sip-connector 19.7.0 → 19.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@SipConnector-BLD-EPG1.cjs +1 -0
- package/dist/{@SipConnector-DXMX6l2G.js → @SipConnector-Ce87V-66.js} +740 -696
- package/dist/AutoConnectorManager/@AutoConnectorManager.d.ts +12 -11
- package/dist/CallManager/@CallManager.d.ts +2 -4
- package/dist/CallManager/AbstractCallStrategy.d.ts +2 -9
- package/dist/CallManager/MCUCallStrategy.d.ts +3 -10
- package/dist/CallManager/MCUSession.d.ts +33 -0
- package/dist/CallManager/types.d.ts +19 -2
- package/dist/ConnectionManager/ConnectionFlow.d.ts +1 -0
- package/dist/ConnectionManager/eventNames.d.ts +4 -2
- package/dist/ConnectionManager/index.d.ts +1 -1
- package/dist/SipConnector/@SipConnector.d.ts +0 -1
- package/dist/SipConnector/eventNames.d.ts +1 -1
- package/dist/VideoSendingBalancer/__fixtures__/createMockTrack.d.ts +1 -1
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/package.json +9 -9
- package/dist/@SipConnector-CMDm0Voo.cjs +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Events as
|
|
1
|
+
import { Events as F, TypedEvents as w } from "events-constructor";
|
|
2
2
|
import x from "debug";
|
|
3
|
-
import { CancelableRequest as G, isCanceledError as
|
|
4
|
-
import { resolveRequesterByTimeout as
|
|
5
|
-
import { hasCanceledError as
|
|
6
|
-
import { setup as
|
|
7
|
-
import { createStackPromises as
|
|
3
|
+
import { CancelableRequest as G, isCanceledError as _e } from "@krivega/cancelable-promise";
|
|
4
|
+
import { resolveRequesterByTimeout as Me, requesterByTimeoutsWithFailCalls as ve, DelayRequester as fe, hasCanceledError as Pe, SetTimeoutRequest as ee } from "@krivega/timeout-requester";
|
|
5
|
+
import { hasCanceledError as Oe, repeatedCallsAsync as te } from "repeated-calls";
|
|
6
|
+
import { setup as ye, createActor as De } from "xstate";
|
|
7
|
+
import { createStackPromises as ne, isPromiseIsNotActualError as be } from "stack-promises";
|
|
8
8
|
import "ua-parser-js";
|
|
9
9
|
import "sequent-promises";
|
|
10
|
-
const Q = "sip-connector",
|
|
10
|
+
const Q = "sip-connector", c = x(Q), xn = () => {
|
|
11
11
|
x.enable(Q);
|
|
12
|
-
},
|
|
12
|
+
}, Gn = () => {
|
|
13
13
|
x.enable(`-${Q}`);
|
|
14
|
-
},
|
|
15
|
-
var l = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n))(l || {}),
|
|
16
|
-
const
|
|
14
|
+
}, we = "Error decline with 603", Ue = 1006, Le = (n) => typeof n == "object" && n !== null && "code" in n && n.code === Ue, Be = (n) => n.message === we;
|
|
15
|
+
var l = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n))(l || {}), L = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(L || {}), V = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(V || {}), P = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.RESTART = "application/vinteo.webrtc.restart", n))(P || {}), p = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(p || {}), f = /* @__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))(f || {}), H = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(H || {}), W = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(W || {}), Fe = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Fe || {}), g = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n.RESTART = "restart", n))(g || {});
|
|
16
|
+
const se = [
|
|
17
17
|
"participation:accepting-word-request",
|
|
18
18
|
"participation:cancelling-word-request",
|
|
19
19
|
"participant:move-request-to-stream",
|
|
@@ -43,8 +43,8 @@ const ne = [
|
|
|
43
43
|
"newDTMF",
|
|
44
44
|
"restart"
|
|
45
45
|
];
|
|
46
|
-
var
|
|
47
|
-
class
|
|
46
|
+
var m = /* @__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))(m || {});
|
|
47
|
+
class ke {
|
|
48
48
|
events;
|
|
49
49
|
connectionManager;
|
|
50
50
|
callManager;
|
|
@@ -52,7 +52,7 @@ class Fe {
|
|
|
52
52
|
connectionManager: e,
|
|
53
53
|
callManager: t
|
|
54
54
|
}) {
|
|
55
|
-
this.connectionManager = e, this.callManager = t, this.events = new
|
|
55
|
+
this.connectionManager = e, this.callManager = t, this.events = new F(se), this.subscribe();
|
|
56
56
|
}
|
|
57
57
|
async waitChannels() {
|
|
58
58
|
return this.wait(g.CHANNELS);
|
|
@@ -62,54 +62,54 @@ class Fe {
|
|
|
62
62
|
}
|
|
63
63
|
async sendDTMF(e) {
|
|
64
64
|
return new Promise((t, s) => {
|
|
65
|
-
let
|
|
65
|
+
let i;
|
|
66
66
|
try {
|
|
67
|
-
|
|
68
|
-
} catch (
|
|
69
|
-
s(
|
|
67
|
+
i = this.getEstablishedRTCSessionProtected();
|
|
68
|
+
} catch (r) {
|
|
69
|
+
s(r);
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}),
|
|
71
|
+
i && (this.callManager.once("newDTMF", ({ originator: r }) => {
|
|
72
|
+
r === "local" && t();
|
|
73
|
+
}), i.sendDTMF(e, {
|
|
74
74
|
duration: 120,
|
|
75
75
|
interToneGap: 600
|
|
76
76
|
}));
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
async sendChannels({ inputChannels: e, outputChannels: t }) {
|
|
80
|
-
const s = this.getEstablishedRTCSessionProtected(),
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const s = this.getEstablishedRTCSessionProtected(), i = `${l.INPUT_CHANNELS}: ${e}`, r = `${l.OUTPUT_CHANNELS}: ${t}`, a = [
|
|
81
|
+
i,
|
|
82
|
+
r
|
|
83
83
|
];
|
|
84
|
-
return s.sendInfo(
|
|
84
|
+
return s.sendInfo(p.CHANNELS, void 0, { extraHeaders: a });
|
|
85
85
|
}
|
|
86
86
|
async sendMediaState({ cam: e, mic: t }, s = {}) {
|
|
87
|
-
const
|
|
88
|
-
|
|
87
|
+
const i = this.getEstablishedRTCSessionProtected(), r = `${l.MEDIA_STATE}: currentstate`, a = `${l.MAIN_CAM_STATE}: ${Number(e)}`, o = `${l.MIC_STATE}: ${Number(t)}`, h = [
|
|
88
|
+
r,
|
|
89
89
|
a,
|
|
90
90
|
o
|
|
91
91
|
];
|
|
92
|
-
return
|
|
92
|
+
return i.sendInfo(p.MEDIA_STATE, void 0, {
|
|
93
93
|
noTerminateWhenError: !0,
|
|
94
94
|
...s,
|
|
95
|
-
extraHeaders:
|
|
95
|
+
extraHeaders: h
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
async sendStats({
|
|
99
99
|
availableIncomingBitrate: e
|
|
100
100
|
}) {
|
|
101
|
-
const t = this.getEstablishedRTCSessionProtected(),
|
|
102
|
-
return t.sendInfo(
|
|
101
|
+
const t = this.getEstablishedRTCSessionProtected(), i = [`${l.AVAILABLE_INCOMING_BITRATE}: ${e}`];
|
|
102
|
+
return t.sendInfo(p.STATS, void 0, {
|
|
103
103
|
noTerminateWhenError: !0,
|
|
104
|
-
extraHeaders:
|
|
104
|
+
extraHeaders: i
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
async sendRefusalToTurnOn(e, t = {}) {
|
|
108
|
-
const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1,
|
|
109
|
-
return s.sendInfo(
|
|
108
|
+
const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, h = [`${l.MEDIA_TYPE}: ${a}`];
|
|
109
|
+
return s.sendInfo(p.REFUSAL, void 0, {
|
|
110
110
|
noTerminateWhenError: !0,
|
|
111
111
|
...t,
|
|
112
|
-
extraHeaders:
|
|
112
|
+
extraHeaders: h
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
async sendRefusalToTurnOnMic(e = {}) {
|
|
@@ -119,39 +119,39 @@ class Fe {
|
|
|
119
119
|
return this.sendRefusalToTurnOn("cam", { noTerminateWhenError: !0, ...e });
|
|
120
120
|
}
|
|
121
121
|
async sendMustStopPresentationP2P() {
|
|
122
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
122
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(p.SHARE_STATE, void 0, {
|
|
123
123
|
extraHeaders: [l.MUST_STOP_PRESENTATION_P2P]
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
async sendStoppedPresentationP2P() {
|
|
127
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
127
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(p.SHARE_STATE, void 0, {
|
|
128
128
|
extraHeaders: [l.STOP_PRESENTATION_P2P]
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
async sendStoppedPresentation() {
|
|
132
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
132
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(p.SHARE_STATE, void 0, {
|
|
133
133
|
extraHeaders: [l.STOP_PRESENTATION]
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
async askPermissionToStartPresentationP2P() {
|
|
137
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
137
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(p.SHARE_STATE, void 0, {
|
|
138
138
|
extraHeaders: [l.START_PRESENTATION_P2P]
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
async askPermissionToStartPresentation() {
|
|
142
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
142
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(p.SHARE_STATE, void 0, {
|
|
143
143
|
extraHeaders: [l.START_PRESENTATION]
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
async askPermissionToEnableCam(e = {}) {
|
|
147
147
|
const t = this.getEstablishedRTCSessionProtected(), s = [l.ENABLE_MAIN_CAM];
|
|
148
|
-
return t.sendInfo(
|
|
148
|
+
return t.sendInfo(p.MAIN_CAM, void 0, {
|
|
149
149
|
noTerminateWhenError: !0,
|
|
150
150
|
...e,
|
|
151
151
|
extraHeaders: s
|
|
152
|
-
}).catch((
|
|
153
|
-
if (
|
|
154
|
-
throw
|
|
152
|
+
}).catch((i) => {
|
|
153
|
+
if (Be(i))
|
|
154
|
+
throw i;
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
@@ -195,115 +195,115 @@ class Fe {
|
|
|
195
195
|
this.handleNotify(s);
|
|
196
196
|
}
|
|
197
197
|
} catch (t) {
|
|
198
|
-
|
|
198
|
+
c("error parse notify", t);
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
201
|
handleNotify = (e) => {
|
|
202
202
|
switch (e.cmd) {
|
|
203
|
-
case
|
|
203
|
+
case m.CHANNELS: {
|
|
204
204
|
const t = e;
|
|
205
205
|
this.triggerChannelsNotify(t);
|
|
206
206
|
break;
|
|
207
207
|
}
|
|
208
|
-
case
|
|
208
|
+
case m.WEBCAST_STARTED: {
|
|
209
209
|
const t = e;
|
|
210
210
|
this.triggerWebcastStartedNotify(t);
|
|
211
211
|
break;
|
|
212
212
|
}
|
|
213
|
-
case
|
|
213
|
+
case m.WEBCAST_STOPPED: {
|
|
214
214
|
const t = e;
|
|
215
215
|
this.triggerWebcastStoppedNotify(t);
|
|
216
216
|
break;
|
|
217
217
|
}
|
|
218
|
-
case
|
|
218
|
+
case m.ADDED_TO_LIST_MODERATORS: {
|
|
219
219
|
const t = e;
|
|
220
220
|
this.triggerAddedToListModeratorsNotify(t);
|
|
221
221
|
break;
|
|
222
222
|
}
|
|
223
|
-
case
|
|
223
|
+
case m.REMOVED_FROM_LIST_MODERATORS: {
|
|
224
224
|
const t = e;
|
|
225
225
|
this.triggerRemovedFromListModeratorsNotify(t);
|
|
226
226
|
break;
|
|
227
227
|
}
|
|
228
|
-
case
|
|
228
|
+
case m.ACCEPTING_WORD_REQUEST: {
|
|
229
229
|
const t = e;
|
|
230
230
|
this.triggerParticipationAcceptingWordRequest(t);
|
|
231
231
|
break;
|
|
232
232
|
}
|
|
233
|
-
case
|
|
233
|
+
case m.CANCELLING_WORD_REQUEST: {
|
|
234
234
|
const t = e;
|
|
235
235
|
this.triggerParticipationCancellingWordRequest(t);
|
|
236
236
|
break;
|
|
237
237
|
}
|
|
238
|
-
case
|
|
238
|
+
case m.MOVE_REQUEST_TO_STREAM: {
|
|
239
239
|
const t = e;
|
|
240
240
|
this.triggerParticipantMoveRequestToStream(t);
|
|
241
241
|
break;
|
|
242
242
|
}
|
|
243
|
-
case
|
|
243
|
+
case m.ACCOUNT_CHANGED: {
|
|
244
244
|
this.triggerAccountChangedNotify();
|
|
245
245
|
break;
|
|
246
246
|
}
|
|
247
|
-
case
|
|
247
|
+
case m.ACCOUNT_DELETED: {
|
|
248
248
|
this.triggerAccountDeletedNotify();
|
|
249
249
|
break;
|
|
250
250
|
}
|
|
251
|
-
case
|
|
251
|
+
case m.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
|
|
252
252
|
const t = e;
|
|
253
253
|
this.triggerConferenceParticipantTokenIssued(t);
|
|
254
254
|
break;
|
|
255
255
|
}
|
|
256
256
|
default:
|
|
257
|
-
|
|
257
|
+
c("unknown cmd", e);
|
|
258
258
|
}
|
|
259
259
|
};
|
|
260
260
|
handleNewInfo = (e) => {
|
|
261
261
|
const { originator: t } = e;
|
|
262
262
|
if (t !== "remote")
|
|
263
263
|
return;
|
|
264
|
-
const { request: s } = e,
|
|
265
|
-
if (
|
|
266
|
-
switch (
|
|
264
|
+
const { request: s } = e, i = s, r = i.getHeader(l.CONTENT_TYPE);
|
|
265
|
+
if (r !== void 0)
|
|
266
|
+
switch (r) {
|
|
267
267
|
case P.ENTER_ROOM: {
|
|
268
|
-
this.triggerEnterRoom(
|
|
268
|
+
this.triggerEnterRoom(i), this.maybeTriggerChannels(i);
|
|
269
269
|
break;
|
|
270
270
|
}
|
|
271
271
|
case P.NOTIFY: {
|
|
272
|
-
this.maybeHandleNotify(
|
|
272
|
+
this.maybeHandleNotify(i);
|
|
273
273
|
break;
|
|
274
274
|
}
|
|
275
275
|
case P.SHARE_STATE: {
|
|
276
|
-
this.triggerShareState(
|
|
276
|
+
this.triggerShareState(i);
|
|
277
277
|
break;
|
|
278
278
|
}
|
|
279
279
|
case P.MAIN_CAM: {
|
|
280
|
-
this.triggerMainCamControl(
|
|
280
|
+
this.triggerMainCamControl(i);
|
|
281
281
|
break;
|
|
282
282
|
}
|
|
283
283
|
case P.MIC: {
|
|
284
|
-
this.triggerMicControl(
|
|
284
|
+
this.triggerMicControl(i);
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
287
|
case P.USE_LICENSE: {
|
|
288
|
-
this.triggerUseLicense(
|
|
288
|
+
this.triggerUseLicense(i);
|
|
289
289
|
break;
|
|
290
290
|
}
|
|
291
291
|
case P.PARTICIPANT_STATE: {
|
|
292
|
-
this.maybeTriggerParticipantMoveRequest(
|
|
292
|
+
this.maybeTriggerParticipantMoveRequest(i);
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
295
|
case P.RESTART: {
|
|
296
|
-
this.triggerRestart(
|
|
296
|
+
this.triggerRestart(i);
|
|
297
297
|
break;
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
};
|
|
301
301
|
triggerChannelsNotify = (e) => {
|
|
302
|
-
const t = e.input, s = e.output,
|
|
302
|
+
const t = e.input, s = e.output, i = {
|
|
303
303
|
inputChannels: t,
|
|
304
304
|
outputChannels: s
|
|
305
305
|
};
|
|
306
|
-
this.events.trigger(g.CHANNELS_NOTIFY,
|
|
306
|
+
this.events.trigger(g.CHANNELS_NOTIFY, i);
|
|
307
307
|
};
|
|
308
308
|
triggerWebcastStartedNotify = ({
|
|
309
309
|
body: { conference: e, type: t }
|
|
@@ -378,24 +378,24 @@ class Fe {
|
|
|
378
378
|
triggerConferenceParticipantTokenIssued = ({
|
|
379
379
|
body: { conference: e, participant: t, jwt: s }
|
|
380
380
|
}) => {
|
|
381
|
-
const
|
|
381
|
+
const i = {
|
|
382
382
|
conference: e,
|
|
383
383
|
participant: t,
|
|
384
384
|
jwt: s
|
|
385
385
|
};
|
|
386
386
|
this.events.trigger(
|
|
387
387
|
g.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
|
|
388
|
-
|
|
388
|
+
i
|
|
389
389
|
);
|
|
390
390
|
};
|
|
391
391
|
maybeTriggerChannels = (e) => {
|
|
392
392
|
const t = e.getHeader(l.INPUT_CHANNELS), s = e.getHeader(l.OUTPUT_CHANNELS);
|
|
393
393
|
if (t && s) {
|
|
394
|
-
const
|
|
394
|
+
const i = {
|
|
395
395
|
inputChannels: t,
|
|
396
396
|
outputChannels: s
|
|
397
397
|
};
|
|
398
|
-
this.events.trigger(g.CHANNELS,
|
|
398
|
+
this.events.trigger(g.CHANNELS, i);
|
|
399
399
|
}
|
|
400
400
|
};
|
|
401
401
|
triggerEnterRoom = (e) => {
|
|
@@ -406,15 +406,15 @@ class Fe {
|
|
|
406
406
|
const t = e.getHeader(l.CONTENT_SHARE_STATE);
|
|
407
407
|
if (t !== void 0)
|
|
408
408
|
switch (t) {
|
|
409
|
-
case
|
|
409
|
+
case L.AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
410
410
|
this.events.trigger(g.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
|
|
411
411
|
break;
|
|
412
412
|
}
|
|
413
|
-
case
|
|
413
|
+
case L.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
414
414
|
this.events.trigger(g.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
|
|
415
415
|
break;
|
|
416
416
|
}
|
|
417
|
-
case
|
|
417
|
+
case L.MUST_STOP_PRESENTATION: {
|
|
418
418
|
this.events.trigger(g.MUST_STOP_PRESENTATION, void 0);
|
|
419
419
|
break;
|
|
420
420
|
}
|
|
@@ -425,25 +425,25 @@ class Fe {
|
|
|
425
425
|
t === V.SPECTATOR && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === V.PARTICIPANT && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0);
|
|
426
426
|
};
|
|
427
427
|
triggerMainCamControl = (e) => {
|
|
428
|
-
const t = e.getHeader(l.MAIN_CAM), s = e.getHeader(l.MEDIA_SYNC),
|
|
429
|
-
if (t ===
|
|
430
|
-
this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced:
|
|
428
|
+
const t = e.getHeader(l.MAIN_CAM), s = e.getHeader(l.MEDIA_SYNC), i = s === W.ADMIN_SYNC_FORCED;
|
|
429
|
+
if (t === f.ADMIN_START_MAIN_CAM) {
|
|
430
|
+
this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: i });
|
|
431
431
|
return;
|
|
432
432
|
}
|
|
433
|
-
if (t ===
|
|
434
|
-
this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced:
|
|
433
|
+
if (t === f.ADMIN_STOP_MAIN_CAM) {
|
|
434
|
+
this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
|
|
435
435
|
return;
|
|
436
436
|
}
|
|
437
|
-
(t ===
|
|
438
|
-
const
|
|
437
|
+
(t === f.RESUME_MAIN_CAM || t === f.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
|
|
438
|
+
const r = e.getHeader(l.MAIN_CAM_RESOLUTION);
|
|
439
439
|
this.events.trigger(g.MAIN_CAM_CONTROL, {
|
|
440
440
|
mainCam: t,
|
|
441
|
-
resolutionMainCam:
|
|
441
|
+
resolutionMainCam: r
|
|
442
442
|
});
|
|
443
443
|
};
|
|
444
444
|
triggerMicControl = (e) => {
|
|
445
|
-
const t = e.getHeader(l.MIC),
|
|
446
|
-
t ===
|
|
445
|
+
const t = e.getHeader(l.MIC), i = e.getHeader(l.MEDIA_SYNC) === W.ADMIN_SYNC_FORCED;
|
|
446
|
+
t === H.ADMIN_START_MIC ? this.events.trigger(g.ADMIN_START_MIC, { isSyncForced: i }) : t === H.ADMIN_STOP_MIC && this.events.trigger(g.ADMIN_STOP_MIC, { isSyncForced: i });
|
|
447
447
|
};
|
|
448
448
|
triggerUseLicense = (e) => {
|
|
449
449
|
const t = e.getHeader(l.CONTENT_USE_LICENSE);
|
|
@@ -454,14 +454,14 @@ class Fe {
|
|
|
454
454
|
l.TRACKS_DIRECTION
|
|
455
455
|
), s = Number(
|
|
456
456
|
e.getHeader(l.AUDIO_TRACK_COUNT)
|
|
457
|
-
),
|
|
457
|
+
), i = Number(
|
|
458
458
|
e.getHeader(l.VIDEO_TRACK_COUNT)
|
|
459
|
-
),
|
|
460
|
-
this.events.trigger(g.RESTART,
|
|
459
|
+
), r = { tracksDirection: t, audioTrackCount: s, videoTrackCount: i };
|
|
460
|
+
this.events.trigger(g.RESTART, r);
|
|
461
461
|
};
|
|
462
462
|
}
|
|
463
|
-
var
|
|
464
|
-
const
|
|
463
|
+
var R = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n.CALL_STATUS_CHANGED = "call-status-changed", n))(R || {}), $e = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))($e || {});
|
|
464
|
+
const ie = [
|
|
465
465
|
"peerconnection",
|
|
466
466
|
"connecting",
|
|
467
467
|
"sending",
|
|
@@ -488,32 +488,19 @@ const se = [
|
|
|
488
488
|
"peerconnection:createanswerfailed",
|
|
489
489
|
"peerconnection:setlocaldescriptionfailed",
|
|
490
490
|
"peerconnection:setremotedescriptionfailed"
|
|
491
|
-
],
|
|
491
|
+
], qe = [
|
|
492
492
|
"peerconnection:confirmed",
|
|
493
493
|
"peerconnection:ontrack",
|
|
494
494
|
"ended:fromserver",
|
|
495
495
|
"call-status-changed"
|
|
496
496
|
], re = [
|
|
497
|
-
...
|
|
498
|
-
|
|
499
|
-
]
|
|
500
|
-
n.getVideoTracks().forEach((s) => {
|
|
501
|
-
"contentHint" in s && s.contentHint !== e && (s.contentHint = e);
|
|
502
|
-
});
|
|
503
|
-
}, F = (n, {
|
|
504
|
-
directionVideo: e,
|
|
505
|
-
directionAudio: t,
|
|
506
|
-
contentHint: s
|
|
507
|
-
} = {}) => {
|
|
508
|
-
if (!n || e === "recvonly" && t === "recvonly")
|
|
509
|
-
return;
|
|
510
|
-
const r = t === "recvonly" ? [] : n.getAudioTracks(), i = e === "recvonly" ? [] : n.getVideoTracks(), a = [...r, ...i], o = new MediaStream(a);
|
|
511
|
-
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && qe(o, s), o;
|
|
512
|
-
};
|
|
497
|
+
...ie,
|
|
498
|
+
...qe
|
|
499
|
+
];
|
|
513
500
|
function Ve(n) {
|
|
514
501
|
return (e) => `sip:${e}@${n}`;
|
|
515
502
|
}
|
|
516
|
-
const
|
|
503
|
+
const He = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, ae = (n) => n.trim().replaceAll(" ", "_"), We = He(1e5, 99999999), xe = (n) => n.some((t) => {
|
|
517
504
|
const { kind: s } = t;
|
|
518
505
|
return s === "video";
|
|
519
506
|
});
|
|
@@ -528,44 +515,28 @@ class Ge {
|
|
|
528
515
|
this.events = e;
|
|
529
516
|
}
|
|
530
517
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
return;
|
|
550
|
-
const i = s, a = e[r - 1];
|
|
551
|
-
let o;
|
|
552
|
-
a?.kind === "audio" && (o = a);
|
|
553
|
-
const c = this.generateStream(i, o);
|
|
554
|
-
t.push(c);
|
|
555
|
-
}), t;
|
|
556
|
-
}
|
|
557
|
-
generateAudioStreams(e) {
|
|
558
|
-
return e.map((t) => this.generateAudioStream(t));
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
class Ye extends Ge {
|
|
562
|
-
remoteStreamsManager = new Qe();
|
|
518
|
+
const Qe = (n, e) => {
|
|
519
|
+
n.getVideoTracks().forEach((s) => {
|
|
520
|
+
"contentHint" in s && s.contentHint !== e && (s.contentHint = e);
|
|
521
|
+
});
|
|
522
|
+
}, B = (n, {
|
|
523
|
+
directionVideo: e,
|
|
524
|
+
directionAudio: t,
|
|
525
|
+
contentHint: s
|
|
526
|
+
} = {}) => {
|
|
527
|
+
if (!n || e === "recvonly" && t === "recvonly")
|
|
528
|
+
return;
|
|
529
|
+
const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
|
|
530
|
+
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && Qe(o, s), o;
|
|
531
|
+
};
|
|
532
|
+
var oe = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(oe || {});
|
|
533
|
+
class Ye {
|
|
534
|
+
events;
|
|
535
|
+
rtcSession;
|
|
563
536
|
disposers = /* @__PURE__ */ new Set();
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
get requested() {
|
|
568
|
-
return this.isPendingCall || this.isPendingAnswer;
|
|
537
|
+
onReset;
|
|
538
|
+
constructor(e, { onReset: t }) {
|
|
539
|
+
this.events = e, this.onReset = t, e.on(R.FAILED, this.handleEnded), e.on(R.ENDED, this.handleEnded);
|
|
569
540
|
}
|
|
570
541
|
get connection() {
|
|
571
542
|
return this.rtcSession?.connection;
|
|
@@ -573,29 +544,27 @@ class Ye extends Ge {
|
|
|
573
544
|
get isCallActive() {
|
|
574
545
|
return this.rtcSession?.isEstablished() === !0;
|
|
575
546
|
}
|
|
576
|
-
|
|
577
|
-
return this.rtcSession?.isEstablished() === !0 ? this.rtcSession : void 0;
|
|
578
|
-
}
|
|
547
|
+
getEstablishedRTCSession = () => this.rtcSession?.isEstablished() === !0 ? this.rtcSession : void 0;
|
|
579
548
|
startCall = async (e, t, {
|
|
580
549
|
number: s,
|
|
581
|
-
mediaStream:
|
|
582
|
-
extraHeaders:
|
|
550
|
+
mediaStream: i,
|
|
551
|
+
extraHeaders: r = [],
|
|
583
552
|
ontrack: a,
|
|
584
553
|
iceServers: o,
|
|
585
|
-
directionVideo:
|
|
554
|
+
directionVideo: h,
|
|
586
555
|
directionAudio: d,
|
|
587
556
|
contentHint: T,
|
|
588
557
|
offerToReceiveAudio: S = !0,
|
|
589
558
|
offerToReceiveVideo: u = !0,
|
|
590
559
|
degradationPreference: E,
|
|
591
|
-
sendEncodings:
|
|
592
|
-
onAddedTransceiver:
|
|
593
|
-
}) =>
|
|
594
|
-
this.
|
|
595
|
-
|
|
560
|
+
sendEncodings: I,
|
|
561
|
+
onAddedTransceiver: N
|
|
562
|
+
}) => new Promise((M, k) => {
|
|
563
|
+
this.handleCall({ ontrack: a }).then(M).catch(($) => {
|
|
564
|
+
k($);
|
|
596
565
|
}), this.rtcSession = e.call(t(s), {
|
|
597
|
-
mediaStream:
|
|
598
|
-
directionVideo:
|
|
566
|
+
mediaStream: B(i, {
|
|
567
|
+
directionVideo: h,
|
|
599
568
|
directionAudio: d,
|
|
600
569
|
contentHint: T
|
|
601
570
|
}),
|
|
@@ -610,21 +579,19 @@ class Ye extends Ge {
|
|
|
610
579
|
// так как в методе call создается RTCSession
|
|
611
580
|
// и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
|
|
612
581
|
eventHandlers: this.events.triggers,
|
|
613
|
-
extraHeaders:
|
|
614
|
-
directionVideo:
|
|
582
|
+
extraHeaders: r,
|
|
583
|
+
directionVideo: h,
|
|
615
584
|
directionAudio: d,
|
|
616
585
|
degradationPreference: E,
|
|
617
|
-
sendEncodings:
|
|
618
|
-
onAddedTransceiver:
|
|
586
|
+
sendEncodings: I,
|
|
587
|
+
onAddedTransceiver: N
|
|
619
588
|
});
|
|
620
|
-
})
|
|
621
|
-
this.isPendingCall = !1;
|
|
622
|
-
}));
|
|
589
|
+
});
|
|
623
590
|
async endCall() {
|
|
624
591
|
const { rtcSession: e } = this;
|
|
625
592
|
if (e && !e.isEnded())
|
|
626
593
|
return e.terminateAsync({
|
|
627
|
-
cause:
|
|
594
|
+
cause: oe.CANCELED
|
|
628
595
|
}).finally(() => {
|
|
629
596
|
this.reset();
|
|
630
597
|
});
|
|
@@ -633,66 +600,54 @@ class Ye extends Ge {
|
|
|
633
600
|
answerToIncomingCall = async (e, {
|
|
634
601
|
mediaStream: t,
|
|
635
602
|
ontrack: s,
|
|
636
|
-
extraHeaders:
|
|
637
|
-
iceServers:
|
|
603
|
+
extraHeaders: i = [],
|
|
604
|
+
iceServers: r,
|
|
638
605
|
directionVideo: a,
|
|
639
606
|
directionAudio: o,
|
|
640
|
-
offerToReceiveAudio:
|
|
607
|
+
offerToReceiveAudio: h,
|
|
641
608
|
offerToReceiveVideo: d,
|
|
642
609
|
contentHint: T,
|
|
643
610
|
degradationPreference: S,
|
|
644
611
|
sendEncodings: u,
|
|
645
612
|
onAddedTransceiver: E
|
|
646
|
-
}) =>
|
|
613
|
+
}) => new Promise((I, N) => {
|
|
647
614
|
try {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}), R.answer({
|
|
615
|
+
this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall({ ontrack: s }).then(I).catch((M) => {
|
|
616
|
+
N(M);
|
|
617
|
+
}), e.answer({
|
|
652
618
|
pcConfig: {
|
|
653
|
-
iceServers:
|
|
619
|
+
iceServers: r
|
|
654
620
|
},
|
|
655
621
|
rtcOfferConstraints: {
|
|
656
|
-
offerToReceiveAudio:
|
|
622
|
+
offerToReceiveAudio: h,
|
|
657
623
|
offerToReceiveVideo: d
|
|
658
624
|
},
|
|
659
|
-
mediaStream:
|
|
625
|
+
mediaStream: B(t, {
|
|
660
626
|
directionVideo: a,
|
|
661
627
|
directionAudio: o,
|
|
662
628
|
contentHint: T
|
|
663
629
|
}),
|
|
664
|
-
extraHeaders:
|
|
630
|
+
extraHeaders: i,
|
|
665
631
|
directionVideo: a,
|
|
666
632
|
directionAudio: o,
|
|
667
633
|
degradationPreference: S,
|
|
668
634
|
sendEncodings: u,
|
|
669
635
|
onAddedTransceiver: E
|
|
670
636
|
});
|
|
671
|
-
} catch (
|
|
672
|
-
|
|
637
|
+
} catch (M) {
|
|
638
|
+
N(M);
|
|
673
639
|
}
|
|
674
|
-
})
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
getEstablishedRTCSession() {
|
|
678
|
-
return this.rtcSession?.isEstablished() === !0 ? this.rtcSession : void 0;
|
|
679
|
-
}
|
|
680
|
-
getCallConfiguration() {
|
|
681
|
-
return { ...this.callConfiguration };
|
|
682
|
-
}
|
|
683
|
-
getRemoteStreams() {
|
|
684
|
-
if (!this.connection)
|
|
685
|
-
return;
|
|
686
|
-
const t = this.connection.getReceivers().map(({ track: s }) => s);
|
|
687
|
-
return xe(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
|
|
640
|
+
});
|
|
641
|
+
getRemoteTracks() {
|
|
642
|
+
return this.connection ? this.connection.getReceivers().map(({ track: s }) => s) : void 0;
|
|
688
643
|
}
|
|
689
644
|
async replaceMediaStream(e, t) {
|
|
690
645
|
if (!this.rtcSession)
|
|
691
646
|
throw new Error("No rtcSession established");
|
|
692
|
-
const { contentHint: s } = t ?? {},
|
|
693
|
-
if (
|
|
647
|
+
const { contentHint: s } = t ?? {}, i = B(e, { contentHint: s });
|
|
648
|
+
if (i === void 0)
|
|
694
649
|
throw new Error("No preparedMediaStream");
|
|
695
|
-
return this.rtcSession.replaceMediaStream(
|
|
650
|
+
return this.rtcSession.replaceMediaStream(i, t);
|
|
696
651
|
}
|
|
697
652
|
async restartIce(e) {
|
|
698
653
|
if (!this.rtcSession)
|
|
@@ -707,36 +662,36 @@ class Ye extends Ge {
|
|
|
707
662
|
handleCall = async ({
|
|
708
663
|
ontrack: e
|
|
709
664
|
}) => new Promise((t, s) => {
|
|
710
|
-
const
|
|
711
|
-
this.events.on(
|
|
712
|
-
},
|
|
713
|
-
this.events.off(
|
|
665
|
+
const i = () => {
|
|
666
|
+
this.events.on(R.PEER_CONNECTION, T), this.events.on(R.CONFIRMED, S);
|
|
667
|
+
}, r = () => {
|
|
668
|
+
this.events.off(R.PEER_CONNECTION, T), this.events.off(R.CONFIRMED, S);
|
|
714
669
|
}, a = () => {
|
|
715
|
-
this.events.on(
|
|
670
|
+
this.events.on(R.FAILED, h), this.events.on(R.ENDED, h);
|
|
716
671
|
}, o = () => {
|
|
717
|
-
this.events.off(
|
|
718
|
-
},
|
|
719
|
-
|
|
672
|
+
this.events.off(R.FAILED, h), this.events.off(R.ENDED, h);
|
|
673
|
+
}, h = (u) => {
|
|
674
|
+
r(), o(), s(u);
|
|
720
675
|
};
|
|
721
676
|
let d;
|
|
722
677
|
const T = ({ peerconnection: u }) => {
|
|
723
678
|
d = u;
|
|
724
|
-
const E = (
|
|
725
|
-
this.events.trigger(
|
|
679
|
+
const E = (I) => {
|
|
680
|
+
this.events.trigger(R.PEER_CONNECTION_ONTRACK, I), e && e(I);
|
|
726
681
|
};
|
|
727
682
|
u.addEventListener("track", E), this.disposers.add(() => {
|
|
728
683
|
u.removeEventListener("track", E);
|
|
729
684
|
});
|
|
730
685
|
}, S = () => {
|
|
731
|
-
d !== void 0 && this.events.trigger(
|
|
686
|
+
d !== void 0 && this.events.trigger(R.PEER_CONNECTION_CONFIRMED, d), r(), o(), t(d);
|
|
732
687
|
};
|
|
733
|
-
|
|
688
|
+
i(), a();
|
|
734
689
|
});
|
|
735
690
|
subscribeToSessionEvents(e) {
|
|
736
691
|
this.events.eachTriggers((t, s) => {
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
e.off(
|
|
692
|
+
const i = ie.find((r) => r === s);
|
|
693
|
+
i && (e.on(i, t), this.disposers.add(() => {
|
|
694
|
+
e.off(i, t);
|
|
740
695
|
}));
|
|
741
696
|
});
|
|
742
697
|
}
|
|
@@ -747,17 +702,96 @@ class Ye extends Ge {
|
|
|
747
702
|
}
|
|
748
703
|
handleEnded = (e) => {
|
|
749
704
|
const { originator: t } = e;
|
|
750
|
-
t === "remote" && this.events.trigger(
|
|
705
|
+
t === "remote" && this.events.trigger(R.ENDED_FROM_SERVER, e), this.reset();
|
|
751
706
|
};
|
|
752
707
|
reset = () => {
|
|
753
|
-
delete this.rtcSession, this.
|
|
708
|
+
delete this.rtcSession, this.unsubscribeFromSessionEvents(), this.onReset();
|
|
754
709
|
};
|
|
755
710
|
}
|
|
756
711
|
class ze {
|
|
712
|
+
remoteStreams = {};
|
|
713
|
+
reset() {
|
|
714
|
+
this.remoteStreams = {};
|
|
715
|
+
}
|
|
716
|
+
generateStream(e, t) {
|
|
717
|
+
const { id: s } = e, i = this.remoteStreams[s] ?? new MediaStream();
|
|
718
|
+
return t && i.addTrack(t), i.addTrack(e), this.remoteStreams[s] = i, i;
|
|
719
|
+
}
|
|
720
|
+
generateAudioStream(e) {
|
|
721
|
+
const { id: t } = e, s = this.remoteStreams[t] ?? new MediaStream();
|
|
722
|
+
return s.addTrack(e), this.remoteStreams[t] = s, s;
|
|
723
|
+
}
|
|
724
|
+
generateStreams(e) {
|
|
725
|
+
const t = [];
|
|
726
|
+
return e.forEach((s, i) => {
|
|
727
|
+
if (s.kind === "audio")
|
|
728
|
+
return;
|
|
729
|
+
const r = s, a = e[i - 1];
|
|
730
|
+
let o;
|
|
731
|
+
a?.kind === "audio" && (o = a);
|
|
732
|
+
const h = this.generateStream(r, o);
|
|
733
|
+
t.push(h);
|
|
734
|
+
}), t;
|
|
735
|
+
}
|
|
736
|
+
generateAudioStreams(e) {
|
|
737
|
+
return e.map((t) => this.generateAudioStream(t));
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
class Xe extends Ge {
|
|
741
|
+
remoteStreamsManager = new ze();
|
|
742
|
+
mcuSession;
|
|
743
|
+
constructor(e) {
|
|
744
|
+
super(e), this.mcuSession = new Ye(e, { onReset: this.reset });
|
|
745
|
+
}
|
|
746
|
+
get requested() {
|
|
747
|
+
return this.isPendingCall || this.isPendingAnswer;
|
|
748
|
+
}
|
|
749
|
+
get connection() {
|
|
750
|
+
return this.mcuSession.connection;
|
|
751
|
+
}
|
|
752
|
+
get isCallActive() {
|
|
753
|
+
return this.mcuSession.isCallActive;
|
|
754
|
+
}
|
|
755
|
+
getEstablishedRTCSession = () => this.mcuSession.getEstablishedRTCSession();
|
|
756
|
+
startCall = async (e, t, s) => (this.isPendingCall = !0, this.callConfiguration.number = s.number, this.callConfiguration.answer = !1, this.mcuSession.startCall(e, t, s).finally(() => {
|
|
757
|
+
this.isPendingCall = !1;
|
|
758
|
+
}));
|
|
759
|
+
async endCall() {
|
|
760
|
+
return this.mcuSession.endCall();
|
|
761
|
+
}
|
|
762
|
+
answerToIncomingCall = async (e, t) => {
|
|
763
|
+
this.isPendingAnswer = !0;
|
|
764
|
+
const s = e();
|
|
765
|
+
return this.callConfiguration.answer = !0, this.callConfiguration.number = s.remote_identity.uri.user, this.mcuSession.answerToIncomingCall(s, t).finally(() => {
|
|
766
|
+
this.isPendingAnswer = !1;
|
|
767
|
+
});
|
|
768
|
+
};
|
|
769
|
+
getCallConfiguration() {
|
|
770
|
+
return { ...this.callConfiguration };
|
|
771
|
+
}
|
|
772
|
+
getRemoteStreams() {
|
|
773
|
+
const e = this.mcuSession.getRemoteTracks();
|
|
774
|
+
if (e)
|
|
775
|
+
return xe(e) ? this.remoteStreamsManager.generateStreams(e) : this.remoteStreamsManager.generateAudioStreams(e);
|
|
776
|
+
}
|
|
777
|
+
async replaceMediaStream(e, t) {
|
|
778
|
+
return this.mcuSession.replaceMediaStream(e, t);
|
|
779
|
+
}
|
|
780
|
+
async restartIce(e) {
|
|
781
|
+
return this.mcuSession.restartIce(e);
|
|
782
|
+
}
|
|
783
|
+
async addTransceiver(e, t) {
|
|
784
|
+
return this.mcuSession.addTransceiver(e, t);
|
|
785
|
+
}
|
|
786
|
+
reset = () => {
|
|
787
|
+
this.remoteStreamsManager.reset(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1;
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
class Je {
|
|
757
791
|
events;
|
|
758
792
|
strategy;
|
|
759
793
|
constructor(e) {
|
|
760
|
-
this.events = new
|
|
794
|
+
this.events = new w(re), this.strategy = e ?? new Xe(this.events), this.subscribeCallStatusChange();
|
|
761
795
|
}
|
|
762
796
|
get requested() {
|
|
763
797
|
return this.strategy.requested;
|
|
@@ -765,12 +799,10 @@ class ze {
|
|
|
765
799
|
get connection() {
|
|
766
800
|
return this.strategy.connection;
|
|
767
801
|
}
|
|
768
|
-
get establishedRTCSession() {
|
|
769
|
-
return this.strategy.establishedRTCSession;
|
|
770
|
-
}
|
|
771
802
|
get isCallActive() {
|
|
772
803
|
return this.strategy.isCallActive;
|
|
773
804
|
}
|
|
805
|
+
getEstablishedRTCSession = () => this.strategy.getEstablishedRTCSession();
|
|
774
806
|
on(e, t) {
|
|
775
807
|
return this.events.on(e, t);
|
|
776
808
|
}
|
|
@@ -795,7 +827,6 @@ class ze {
|
|
|
795
827
|
startCall = async (...e) => this.strategy.startCall(...e);
|
|
796
828
|
endCall = async () => this.strategy.endCall();
|
|
797
829
|
answerToIncomingCall = async (...e) => this.strategy.answerToIncomingCall(...e);
|
|
798
|
-
getEstablishedRTCSession = () => this.strategy.getEstablishedRTCSession();
|
|
799
830
|
getCallConfiguration = () => this.strategy.getCallConfiguration();
|
|
800
831
|
getRemoteStreams = () => this.strategy.getRemoteStreams();
|
|
801
832
|
addTransceiver = async (...e) => this.strategy.addTransceiver(...e);
|
|
@@ -803,49 +834,49 @@ class ze {
|
|
|
803
834
|
restartIce = async (e) => this.strategy.restartIce(e);
|
|
804
835
|
subscribeCallStatusChange() {
|
|
805
836
|
let { isCallActive: e } = this;
|
|
806
|
-
const { ACCEPTED: t, CONFIRMED: s, ENDED:
|
|
807
|
-
this.onRace([t, s,
|
|
837
|
+
const { ACCEPTED: t, CONFIRMED: s, ENDED: i, FAILED: r } = R;
|
|
838
|
+
this.onRace([t, s, i, r], () => {
|
|
808
839
|
e = this.maybeTriggerCallStatus(e);
|
|
809
840
|
});
|
|
810
841
|
}
|
|
811
842
|
maybeTriggerCallStatus(e) {
|
|
812
843
|
const t = this.isCallActive;
|
|
813
|
-
return t !== e && this.events.trigger(
|
|
844
|
+
return t !== e && this.events.trigger(R.CALL_STATUS_CHANGED, { isCallActive: t }), t;
|
|
814
845
|
}
|
|
815
846
|
}
|
|
816
|
-
const
|
|
847
|
+
const Ke = (n, e) => (n.degradationPreference = e.degradationPreference, n), je = (n, e) => {
|
|
817
848
|
n.encodings ??= [];
|
|
818
849
|
for (let t = n.encodings.length; t < e; t += 1)
|
|
819
850
|
n.encodings.push({});
|
|
820
851
|
return n;
|
|
821
|
-
},
|
|
822
|
-
if (
|
|
852
|
+
}, ce = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, Ze = ce(), et = (n, e) => {
|
|
853
|
+
if (Ze(n, e))
|
|
823
854
|
return n;
|
|
824
|
-
},
|
|
825
|
-
const t = n.maxBitrate, s =
|
|
855
|
+
}, tt = (n, e) => {
|
|
856
|
+
const t = n.maxBitrate, s = et(e, t);
|
|
826
857
|
return s !== void 0 && (n.maxBitrate = s), n;
|
|
827
|
-
},
|
|
828
|
-
|
|
829
|
-
),
|
|
830
|
-
const t = n === void 0 ? void 0 : Math.max(n,
|
|
831
|
-
if (t !== void 0 &&
|
|
858
|
+
}, he = 1, nt = ce(
|
|
859
|
+
he
|
|
860
|
+
), st = (n, e) => {
|
|
861
|
+
const t = n === void 0 ? void 0 : Math.max(n, he);
|
|
862
|
+
if (t !== void 0 && nt(
|
|
832
863
|
t,
|
|
833
864
|
e
|
|
834
865
|
))
|
|
835
866
|
return t;
|
|
836
|
-
},
|
|
837
|
-
const t = n.scaleResolutionDownBy, s =
|
|
867
|
+
}, it = (n, e) => {
|
|
868
|
+
const t = n.scaleResolutionDownBy, s = st(
|
|
838
869
|
e,
|
|
839
870
|
t
|
|
840
871
|
);
|
|
841
872
|
return s !== void 0 && (n.scaleResolutionDownBy = s), n;
|
|
842
|
-
},
|
|
873
|
+
}, rt = (n, e) => {
|
|
843
874
|
const t = e.encodings?.length ?? 0;
|
|
844
|
-
return
|
|
845
|
-
const
|
|
846
|
-
|
|
875
|
+
return je(n, t), n.encodings.forEach((s, i) => {
|
|
876
|
+
const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
|
|
877
|
+
tt(s, a), it(s, o);
|
|
847
878
|
}), n;
|
|
848
|
-
},
|
|
879
|
+
}, at = (n, e) => {
|
|
849
880
|
if (n.codecs?.length !== e.codecs?.length)
|
|
850
881
|
return !0;
|
|
851
882
|
for (let t = 0; t < (n.codecs?.length ?? 0); t++)
|
|
@@ -862,15 +893,15 @@ const Xe = (n, e) => (n.degradationPreference = e.degradationPreference, n), Je
|
|
|
862
893
|
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
863
894
|
return !0;
|
|
864
895
|
return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
|
|
865
|
-
},
|
|
896
|
+
}, ot = async (n, e) => {
|
|
866
897
|
const t = n.getParameters(), s = JSON.parse(
|
|
867
898
|
JSON.stringify(t)
|
|
868
899
|
);
|
|
869
|
-
|
|
870
|
-
const
|
|
871
|
-
return
|
|
872
|
-
},
|
|
873
|
-
const { isChanged: s, parameters:
|
|
900
|
+
rt(t, e), Ke(t, e);
|
|
901
|
+
const i = at(s, t);
|
|
902
|
+
return i && await n.setParameters(t), { parameters: t, isChanged: i };
|
|
903
|
+
}, de = async (n, e, t) => {
|
|
904
|
+
const { isChanged: s, parameters: i } = await ot(n, {
|
|
874
905
|
encodings: [
|
|
875
906
|
{
|
|
876
907
|
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
@@ -878,21 +909,21 @@ const Xe = (n, e) => (n.degradationPreference = e.degradationPreference, n), Je
|
|
|
878
909
|
}
|
|
879
910
|
]
|
|
880
911
|
});
|
|
881
|
-
return s && t && t(
|
|
882
|
-
},
|
|
883
|
-
const s =
|
|
912
|
+
return s && t && t(i), { isChanged: s, parameters: i };
|
|
913
|
+
}, ct = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), ht = async (n, e, t) => {
|
|
914
|
+
const s = ct(n, e);
|
|
884
915
|
if (s)
|
|
885
|
-
return
|
|
916
|
+
return de(s, { maxBitrate: t });
|
|
886
917
|
};
|
|
887
918
|
var O = /* @__PURE__ */ ((n) => (n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n))(O || {});
|
|
888
|
-
const
|
|
919
|
+
const le = [
|
|
889
920
|
"presentation:start",
|
|
890
921
|
"presentation:started",
|
|
891
922
|
"presentation:end",
|
|
892
923
|
"presentation:ended",
|
|
893
924
|
"presentation:failed"
|
|
894
|
-
],
|
|
895
|
-
class
|
|
925
|
+
], dt = 1, Qn = (n) => Oe(n);
|
|
926
|
+
class lt {
|
|
896
927
|
events;
|
|
897
928
|
promisePendingStartPresentation;
|
|
898
929
|
promisePendingStopPresentation;
|
|
@@ -904,7 +935,7 @@ class ht {
|
|
|
904
935
|
callManager: e,
|
|
905
936
|
maxBitrate: t
|
|
906
937
|
}) {
|
|
907
|
-
this.callManager = e, this.maxBitrate = t, this.events = new
|
|
938
|
+
this.callManager = e, this.maxBitrate = t, this.events = new F(le), this.subscribe();
|
|
908
939
|
}
|
|
909
940
|
get isPendingPresentation() {
|
|
910
941
|
return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
|
|
@@ -912,20 +943,20 @@ class ht {
|
|
|
912
943
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
913
944
|
async startPresentation(e, t, {
|
|
914
945
|
isNeedReinvite: s,
|
|
915
|
-
contentHint:
|
|
916
|
-
sendEncodings:
|
|
946
|
+
contentHint: i,
|
|
947
|
+
sendEncodings: r,
|
|
917
948
|
onAddedTransceiver: a
|
|
918
949
|
} = {}, o) {
|
|
919
|
-
const
|
|
950
|
+
const h = this.getRtcSessionProtected();
|
|
920
951
|
if (this.streamPresentationCurrent)
|
|
921
952
|
throw new Error("Presentation is already started");
|
|
922
953
|
return this.sendPresentationWithDuplicatedCalls(e, {
|
|
923
|
-
rtcSession:
|
|
954
|
+
rtcSession: h,
|
|
924
955
|
stream: t,
|
|
925
956
|
presentationOptions: {
|
|
926
957
|
isNeedReinvite: s,
|
|
927
|
-
contentHint:
|
|
928
|
-
sendEncodings:
|
|
958
|
+
contentHint: i,
|
|
959
|
+
sendEncodings: r,
|
|
929
960
|
onAddedTransceiver: a
|
|
930
961
|
},
|
|
931
962
|
options: o
|
|
@@ -937,17 +968,17 @@ class ht {
|
|
|
937
968
|
let s = this.promisePendingStartPresentation ?? Promise.resolve(void 0);
|
|
938
969
|
this.promisePendingStartPresentation && await this.promisePendingStartPresentation.catch(() => {
|
|
939
970
|
});
|
|
940
|
-
const
|
|
941
|
-
return
|
|
942
|
-
throw this.events.trigger(O.FAILED_PRESENTATION,
|
|
971
|
+
const i = this.callManager.getEstablishedRTCSession();
|
|
972
|
+
return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
|
|
973
|
+
throw this.events.trigger(O.FAILED_PRESENTATION, r), r;
|
|
943
974
|
}) : t && this.events.trigger(O.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
|
|
944
975
|
this.resetPresentation();
|
|
945
976
|
});
|
|
946
977
|
}
|
|
947
978
|
async updatePresentation(e, t, {
|
|
948
979
|
contentHint: s,
|
|
949
|
-
sendEncodings:
|
|
950
|
-
onAddedTransceiver:
|
|
980
|
+
sendEncodings: i,
|
|
981
|
+
onAddedTransceiver: r
|
|
951
982
|
} = {}) {
|
|
952
983
|
const a = this.getRtcSessionProtected();
|
|
953
984
|
if (!this.streamPresentationCurrent)
|
|
@@ -955,8 +986,8 @@ class ht {
|
|
|
955
986
|
return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this.sendPresentation(e, a, t, {
|
|
956
987
|
contentHint: s,
|
|
957
988
|
isNeedReinvite: !1,
|
|
958
|
-
sendEncodings:
|
|
959
|
-
onAddedTransceiver:
|
|
989
|
+
sendEncodings: i,
|
|
990
|
+
onAddedTransceiver: r
|
|
960
991
|
}).then(async (o) => (await this.setMaxBitrate(), o));
|
|
961
992
|
}
|
|
962
993
|
cancelSendPresentationWithRepeatedCalls() {
|
|
@@ -997,40 +1028,40 @@ class ht {
|
|
|
997
1028
|
async sendPresentationWithDuplicatedCalls(e, {
|
|
998
1029
|
rtcSession: t,
|
|
999
1030
|
stream: s,
|
|
1000
|
-
presentationOptions:
|
|
1001
|
-
options:
|
|
1002
|
-
callLimit:
|
|
1031
|
+
presentationOptions: i,
|
|
1032
|
+
options: r = {
|
|
1033
|
+
callLimit: dt
|
|
1003
1034
|
}
|
|
1004
1035
|
}) {
|
|
1005
1036
|
const a = async () => this.sendPresentation(
|
|
1006
1037
|
e,
|
|
1007
1038
|
t,
|
|
1008
1039
|
s,
|
|
1009
|
-
|
|
1040
|
+
i
|
|
1010
1041
|
), o = () => !!this.streamPresentationCurrent;
|
|
1011
|
-
return this.cancelableSendPresentationWithRepeatedCalls =
|
|
1042
|
+
return this.cancelableSendPresentationWithRepeatedCalls = te({
|
|
1012
1043
|
targetFunction: a,
|
|
1013
1044
|
isComplete: o,
|
|
1014
1045
|
isRejectAsValid: !0,
|
|
1015
|
-
...
|
|
1016
|
-
}), this.cancelableSendPresentationWithRepeatedCalls.then((
|
|
1046
|
+
...r
|
|
1047
|
+
}), this.cancelableSendPresentationWithRepeatedCalls.then((h) => h);
|
|
1017
1048
|
}
|
|
1018
1049
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
1019
1050
|
async sendPresentation(e, t, s, {
|
|
1020
|
-
isNeedReinvite:
|
|
1021
|
-
contentHint:
|
|
1051
|
+
isNeedReinvite: i = !0,
|
|
1052
|
+
contentHint: r = "detail",
|
|
1022
1053
|
degradationPreference: a,
|
|
1023
1054
|
sendEncodings: o,
|
|
1024
|
-
onAddedTransceiver:
|
|
1055
|
+
onAddedTransceiver: h
|
|
1025
1056
|
}) {
|
|
1026
|
-
const d =
|
|
1057
|
+
const d = B(s, { contentHint: r });
|
|
1027
1058
|
if (d === void 0)
|
|
1028
1059
|
throw new Error("No streamPresentationTarget");
|
|
1029
1060
|
this.streamPresentationCurrent = d;
|
|
1030
|
-
const T = e().then(async () => t.startPresentation(d,
|
|
1061
|
+
const T = e().then(async () => t.startPresentation(d, i, {
|
|
1031
1062
|
degradationPreference: a,
|
|
1032
1063
|
sendEncodings: o,
|
|
1033
|
-
onAddedTransceiver:
|
|
1064
|
+
onAddedTransceiver: h
|
|
1034
1065
|
})).then(this.setMaxBitrate).then(() => s).catch((S) => {
|
|
1035
1066
|
throw this.removeStreamPresentationCurrent(), this.events.trigger(O.FAILED_PRESENTATION, S), S;
|
|
1036
1067
|
});
|
|
@@ -1042,8 +1073,8 @@ class ht {
|
|
|
1042
1073
|
const { connection: e } = this.callManager, { streamPresentationCurrent: t } = this, { maxBitrate: s } = this;
|
|
1043
1074
|
if (!e || !t || s === void 0)
|
|
1044
1075
|
return;
|
|
1045
|
-
const
|
|
1046
|
-
await
|
|
1076
|
+
const i = e.getSenders();
|
|
1077
|
+
await ht(i, t, s);
|
|
1047
1078
|
};
|
|
1048
1079
|
getRtcSessionProtected = () => {
|
|
1049
1080
|
const e = this.callManager.getEstablishedRTCSession();
|
|
@@ -1064,7 +1095,7 @@ class ht {
|
|
|
1064
1095
|
delete this.streamPresentationCurrent;
|
|
1065
1096
|
}
|
|
1066
1097
|
}
|
|
1067
|
-
class
|
|
1098
|
+
class ut {
|
|
1068
1099
|
data;
|
|
1069
1100
|
getUa;
|
|
1070
1101
|
constructor(e) {
|
|
@@ -1144,8 +1175,8 @@ class dt {
|
|
|
1144
1175
|
return this.data?.register === !0;
|
|
1145
1176
|
}
|
|
1146
1177
|
}
|
|
1147
|
-
var C = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.DISCONNECTING = "disconnecting", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n.CONNECT_STARTED = "connect-started", n.CONNECT_SUCCEEDED = "connect-succeeded", n.CONNECT_FAILED = "connect-failed", n.CONNECT_PARAMETERS_RESOLVE_SUCCESS = "connect-parameters-resolve-success", n.CONNECT_PARAMETERS_RESOLVE_FAILED = "connect-parameters-resolve-failed", n))(C || {});
|
|
1148
|
-
const
|
|
1178
|
+
var C = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.DISCONNECTING = "disconnecting", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n.CONNECT_STARTED = "connect-started", n.CONNECT_SUCCEEDED = "connect-succeeded", n.CONNECT_FAILED = "connect-failed", n.CONNECT_PARAMETERS_RESOLVE_SUCCESS = "connect-parameters-resolve-success", n.CONNECT_PARAMETERS_RESOLVE_FAILED = "connect-parameters-resolve-failed", n.CONNECTED_WITH_CONFIGURATION = "connected-with-configuration", n))(C || {});
|
|
1179
|
+
const ue = [
|
|
1149
1180
|
"connecting",
|
|
1150
1181
|
"connected",
|
|
1151
1182
|
"disconnected",
|
|
@@ -1155,15 +1186,16 @@ const le = [
|
|
|
1155
1186
|
"registrationFailed",
|
|
1156
1187
|
"newMessage",
|
|
1157
1188
|
"sipEvent"
|
|
1158
|
-
],
|
|
1189
|
+
], gt = [
|
|
1159
1190
|
"disconnecting",
|
|
1160
1191
|
"connect-started",
|
|
1161
1192
|
"connect-succeeded",
|
|
1162
1193
|
"connect-failed",
|
|
1163
1194
|
"connect-parameters-resolve-success",
|
|
1164
|
-
"connect-parameters-resolve-failed"
|
|
1165
|
-
|
|
1166
|
-
|
|
1195
|
+
"connect-parameters-resolve-failed",
|
|
1196
|
+
"connected-with-configuration"
|
|
1197
|
+
], ge = [...ue, ...gt], Tt = 3;
|
|
1198
|
+
class St {
|
|
1167
1199
|
cancelableConnectWithRepeatedCalls;
|
|
1168
1200
|
JsSIP;
|
|
1169
1201
|
events;
|
|
@@ -1178,19 +1210,19 @@ class gt {
|
|
|
1178
1210
|
setSipServerUrl;
|
|
1179
1211
|
setSocket;
|
|
1180
1212
|
constructor(e) {
|
|
1181
|
-
this.JsSIP = e.JsSIP, this.events = e.events, this.uaFactory = e.uaFactory, this.stateMachine = e.stateMachine, this.registrationManager = e.registrationManager, this.getUa = e.getUa, this.setUa = e.setUa, this.getConnectionConfiguration = e.getConnectionConfiguration, this.setConnectionConfiguration = e.setConnectionConfiguration, this.updateConnectionConfiguration = e.updateConnectionConfiguration, this.setSipServerUrl = e.setSipServerUrl, this.setSocket = e.setSocket;
|
|
1213
|
+
this.JsSIP = e.JsSIP, this.events = e.events, this.uaFactory = e.uaFactory, this.stateMachine = e.stateMachine, this.registrationManager = e.registrationManager, this.getUa = e.getUa, this.setUa = e.setUa, this.getConnectionConfiguration = e.getConnectionConfiguration, this.setConnectionConfiguration = e.setConnectionConfiguration, this.updateConnectionConfiguration = e.updateConnectionConfiguration, this.setSipServerUrl = e.setSipServerUrl, this.setSocket = e.setSocket, this.proxyEvents();
|
|
1182
1214
|
}
|
|
1183
1215
|
connect = async (e, t) => (this.cancelRequests(), this.connectWithDuplicatedCalls(e, t));
|
|
1184
1216
|
set = async ({ displayName: e }) => new Promise((t, s) => {
|
|
1185
|
-
const
|
|
1186
|
-
if (!
|
|
1217
|
+
const i = this.getUa();
|
|
1218
|
+
if (!i) {
|
|
1187
1219
|
s(new Error("this.ua is not initialized"));
|
|
1188
1220
|
return;
|
|
1189
1221
|
}
|
|
1190
|
-
let
|
|
1222
|
+
let r = !1;
|
|
1191
1223
|
const a = this.getConnectionConfiguration();
|
|
1192
|
-
e !== void 0 && e !== a?.displayName && (
|
|
1193
|
-
const o =
|
|
1224
|
+
e !== void 0 && e !== a?.displayName && (r = i.set("display_name", ae(e)), this.updateConnectionConfiguration("displayName", e));
|
|
1225
|
+
const o = r;
|
|
1194
1226
|
o ? t(o) : s(new Error("nothing changed"));
|
|
1195
1227
|
});
|
|
1196
1228
|
disconnect = async () => {
|
|
@@ -1207,26 +1239,26 @@ class gt {
|
|
|
1207
1239
|
cancelRequests() {
|
|
1208
1240
|
this.cancelConnectWithRepeatedCalls();
|
|
1209
1241
|
}
|
|
1210
|
-
connectWithDuplicatedCalls = async (e, { callLimit: t =
|
|
1211
|
-
const s = async () => this.connectInner(e),
|
|
1212
|
-
const
|
|
1213
|
-
return
|
|
1242
|
+
connectWithDuplicatedCalls = async (e, { callLimit: t = Tt } = {}) => {
|
|
1243
|
+
const s = async () => this.connectInner(e), i = (r) => {
|
|
1244
|
+
const h = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = r != null && !Le(r);
|
|
1245
|
+
return h || d;
|
|
1214
1246
|
};
|
|
1215
|
-
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls =
|
|
1247
|
+
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = te({
|
|
1216
1248
|
targetFunction: s,
|
|
1217
|
-
isComplete:
|
|
1249
|
+
isComplete: i,
|
|
1218
1250
|
callLimit: t,
|
|
1219
1251
|
isRejectAsValid: !0,
|
|
1220
1252
|
isCheckBeforeCall: !1
|
|
1221
|
-
}), this.cancelableConnectWithRepeatedCalls.then((
|
|
1222
|
-
if ("ua" in
|
|
1223
|
-
return
|
|
1224
|
-
throw
|
|
1253
|
+
}), this.cancelableConnectWithRepeatedCalls.then((r) => {
|
|
1254
|
+
if ("ua" in r && r.ua instanceof this.JsSIP.UA)
|
|
1255
|
+
return r;
|
|
1256
|
+
throw r;
|
|
1225
1257
|
});
|
|
1226
1258
|
};
|
|
1227
1259
|
hasEqualConnectionConfiguration(e) {
|
|
1228
|
-
const { configuration: t } = this.uaFactory.createConfiguration(e),
|
|
1229
|
-
return
|
|
1260
|
+
const { configuration: t } = this.uaFactory.createConfiguration(e), i = this.getUa()?.configuration;
|
|
1261
|
+
return i ? i.password === t.password && i.register === t.register && i.uri.toString() === t.uri && i.display_name === t.display_name && i.user_agent === t.user_agent && i.sockets === t.sockets && i.session_timers === t.session_timers && i.register_expires === t.register_expires && i.connection_recovery_min_interval === t.connection_recovery_min_interval && i.connection_recovery_max_interval === t.connection_recovery_max_interval : !1;
|
|
1230
1262
|
}
|
|
1231
1263
|
connectInner = async (e) => this.initUa(e).then(async () => this.start()).then((t) => {
|
|
1232
1264
|
const s = this.getConnectionConfiguration();
|
|
@@ -1241,11 +1273,11 @@ class gt {
|
|
|
1241
1273
|
user: e,
|
|
1242
1274
|
password: t,
|
|
1243
1275
|
sipServerUrl: s,
|
|
1244
|
-
sipWebSocketServerURL:
|
|
1245
|
-
remoteAddress:
|
|
1276
|
+
sipWebSocketServerURL: i,
|
|
1277
|
+
remoteAddress: r,
|
|
1246
1278
|
sessionTimers: a,
|
|
1247
1279
|
registerExpires: o,
|
|
1248
|
-
connectionRecoveryMinInterval:
|
|
1280
|
+
connectionRecoveryMinInterval: h,
|
|
1249
1281
|
connectionRecoveryMaxInterval: d,
|
|
1250
1282
|
userAgent: T,
|
|
1251
1283
|
displayName: S = "",
|
|
@@ -1259,25 +1291,25 @@ class gt {
|
|
|
1259
1291
|
user: e,
|
|
1260
1292
|
password: t
|
|
1261
1293
|
}), this.getUa() && await this.disconnect();
|
|
1262
|
-
const { ua:
|
|
1294
|
+
const { ua: N, helpers: M } = this.uaFactory.createUAWithConfiguration(
|
|
1263
1295
|
{
|
|
1264
1296
|
user: e,
|
|
1265
1297
|
password: t,
|
|
1266
1298
|
sipServerUrl: s,
|
|
1267
|
-
sipWebSocketServerURL:
|
|
1299
|
+
sipWebSocketServerURL: i,
|
|
1268
1300
|
displayName: S,
|
|
1269
1301
|
register: u,
|
|
1270
1302
|
sessionTimers: a,
|
|
1271
1303
|
registerExpires: o,
|
|
1272
|
-
connectionRecoveryMinInterval:
|
|
1304
|
+
connectionRecoveryMinInterval: h,
|
|
1273
1305
|
connectionRecoveryMaxInterval: d,
|
|
1274
1306
|
userAgent: T,
|
|
1275
|
-
remoteAddress:
|
|
1307
|
+
remoteAddress: r,
|
|
1276
1308
|
extraHeaders: E
|
|
1277
1309
|
},
|
|
1278
1310
|
this.events
|
|
1279
1311
|
);
|
|
1280
|
-
return this.setUa(
|
|
1312
|
+
return this.setUa(N), this.setSipServerUrl(M.getSipServerUrl), this.setSocket(M.socket), N;
|
|
1281
1313
|
};
|
|
1282
1314
|
start = async () => new Promise((e, t) => {
|
|
1283
1315
|
const s = this.getUa();
|
|
@@ -1285,40 +1317,49 @@ class gt {
|
|
|
1285
1317
|
t(new Error("this.ua is not initialized"));
|
|
1286
1318
|
return;
|
|
1287
1319
|
}
|
|
1288
|
-
let
|
|
1289
|
-
|
|
1320
|
+
let i;
|
|
1321
|
+
i = ((h, d) => {
|
|
1290
1322
|
if (this.getConnectionConfiguration()?.register === !0)
|
|
1291
|
-
return this.registrationManager.subscribeToStartEvents(
|
|
1323
|
+
return this.registrationManager.subscribeToStartEvents(h, d);
|
|
1292
1324
|
const S = C.CONNECTED, u = [C.DISCONNECTED];
|
|
1293
|
-
return this.events.on(S,
|
|
1325
|
+
return this.events.on(S, h), u.forEach((E) => {
|
|
1294
1326
|
this.events.on(E, d);
|
|
1295
1327
|
}), () => {
|
|
1296
|
-
this.events.off(S,
|
|
1328
|
+
this.events.off(S, h), u.forEach((E) => {
|
|
1297
1329
|
this.events.off(E, d);
|
|
1298
1330
|
});
|
|
1299
1331
|
};
|
|
1300
1332
|
})(() => {
|
|
1301
|
-
|
|
1302
|
-
}, (
|
|
1303
|
-
|
|
1333
|
+
i?.(), e(s);
|
|
1334
|
+
}, (h) => {
|
|
1335
|
+
i?.(), t(h);
|
|
1304
1336
|
}), s.start();
|
|
1305
1337
|
});
|
|
1306
1338
|
cancelConnectWithRepeatedCalls() {
|
|
1307
1339
|
this.cancelableConnectWithRepeatedCalls?.cancel();
|
|
1308
1340
|
}
|
|
1341
|
+
proxyEvents() {
|
|
1342
|
+
this.events.on(C.CONNECTED, () => {
|
|
1343
|
+
const e = this.getConnectionConfiguration(), t = this.getUa();
|
|
1344
|
+
e !== void 0 && t !== void 0 && this.events.trigger(C.CONNECTED_WITH_CONFIGURATION, {
|
|
1345
|
+
...e,
|
|
1346
|
+
ua: t
|
|
1347
|
+
});
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1309
1350
|
}
|
|
1310
|
-
var
|
|
1311
|
-
const
|
|
1351
|
+
var Te = /* @__PURE__ */ ((n) => (n.START_CONNECT = "START_CONNECT", n.START_INIT_UA = "START_INIT_UA", n.UA_CONNECTED = "UA_CONNECTED", n.UA_REGISTERED = "UA_REGISTERED", n.UA_UNREGISTERED = "UA_UNREGISTERED", n.UA_DISCONNECTED = "UA_DISCONNECTED", n.CONNECTION_FAILED = "CONNECTION_FAILED", n.RESET = "RESET", n))(Te || {});
|
|
1352
|
+
const Ct = ye({
|
|
1312
1353
|
types: {
|
|
1313
1354
|
context: {},
|
|
1314
1355
|
events: {}
|
|
1315
1356
|
},
|
|
1316
1357
|
actions: {
|
|
1317
1358
|
logTransition: (n, e) => {
|
|
1318
|
-
|
|
1359
|
+
c(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
1319
1360
|
},
|
|
1320
1361
|
logStateChange: (n, e) => {
|
|
1321
|
-
|
|
1362
|
+
c("ConnectionStateMachine state changed", e.state);
|
|
1322
1363
|
}
|
|
1323
1364
|
}
|
|
1324
1365
|
}).createMachine({
|
|
@@ -1622,17 +1663,17 @@ const Tt = Oe({
|
|
|
1622
1663
|
}
|
|
1623
1664
|
}
|
|
1624
1665
|
});
|
|
1625
|
-
class
|
|
1666
|
+
class Et {
|
|
1626
1667
|
actor;
|
|
1627
1668
|
stateChangeListeners = /* @__PURE__ */ new Set();
|
|
1628
1669
|
events;
|
|
1629
1670
|
unsubscribeFromEvents;
|
|
1630
1671
|
actorSubscription;
|
|
1631
1672
|
constructor(e) {
|
|
1632
|
-
this.events = e, this.actor =
|
|
1673
|
+
this.events = e, this.actor = De(Ct), this.actorSubscription = this.actor.subscribe((t) => {
|
|
1633
1674
|
const s = t.value;
|
|
1634
|
-
this.stateChangeListeners.forEach((
|
|
1635
|
-
|
|
1675
|
+
this.stateChangeListeners.forEach((i) => {
|
|
1676
|
+
i(s);
|
|
1636
1677
|
});
|
|
1637
1678
|
}), this.actor.start(), this.subscribeToEvents();
|
|
1638
1679
|
}
|
|
@@ -1715,7 +1756,7 @@ class St {
|
|
|
1715
1756
|
return this.actor.getSnapshot().can({ type: e });
|
|
1716
1757
|
}
|
|
1717
1758
|
getValidEvents() {
|
|
1718
|
-
return Object.values(
|
|
1759
|
+
return Object.values(Te).filter((e) => this.canTransition(e));
|
|
1719
1760
|
}
|
|
1720
1761
|
hasState(e) {
|
|
1721
1762
|
return this.actor.getSnapshot().matches(e);
|
|
@@ -1723,7 +1764,7 @@ class St {
|
|
|
1723
1764
|
sendEvent(e) {
|
|
1724
1765
|
const t = this.actor.getSnapshot(), s = { type: e };
|
|
1725
1766
|
if (!t.can(s)) {
|
|
1726
|
-
|
|
1767
|
+
c(
|
|
1727
1768
|
`Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
|
|
1728
1769
|
);
|
|
1729
1770
|
return;
|
|
@@ -1784,7 +1825,7 @@ class St {
|
|
|
1784
1825
|
};
|
|
1785
1826
|
}
|
|
1786
1827
|
}
|
|
1787
|
-
class
|
|
1828
|
+
class At {
|
|
1788
1829
|
events;
|
|
1789
1830
|
getUaProtected;
|
|
1790
1831
|
constructor(e) {
|
|
@@ -1806,22 +1847,22 @@ class Ct {
|
|
|
1806
1847
|
try {
|
|
1807
1848
|
await this.unregister();
|
|
1808
1849
|
} catch (e) {
|
|
1809
|
-
|
|
1850
|
+
c("tryRegister", e);
|
|
1810
1851
|
}
|
|
1811
1852
|
return this.register();
|
|
1812
1853
|
}
|
|
1813
1854
|
subscribeToStartEvents(e, t) {
|
|
1814
|
-
const s = C.REGISTERED,
|
|
1815
|
-
return this.events.on(s, e),
|
|
1816
|
-
this.events.on(
|
|
1855
|
+
const s = C.REGISTERED, i = [C.REGISTRATION_FAILED, C.DISCONNECTED];
|
|
1856
|
+
return this.events.on(s, e), i.forEach((r) => {
|
|
1857
|
+
this.events.on(r, t);
|
|
1817
1858
|
}), () => {
|
|
1818
|
-
this.events.off(s, e),
|
|
1819
|
-
this.events.off(
|
|
1859
|
+
this.events.off(s, e), i.forEach((r) => {
|
|
1860
|
+
this.events.off(r, t);
|
|
1820
1861
|
});
|
|
1821
1862
|
};
|
|
1822
1863
|
}
|
|
1823
1864
|
}
|
|
1824
|
-
class
|
|
1865
|
+
class Rt {
|
|
1825
1866
|
uaFactory;
|
|
1826
1867
|
getUaProtected;
|
|
1827
1868
|
constructor(e) {
|
|
@@ -1831,14 +1872,14 @@ class Et {
|
|
|
1831
1872
|
* Отправляет SIP OPTIONS запрос к указанному адресу
|
|
1832
1873
|
*/
|
|
1833
1874
|
async sendOptions(e, t, s) {
|
|
1834
|
-
const
|
|
1835
|
-
return new Promise((
|
|
1875
|
+
const i = this.getUaProtected();
|
|
1876
|
+
return new Promise((r, a) => {
|
|
1836
1877
|
try {
|
|
1837
|
-
|
|
1878
|
+
i.sendOptions(e, t, {
|
|
1838
1879
|
extraHeaders: s,
|
|
1839
1880
|
eventHandlers: {
|
|
1840
1881
|
succeeded: () => {
|
|
1841
|
-
|
|
1882
|
+
r();
|
|
1842
1883
|
},
|
|
1843
1884
|
failed: a
|
|
1844
1885
|
}
|
|
@@ -1852,8 +1893,8 @@ class Et {
|
|
|
1852
1893
|
* Отправляет SIP OPTIONS запрос к собственному URI (ping)
|
|
1853
1894
|
*/
|
|
1854
1895
|
async ping(e, t) {
|
|
1855
|
-
const
|
|
1856
|
-
return this.sendOptions(
|
|
1896
|
+
const i = this.getUaProtected().configuration.uri;
|
|
1897
|
+
return this.sendOptions(i, e, t);
|
|
1857
1898
|
}
|
|
1858
1899
|
/**
|
|
1859
1900
|
* Проверяет доступность телефонии, создавая временное соединение
|
|
@@ -1862,19 +1903,19 @@ class Et {
|
|
|
1862
1903
|
userAgent: e,
|
|
1863
1904
|
displayName: t,
|
|
1864
1905
|
sipServerUrl: s,
|
|
1865
|
-
sipWebSocketServerURL:
|
|
1866
|
-
remoteAddress:
|
|
1906
|
+
sipWebSocketServerURL: i,
|
|
1907
|
+
remoteAddress: r,
|
|
1867
1908
|
extraHeaders: a
|
|
1868
1909
|
}) {
|
|
1869
|
-
return new Promise((o,
|
|
1910
|
+
return new Promise((o, h) => {
|
|
1870
1911
|
const { configuration: d } = this.uaFactory.createConfiguration({
|
|
1871
|
-
sipWebSocketServerURL:
|
|
1912
|
+
sipWebSocketServerURL: i,
|
|
1872
1913
|
displayName: t,
|
|
1873
1914
|
userAgent: e,
|
|
1874
1915
|
sipServerUrl: s
|
|
1875
|
-
}), T = this.uaFactory.createUA({ ...d, remoteAddress:
|
|
1916
|
+
}), T = this.uaFactory.createUA({ ...d, remoteAddress: r, extraHeaders: a }), S = () => {
|
|
1876
1917
|
const E = new Error("Telephony is not available");
|
|
1877
|
-
|
|
1918
|
+
h(E);
|
|
1878
1919
|
};
|
|
1879
1920
|
T.once(C.DISCONNECTED, S);
|
|
1880
1921
|
const u = () => {
|
|
@@ -1886,7 +1927,7 @@ class Et {
|
|
|
1886
1927
|
});
|
|
1887
1928
|
}
|
|
1888
1929
|
}
|
|
1889
|
-
const
|
|
1930
|
+
const Nt = (n) => {
|
|
1890
1931
|
const e = [];
|
|
1891
1932
|
return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
|
|
1892
1933
|
};
|
|
@@ -1902,12 +1943,12 @@ class y {
|
|
|
1902
1943
|
register: e,
|
|
1903
1944
|
password: t,
|
|
1904
1945
|
user: s,
|
|
1905
|
-
sipServerUrl:
|
|
1906
|
-
sipWebSocketServerURL:
|
|
1946
|
+
sipServerUrl: i,
|
|
1947
|
+
sipWebSocketServerURL: r
|
|
1907
1948
|
}) {
|
|
1908
|
-
if (!r)
|
|
1909
|
-
throw new Error("sipServerUrl is required");
|
|
1910
1949
|
if (!i)
|
|
1950
|
+
throw new Error("sipServerUrl is required");
|
|
1951
|
+
if (!r)
|
|
1911
1952
|
throw new Error("sipWebSocketServerURL is required");
|
|
1912
1953
|
if (e && (t === void 0 || t === ""))
|
|
1913
1954
|
throw new Error("password is required for authorized connection");
|
|
@@ -1915,21 +1956,21 @@ class y {
|
|
|
1915
1956
|
throw new Error("user is required for authorized connection");
|
|
1916
1957
|
}
|
|
1917
1958
|
static resolveAuthorizationUser(e, t) {
|
|
1918
|
-
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${
|
|
1959
|
+
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${We()}`;
|
|
1919
1960
|
}
|
|
1920
1961
|
static buildExtraHeaders(e, t) {
|
|
1921
|
-
const s = e !== void 0 && e !== "" ?
|
|
1962
|
+
const s = e !== void 0 && e !== "" ? Nt(e) : [];
|
|
1922
1963
|
return t === void 0 ? s : [...s, ...t];
|
|
1923
1964
|
}
|
|
1924
1965
|
createConfiguration({
|
|
1925
1966
|
user: e,
|
|
1926
1967
|
password: t,
|
|
1927
1968
|
sipWebSocketServerURL: s,
|
|
1928
|
-
displayName:
|
|
1929
|
-
sipServerUrl:
|
|
1969
|
+
displayName: i = "",
|
|
1970
|
+
sipServerUrl: r,
|
|
1930
1971
|
register: a = !1,
|
|
1931
1972
|
sessionTimers: o = !1,
|
|
1932
|
-
registerExpires:
|
|
1973
|
+
registerExpires: h = 300,
|
|
1933
1974
|
// 5 minutes in sec
|
|
1934
1975
|
connectionRecoveryMinInterval: d = 2,
|
|
1935
1976
|
connectionRecoveryMaxInterval: T = 6,
|
|
@@ -1939,51 +1980,51 @@ class y {
|
|
|
1939
1980
|
register: a,
|
|
1940
1981
|
password: t,
|
|
1941
1982
|
user: e,
|
|
1942
|
-
sipServerUrl:
|
|
1983
|
+
sipServerUrl: r,
|
|
1943
1984
|
sipWebSocketServerURL: s
|
|
1944
1985
|
});
|
|
1945
|
-
const u = y.resolveAuthorizationUser(a, e), E = Ve(
|
|
1986
|
+
const u = y.resolveAuthorizationUser(a, e), E = Ve(r), I = E(u), N = new this.JsSIP.WebSocketInterface(s);
|
|
1946
1987
|
return {
|
|
1947
1988
|
configuration: {
|
|
1948
1989
|
password: t,
|
|
1949
1990
|
register: a,
|
|
1950
|
-
uri:
|
|
1951
|
-
display_name:
|
|
1991
|
+
uri: I,
|
|
1992
|
+
display_name: ae(i),
|
|
1952
1993
|
user_agent: S,
|
|
1953
1994
|
sdpSemantics: "unified-plan",
|
|
1954
|
-
sockets: [
|
|
1995
|
+
sockets: [N],
|
|
1955
1996
|
session_timers: o,
|
|
1956
|
-
register_expires:
|
|
1997
|
+
register_expires: h,
|
|
1957
1998
|
connection_recovery_min_interval: d,
|
|
1958
1999
|
connection_recovery_max_interval: T
|
|
1959
2000
|
},
|
|
1960
2001
|
helpers: {
|
|
1961
|
-
socket:
|
|
2002
|
+
socket: N,
|
|
1962
2003
|
getSipServerUrl: E
|
|
1963
2004
|
}
|
|
1964
2005
|
};
|
|
1965
2006
|
}
|
|
1966
2007
|
createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
|
|
1967
|
-
const
|
|
1968
|
-
return
|
|
2008
|
+
const i = new this.JsSIP.UA(s), r = y.buildExtraHeaders(e, t);
|
|
2009
|
+
return r.length > 0 && i.registrator().setExtraHeaders(r), i;
|
|
1969
2010
|
}
|
|
1970
2011
|
/**
|
|
1971
2012
|
* Создает UA с полным жизненным циклом - конфигурация + создание + настройка событий
|
|
1972
2013
|
*/
|
|
1973
2014
|
createUAWithConfiguration(e, t) {
|
|
1974
|
-
const { configuration: s, helpers:
|
|
2015
|
+
const { configuration: s, helpers: i } = this.createConfiguration(e), r = this.createUA({
|
|
1975
2016
|
...s,
|
|
1976
2017
|
remoteAddress: e.remoteAddress,
|
|
1977
2018
|
extraHeaders: e.extraHeaders
|
|
1978
2019
|
});
|
|
1979
2020
|
return t.eachTriggers((a, o) => {
|
|
1980
|
-
const
|
|
1981
|
-
|
|
1982
|
-
}), { ua:
|
|
2021
|
+
const h = ue.find((d) => d === o);
|
|
2022
|
+
h && r.on(h, a);
|
|
2023
|
+
}), { ua: r, helpers: i };
|
|
1983
2024
|
}
|
|
1984
2025
|
}
|
|
1985
|
-
const
|
|
1986
|
-
class
|
|
2026
|
+
const Se = "Not ready for connection", mt = (n) => n instanceof Error && n.message === Se, It = () => new Error(Se), pt = async (n) => typeof n == "function" ? n() : n;
|
|
2027
|
+
class _t {
|
|
1987
2028
|
events;
|
|
1988
2029
|
ua;
|
|
1989
2030
|
socket;
|
|
@@ -1995,15 +2036,15 @@ class pt {
|
|
|
1995
2036
|
configurationManager;
|
|
1996
2037
|
JsSIP;
|
|
1997
2038
|
constructor({ JsSIP: e }) {
|
|
1998
|
-
this.JsSIP = e, this.events = new
|
|
2039
|
+
this.JsSIP = e, this.events = new w(ge), this.uaFactory = new y(e), this.registrationManager = new At({
|
|
1999
2040
|
events: this.events,
|
|
2000
2041
|
getUaProtected: this.getUaProtected
|
|
2001
|
-
}), this.stateMachine = new
|
|
2042
|
+
}), this.stateMachine = new Et(this.events), this.configurationManager = new ut({
|
|
2002
2043
|
getUa: this.getUa
|
|
2003
|
-
}), this.sipOperations = new
|
|
2044
|
+
}), this.sipOperations = new Rt({
|
|
2004
2045
|
uaFactory: this.uaFactory,
|
|
2005
2046
|
getUaProtected: this.getUaProtected
|
|
2006
|
-
}), this.connectionFlow = new
|
|
2047
|
+
}), this.connectionFlow = new St({
|
|
2007
2048
|
JsSIP: this.JsSIP,
|
|
2008
2049
|
events: this.events,
|
|
2009
2050
|
uaFactory: this.uaFactory,
|
|
@@ -2056,7 +2097,7 @@ class pt {
|
|
|
2056
2097
|
return this.configurationManager.isRegister();
|
|
2057
2098
|
}
|
|
2058
2099
|
connect = async (e, t) => this.disconnect().catch((s) => {
|
|
2059
|
-
|
|
2100
|
+
c("connect: disconnect error", s);
|
|
2060
2101
|
}).then(async () => this.connectWithProcessError(e, t));
|
|
2061
2102
|
set = async ({ displayName: e }) => this.connectionFlow.set({ displayName: e });
|
|
2062
2103
|
disconnect = async () => {
|
|
@@ -2105,28 +2146,28 @@ class pt {
|
|
|
2105
2146
|
getUa = () => this.ua;
|
|
2106
2147
|
connectWithProcessError = async (e, t) => {
|
|
2107
2148
|
if (!(t?.hasReadyForConnection?.() ?? !0))
|
|
2108
|
-
throw
|
|
2109
|
-
return this.processConnect(e, t).catch(async (
|
|
2110
|
-
const
|
|
2149
|
+
throw It();
|
|
2150
|
+
return this.processConnect(e, t).catch(async (i) => {
|
|
2151
|
+
const r = i;
|
|
2111
2152
|
return this.disconnect().then(() => {
|
|
2112
|
-
throw
|
|
2153
|
+
throw r;
|
|
2113
2154
|
}).catch(() => {
|
|
2114
|
-
throw
|
|
2155
|
+
throw r;
|
|
2115
2156
|
});
|
|
2116
2157
|
});
|
|
2117
2158
|
};
|
|
2118
|
-
processConnect = async (e, t) => (this.events.trigger(C.CONNECT_STARTED, {}),
|
|
2159
|
+
processConnect = async (e, t) => (this.events.trigger(C.CONNECT_STARTED, {}), pt(e).then((s) => (this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
|
|
2119
2160
|
throw this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_FAILED, s), s;
|
|
2120
2161
|
}).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(C.CONNECT_SUCCEEDED, {
|
|
2121
2162
|
...s
|
|
2122
2163
|
}), s)).catch((s) => {
|
|
2123
|
-
const
|
|
2124
|
-
throw this.events.trigger(C.CONNECT_FAILED,
|
|
2164
|
+
const i = s ?? new Error("Failed to connect to server");
|
|
2165
|
+
throw this.events.trigger(C.CONNECT_FAILED, i), i;
|
|
2125
2166
|
}));
|
|
2126
2167
|
}
|
|
2127
|
-
class
|
|
2168
|
+
class Mt {
|
|
2128
2169
|
connectionManager;
|
|
2129
|
-
stackPromises =
|
|
2170
|
+
stackPromises = ne({
|
|
2130
2171
|
noRunIsNotActual: !0
|
|
2131
2172
|
});
|
|
2132
2173
|
constructor({ connectionManager: e }) {
|
|
@@ -2138,11 +2179,11 @@ class mt {
|
|
|
2138
2179
|
this.stackPromises.stop();
|
|
2139
2180
|
}
|
|
2140
2181
|
}
|
|
2141
|
-
const z = 0,
|
|
2142
|
-
class
|
|
2182
|
+
const z = 0, vt = 30;
|
|
2183
|
+
class ft {
|
|
2143
2184
|
countInner = z;
|
|
2144
2185
|
initialCount = z;
|
|
2145
|
-
limitInner =
|
|
2186
|
+
limitInner = vt;
|
|
2146
2187
|
isInProgress = !1;
|
|
2147
2188
|
onStatusChange;
|
|
2148
2189
|
constructor({
|
|
@@ -2175,7 +2216,7 @@ class Mt {
|
|
|
2175
2216
|
this.countInner = this.initialCount, this.finishAttempt();
|
|
2176
2217
|
}
|
|
2177
2218
|
}
|
|
2178
|
-
class
|
|
2219
|
+
class Pt {
|
|
2179
2220
|
connectionManager;
|
|
2180
2221
|
interval;
|
|
2181
2222
|
checkTelephonyByTimeout = void 0;
|
|
@@ -2191,14 +2232,14 @@ class ft {
|
|
|
2191
2232
|
onSuccessRequest: t,
|
|
2192
2233
|
onFailRequest: s
|
|
2193
2234
|
}) {
|
|
2194
|
-
this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout =
|
|
2235
|
+
this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout = Me({
|
|
2195
2236
|
isDontStopOnFail: !0,
|
|
2196
2237
|
requestInterval: this.interval,
|
|
2197
2238
|
request: async () => {
|
|
2198
2239
|
if (!this.cancelableBeforeRequest)
|
|
2199
2240
|
throw new Error("cancelableBeforeRequest is not defined");
|
|
2200
|
-
const
|
|
2201
|
-
return this.connectionManager.checkTelephony(
|
|
2241
|
+
const i = await this.cancelableBeforeRequest.request();
|
|
2242
|
+
return this.connectionManager.checkTelephony(i);
|
|
2202
2243
|
}
|
|
2203
2244
|
}), this.checkTelephonyByTimeout.start(void 0, {
|
|
2204
2245
|
onFailRequest: s,
|
|
@@ -2211,8 +2252,8 @@ class ft {
|
|
|
2211
2252
|
this.checkTelephonyByTimeout?.stop(), this.checkTelephonyByTimeout = void 0, this.cancelableBeforeRequest?.cancelRequest(), this.cancelableBeforeRequest = void 0;
|
|
2212
2253
|
}
|
|
2213
2254
|
}
|
|
2214
|
-
var
|
|
2215
|
-
const
|
|
2255
|
+
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))(_ || {});
|
|
2256
|
+
const Ce = [
|
|
2216
2257
|
"before-attempt",
|
|
2217
2258
|
"success",
|
|
2218
2259
|
"failed-all-attempts",
|
|
@@ -2220,28 +2261,28 @@ const Se = [
|
|
|
2220
2261
|
"changed-attempt-status",
|
|
2221
2262
|
"stop-attempts-by-error",
|
|
2222
2263
|
"limit-reached-attempts"
|
|
2223
|
-
],
|
|
2224
|
-
class
|
|
2264
|
+
], Ot = 15e3, yt = 2;
|
|
2265
|
+
class Dt {
|
|
2225
2266
|
connectionManager;
|
|
2226
2267
|
pingServerByTimeoutWithFailCalls;
|
|
2227
2268
|
constructor({ connectionManager: e }) {
|
|
2228
|
-
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls =
|
|
2269
|
+
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = ve(yt, {
|
|
2229
2270
|
whenPossibleRequest: async () => {
|
|
2230
2271
|
},
|
|
2231
|
-
requestInterval:
|
|
2232
|
-
request: async () => (
|
|
2233
|
-
|
|
2272
|
+
requestInterval: Ot,
|
|
2273
|
+
request: async () => (c("ping"), this.connectionManager.ping().then(() => {
|
|
2274
|
+
c("ping success");
|
|
2234
2275
|
}))
|
|
2235
2276
|
});
|
|
2236
2277
|
}
|
|
2237
2278
|
start({ onFailRequest: e }) {
|
|
2238
|
-
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(
|
|
2279
|
+
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(c);
|
|
2239
2280
|
}
|
|
2240
2281
|
stop() {
|
|
2241
2282
|
this.pingServerByTimeoutWithFailCalls.stop();
|
|
2242
2283
|
}
|
|
2243
2284
|
}
|
|
2244
|
-
class
|
|
2285
|
+
class bt {
|
|
2245
2286
|
callManager;
|
|
2246
2287
|
pingServerRequester;
|
|
2247
2288
|
disposeCallStatusChange;
|
|
@@ -2249,17 +2290,17 @@ class yt {
|
|
|
2249
2290
|
connectionManager: e,
|
|
2250
2291
|
callManager: t
|
|
2251
2292
|
}) {
|
|
2252
|
-
this.callManager = t, this.pingServerRequester = new
|
|
2293
|
+
this.callManager = t, this.pingServerRequester = new Dt({
|
|
2253
2294
|
connectionManager: e
|
|
2254
2295
|
});
|
|
2255
2296
|
}
|
|
2256
2297
|
start({ onFailRequest: e }) {
|
|
2257
|
-
|
|
2298
|
+
c("start"), this.disposeCallStatusChange = this.callManager.on("call-status-changed", () => {
|
|
2258
2299
|
this.handleCallStatusChange({ onFailRequest: e });
|
|
2259
2300
|
}), this.handleCallStatusChange({ onFailRequest: e });
|
|
2260
2301
|
}
|
|
2261
2302
|
stop() {
|
|
2262
|
-
|
|
2303
|
+
c("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
|
|
2263
2304
|
}
|
|
2264
2305
|
unsubscribeCallStatusChange() {
|
|
2265
2306
|
this.disposeCallStatusChange?.(), this.disposeCallStatusChange = void 0;
|
|
@@ -2268,7 +2309,7 @@ class yt {
|
|
|
2268
2309
|
this.callManager.isCallActive ? this.pingServerRequester.stop() : this.pingServerRequester.start({ onFailRequest: e });
|
|
2269
2310
|
}
|
|
2270
2311
|
}
|
|
2271
|
-
class
|
|
2312
|
+
class wt {
|
|
2272
2313
|
connectionManager;
|
|
2273
2314
|
callManager;
|
|
2274
2315
|
isRegistrationFailed = !1;
|
|
@@ -2302,9 +2343,12 @@ class Dt {
|
|
|
2302
2343
|
this.isRegistrationFailed = !1;
|
|
2303
2344
|
}
|
|
2304
2345
|
}
|
|
2305
|
-
const
|
|
2306
|
-
|
|
2307
|
-
|
|
2346
|
+
const Ut = 3e3, Lt = 15e3, X = {
|
|
2347
|
+
LIMIT_REACHED: "Limit reached",
|
|
2348
|
+
FAILED_TO_RECONNECT: "Failed to reconnect"
|
|
2349
|
+
}, Bt = async () => {
|
|
2350
|
+
}, Ft = (n) => !0;
|
|
2351
|
+
class kt {
|
|
2308
2352
|
events;
|
|
2309
2353
|
connectionManager;
|
|
2310
2354
|
connectionQueueManager;
|
|
@@ -2322,30 +2366,28 @@ class Bt {
|
|
|
2322
2366
|
connectionQueueManager: e,
|
|
2323
2367
|
connectionManager: t,
|
|
2324
2368
|
callManager: s
|
|
2325
|
-
},
|
|
2326
|
-
const
|
|
2327
|
-
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry =
|
|
2369
|
+
}, i) {
|
|
2370
|
+
const r = i?.onBeforeRetry ?? Bt, a = i?.canRetryOnError ?? Ft;
|
|
2371
|
+
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = new w(Ce), this.checkTelephonyRequester = new Pt({
|
|
2328
2372
|
connectionManager: t,
|
|
2329
|
-
interval:
|
|
2330
|
-
}), this.pingServerIfNotActiveCallRequester = new
|
|
2373
|
+
interval: i?.checkTelephonyRequestInterval ?? Lt
|
|
2374
|
+
}), this.pingServerIfNotActiveCallRequester = new bt({
|
|
2331
2375
|
connectionManager: t,
|
|
2332
2376
|
callManager: s
|
|
2333
|
-
}), this.registrationFailedOutOfCallSubscriber = new
|
|
2377
|
+
}), this.registrationFailedOutOfCallSubscriber = new wt({
|
|
2334
2378
|
connectionManager: t,
|
|
2335
2379
|
callManager: s
|
|
2336
|
-
}), this.attemptsState = new
|
|
2380
|
+
}), this.attemptsState = new ft({
|
|
2337
2381
|
onStatusChange: this.emitStatusChange
|
|
2338
|
-
}), this.cancelableRequestBeforeRetry = new G(
|
|
2339
|
-
|
|
2382
|
+
}), this.cancelableRequestBeforeRetry = new G(r), this.delayBetweenAttempts = new fe(
|
|
2383
|
+
i?.timeoutBetweenAttempts ?? Ut
|
|
2340
2384
|
);
|
|
2341
2385
|
}
|
|
2342
2386
|
start(e) {
|
|
2343
|
-
|
|
2344
|
-
h("auto connector failed to connect:", t);
|
|
2345
|
-
});
|
|
2387
|
+
c("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToHardwareTriggers(e);
|
|
2346
2388
|
}
|
|
2347
2389
|
stop() {
|
|
2348
|
-
|
|
2390
|
+
c("auto connector stop"), this.unsubscribeFromHardwareTriggers(), this.stopConnectionFlow();
|
|
2349
2391
|
}
|
|
2350
2392
|
on(e, t) {
|
|
2351
2393
|
return this.events.on(e, t);
|
|
@@ -2362,126 +2404,131 @@ class Bt {
|
|
|
2362
2404
|
off(e, t) {
|
|
2363
2405
|
this.events.off(e, t);
|
|
2364
2406
|
}
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2407
|
+
restartConnectionAttempts(e) {
|
|
2408
|
+
c("auto connector restart connection attempts"), this.stopConnectionFlow(), this.attemptConnection(e).catch((t) => {
|
|
2409
|
+
c("auto connector failed to connect:", t);
|
|
2410
|
+
});
|
|
2411
|
+
}
|
|
2412
|
+
stopConnectionFlow() {
|
|
2413
|
+
c("stopConnectionFlow"), this.stopAttempts(), this.stopConnectTriggers(), this.connectionQueueManager.disconnect().catch((e) => {
|
|
2414
|
+
c("auto connector disconnect: error", e);
|
|
2368
2415
|
});
|
|
2369
2416
|
}
|
|
2370
2417
|
stopAttempts() {
|
|
2371
2418
|
this.attemptsState.isAttemptInProgress && this.connectionQueueManager.stop(), this.delayBetweenAttempts.cancelRequest(), this.cancelableRequestBeforeRetry.cancelRequest(), this.attemptsState.reset();
|
|
2372
2419
|
}
|
|
2373
2420
|
stopConnectTriggers() {
|
|
2374
|
-
|
|
2421
|
+
c("stopConnectTriggers"), this.stopPingRequester(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe();
|
|
2375
2422
|
}
|
|
2376
|
-
|
|
2377
|
-
|
|
2423
|
+
startCheckTelephony(e) {
|
|
2424
|
+
c("startCheckTelephony"), this.checkTelephonyRequester.start({
|
|
2378
2425
|
onBeforeRequest: async () => (await this.onBeforeRetry(), e.getParameters()),
|
|
2379
2426
|
onSuccessRequest: () => {
|
|
2380
|
-
|
|
2427
|
+
c("startCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
|
|
2381
2428
|
},
|
|
2382
2429
|
onFailRequest: (t) => {
|
|
2383
|
-
|
|
2430
|
+
c("startCheckTelephony: onFailRequest", t.message);
|
|
2384
2431
|
}
|
|
2385
2432
|
});
|
|
2386
2433
|
}
|
|
2387
|
-
async
|
|
2388
|
-
if (
|
|
2389
|
-
|
|
2434
|
+
async attemptConnection(e) {
|
|
2435
|
+
if (c("attemptConnection: attempts.count", this.attemptsState.count), this.events.trigger(_.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
|
|
2436
|
+
c("attemptConnection: limit reached"), this.handleLimitReached(e);
|
|
2390
2437
|
return;
|
|
2391
2438
|
}
|
|
2392
|
-
return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.
|
|
2439
|
+
return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.executeConnectionAttempt(e);
|
|
2393
2440
|
}
|
|
2394
|
-
async
|
|
2441
|
+
async executeConnectionAttempt(e) {
|
|
2395
2442
|
try {
|
|
2396
|
-
await this.connectionQueueManager.connect(e.getParameters, e.options),
|
|
2443
|
+
await this.connectionQueueManager.connect(e.getParameters, e.options), c("executeConnectionAttempt: success"), this.handleSucceededAttempt(e);
|
|
2397
2444
|
} catch (t) {
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
}
|
|
2410
|
-
h("processConnect: error", t), this.reconnect(e);
|
|
2445
|
+
this.handleConnectionError(t, e);
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
handleConnectionError(e, t) {
|
|
2449
|
+
if (mt(e)) {
|
|
2450
|
+
this.attemptsState.finishAttempt(), this.events.trigger(_.STOP_ATTEMPTS_BY_ERROR, e);
|
|
2451
|
+
return;
|
|
2452
|
+
}
|
|
2453
|
+
if (!this.canRetryOnError(e)) {
|
|
2454
|
+
c("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(_.STOP_ATTEMPTS_BY_ERROR, e);
|
|
2455
|
+
return;
|
|
2411
2456
|
}
|
|
2457
|
+
if (be(e)) {
|
|
2458
|
+
c("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(_.CANCELLED_ATTEMPTS, e);
|
|
2459
|
+
return;
|
|
2460
|
+
}
|
|
2461
|
+
c("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
|
|
2412
2462
|
}
|
|
2413
2463
|
handleLimitReached(e) {
|
|
2414
|
-
this.attemptsState.finishAttempt(), this.events.trigger(
|
|
2464
|
+
this.attemptsState.finishAttempt(), this.events.trigger(_.LIMIT_REACHED_ATTEMPTS, new Error(X.LIMIT_REACHED)), this.startCheckTelephony(e);
|
|
2415
2465
|
}
|
|
2416
2466
|
handleSucceededAttempt(e) {
|
|
2417
|
-
|
|
2467
|
+
c("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(_.SUCCESS);
|
|
2418
2468
|
}
|
|
2419
2469
|
subscribeToConnectTriggers(e) {
|
|
2420
|
-
this.
|
|
2421
|
-
|
|
2422
|
-
h("resumeFromSleepModeSubscriber onResume"), this.restartPingServerIfNotActiveCallRequester(e);
|
|
2423
|
-
}
|
|
2424
|
-
}), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
|
|
2425
|
-
h("registrationFailedOutOfCallListener callback"), this.start(e);
|
|
2470
|
+
this.startPingRequester(e), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
|
|
2471
|
+
c("registrationFailedOutOfCallListener callback"), this.restartConnectionAttempts(e);
|
|
2426
2472
|
});
|
|
2427
2473
|
}
|
|
2428
|
-
|
|
2429
|
-
this.
|
|
2474
|
+
subscribeToHardwareTriggers(e) {
|
|
2475
|
+
this.unsubscribeFromHardwareTriggers(), c("subscribeToHardwareTriggers"), this.networkInterfacesSubscriber?.subscribe({
|
|
2430
2476
|
onChange: () => {
|
|
2431
|
-
|
|
2477
|
+
c("networkInterfacesSubscriber onChange"), this.restartConnectionAttempts(e);
|
|
2432
2478
|
},
|
|
2433
2479
|
onUnavailable: () => {
|
|
2434
|
-
|
|
2480
|
+
c("networkInterfacesSubscriber onUnavailable"), this.stopConnectionFlow();
|
|
2481
|
+
}
|
|
2482
|
+
}), this.resumeFromSleepModeSubscriber?.subscribe({
|
|
2483
|
+
onResume: () => {
|
|
2484
|
+
c("resumeFromSleepModeSubscriber onResume"), this.restartConnectionAttempts(e);
|
|
2435
2485
|
}
|
|
2436
2486
|
});
|
|
2437
2487
|
}
|
|
2438
|
-
|
|
2439
|
-
this.networkInterfacesSubscriber?.unsubscribe();
|
|
2488
|
+
unsubscribeFromHardwareTriggers() {
|
|
2489
|
+
c("unsubscribeFromHardwareTriggers"), this.networkInterfacesSubscriber?.unsubscribe(), this.resumeFromSleepModeSubscriber?.unsubscribe();
|
|
2440
2490
|
}
|
|
2441
|
-
|
|
2442
|
-
this.stopPingServerIfNotActiveCallRequester(), this.startPingServerIfNotActiveCallRequester(e);
|
|
2443
|
-
}
|
|
2444
|
-
stopPingServerIfNotActiveCallRequester() {
|
|
2491
|
+
stopPingRequester() {
|
|
2445
2492
|
this.pingServerIfNotActiveCallRequester.stop();
|
|
2446
2493
|
}
|
|
2447
|
-
|
|
2494
|
+
startPingRequester(e) {
|
|
2448
2495
|
this.pingServerIfNotActiveCallRequester.start({
|
|
2449
2496
|
onFailRequest: () => {
|
|
2450
|
-
|
|
2497
|
+
c("pingRequester: onFailRequest"), this.restartConnectionAttempts(e);
|
|
2451
2498
|
}
|
|
2452
2499
|
});
|
|
2453
2500
|
}
|
|
2454
2501
|
connectIfDisconnected(e) {
|
|
2455
|
-
const t = this.
|
|
2456
|
-
|
|
2502
|
+
const t = this.isConnectionUnavailable();
|
|
2503
|
+
c("connectIfDisconnected: isUnavailable", t), t ? this.restartConnectionAttempts(e) : (this.stopConnectTriggers(), this.events.trigger(_.SUCCESS));
|
|
2457
2504
|
}
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
const s = t instanceof Error ? t : new Error(
|
|
2461
|
-
this.attemptsState.finishAttempt(),
|
|
2505
|
+
scheduleReconnect(e) {
|
|
2506
|
+
c("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (c("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (c("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
|
|
2507
|
+
const s = t instanceof Error ? t : new Error(X.FAILED_TO_RECONNECT);
|
|
2508
|
+
this.attemptsState.finishAttempt(), _e(t) || Pe(t) ? this.events.trigger(_.CANCELLED_ATTEMPTS, s) : this.events.trigger(_.FAILED_ALL_ATTEMPTS, s), c("scheduleReconnect: error", t);
|
|
2462
2509
|
});
|
|
2463
2510
|
}
|
|
2464
|
-
|
|
2511
|
+
isConnectionUnavailable() {
|
|
2465
2512
|
const { isFailed: e, isDisconnected: t, isIdle: s } = this.connectionManager;
|
|
2466
2513
|
return e || t || s;
|
|
2467
2514
|
}
|
|
2468
2515
|
emitStatusChange = ({ isInProgress: e }) => {
|
|
2469
|
-
this.events.trigger(
|
|
2516
|
+
this.events.trigger(_.CHANGED_ATTEMPT_STATUS, { isInProgress: e });
|
|
2470
2517
|
};
|
|
2471
2518
|
}
|
|
2472
|
-
var
|
|
2473
|
-
const
|
|
2519
|
+
var b = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(b || {});
|
|
2520
|
+
const Ee = [
|
|
2474
2521
|
"incomingCall",
|
|
2475
2522
|
"declinedIncomingCall",
|
|
2476
2523
|
"terminatedIncomingCall",
|
|
2477
2524
|
"failedIncomingCall"
|
|
2478
|
-
],
|
|
2479
|
-
class
|
|
2525
|
+
], $t = 486, qt = 487;
|
|
2526
|
+
class Vt {
|
|
2480
2527
|
events;
|
|
2481
2528
|
incomingRTCSession;
|
|
2482
2529
|
connectionManager;
|
|
2483
2530
|
constructor(e) {
|
|
2484
|
-
this.connectionManager = e, this.events = new
|
|
2531
|
+
this.connectionManager = e, this.events = new F(Ee), this.start();
|
|
2485
2532
|
}
|
|
2486
2533
|
get remoteCallerData() {
|
|
2487
2534
|
return {
|
|
@@ -2511,19 +2558,19 @@ class $t {
|
|
|
2511
2558
|
return this.removeIncomingSession(), e;
|
|
2512
2559
|
};
|
|
2513
2560
|
async declineToIncomingCall({
|
|
2514
|
-
statusCode: e =
|
|
2561
|
+
statusCode: e = qt
|
|
2515
2562
|
} = {}) {
|
|
2516
2563
|
return new Promise((t, s) => {
|
|
2517
2564
|
try {
|
|
2518
|
-
const
|
|
2519
|
-
this.removeIncomingSession(), this.events.trigger(
|
|
2520
|
-
} catch (
|
|
2521
|
-
s(
|
|
2565
|
+
const i = this.getIncomingRTCSession(), r = this.remoteCallerData;
|
|
2566
|
+
this.removeIncomingSession(), this.events.trigger(b.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
|
|
2567
|
+
} catch (i) {
|
|
2568
|
+
s(i);
|
|
2522
2569
|
}
|
|
2523
2570
|
});
|
|
2524
2571
|
}
|
|
2525
2572
|
async busyIncomingCall() {
|
|
2526
|
-
return this.declineToIncomingCall({ statusCode:
|
|
2573
|
+
return this.declineToIncomingCall({ statusCode: $t });
|
|
2527
2574
|
}
|
|
2528
2575
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
2529
2576
|
on(e, t) {
|
|
@@ -2560,19 +2607,19 @@ class $t {
|
|
|
2560
2607
|
this.incomingRTCSession = e;
|
|
2561
2608
|
const t = this.remoteCallerData;
|
|
2562
2609
|
e.on("failed", (s) => {
|
|
2563
|
-
this.removeIncomingSession(), s.originator === "local" ? this.events.trigger(
|
|
2564
|
-
}), this.events.trigger(
|
|
2610
|
+
this.removeIncomingSession(), s.originator === "local" ? this.events.trigger(b.TERMINATED_INCOMING_CALL, t) : this.events.trigger(b.FAILED_INCOMING_CALL, t);
|
|
2611
|
+
}), this.events.trigger(b.INCOMING_CALL, t);
|
|
2565
2612
|
}
|
|
2566
2613
|
removeIncomingSession() {
|
|
2567
2614
|
delete this.incomingRTCSession;
|
|
2568
2615
|
}
|
|
2569
2616
|
}
|
|
2570
|
-
const
|
|
2617
|
+
const D = 1e3;
|
|
2571
2618
|
var A = /* @__PURE__ */ ((n) => (n.INBOUND_RTP = "inbound-rtp", n.REMOTE_OUTBOUND_RTP = "remote-outbound-rtp", n.MEDIA_SOURCE = "media-source", n.OUTBOUND_RTP = "outbound-rtp", n.REMOTE_INBOUND_RTP = "remote-inbound-rtp", n.CODEC = "codec", n.CANDIDATE_PAIR = "candidate-pair", n.CERTIFICATE = "certificate", n.TRANSPORT = "transport", n.LOCAL_CANDIDATE = "local-candidate", n.REMOTE_CANDIDATE = "remote-candidate", n))(A || {});
|
|
2572
|
-
const
|
|
2619
|
+
const Ae = ["collected"], J = () => "performance" in window ? performance.now() : Date.now(), U = (n) => [...n.keys()].reduce((e, t) => {
|
|
2573
2620
|
const s = n.get(t);
|
|
2574
2621
|
return s === void 0 ? e : { ...e, [s.type]: s };
|
|
2575
|
-
}, {}),
|
|
2622
|
+
}, {}), Ht = (n) => {
|
|
2576
2623
|
if (!n)
|
|
2577
2624
|
return {
|
|
2578
2625
|
outboundRtp: void 0,
|
|
@@ -2580,14 +2627,14 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2580
2627
|
mediaSource: void 0,
|
|
2581
2628
|
remoteInboundRtp: void 0
|
|
2582
2629
|
};
|
|
2583
|
-
const e =
|
|
2630
|
+
const e = U(n);
|
|
2584
2631
|
return {
|
|
2585
2632
|
outboundRtp: e[A.OUTBOUND_RTP],
|
|
2586
2633
|
codec: e[A.CODEC],
|
|
2587
2634
|
mediaSource: e[A.MEDIA_SOURCE],
|
|
2588
2635
|
remoteInboundRtp: e[A.REMOTE_INBOUND_RTP]
|
|
2589
2636
|
};
|
|
2590
|
-
},
|
|
2637
|
+
}, K = (n) => {
|
|
2591
2638
|
if (!n)
|
|
2592
2639
|
return {
|
|
2593
2640
|
outboundRtp: void 0,
|
|
@@ -2595,14 +2642,14 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2595
2642
|
mediaSource: void 0,
|
|
2596
2643
|
remoteInboundRtp: void 0
|
|
2597
2644
|
};
|
|
2598
|
-
const e =
|
|
2645
|
+
const e = U(n);
|
|
2599
2646
|
return {
|
|
2600
2647
|
outboundRtp: e[A.OUTBOUND_RTP],
|
|
2601
2648
|
codec: e[A.CODEC],
|
|
2602
2649
|
mediaSource: e[A.MEDIA_SOURCE],
|
|
2603
2650
|
remoteInboundRtp: e[A.REMOTE_INBOUND_RTP]
|
|
2604
2651
|
};
|
|
2605
|
-
},
|
|
2652
|
+
}, j = ({
|
|
2606
2653
|
videoReceiversStats: n,
|
|
2607
2654
|
synchronizationSourcesVideo: e
|
|
2608
2655
|
}) => {
|
|
@@ -2612,13 +2659,13 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2612
2659
|
codec: void 0,
|
|
2613
2660
|
synchronizationSources: e
|
|
2614
2661
|
};
|
|
2615
|
-
const t =
|
|
2662
|
+
const t = U(n);
|
|
2616
2663
|
return {
|
|
2617
2664
|
inboundRtp: t[A.INBOUND_RTP],
|
|
2618
2665
|
codec: t[A.CODEC],
|
|
2619
2666
|
synchronizationSources: e
|
|
2620
2667
|
};
|
|
2621
|
-
},
|
|
2668
|
+
}, Wt = ({
|
|
2622
2669
|
audioReceiverStats: n,
|
|
2623
2670
|
synchronizationSourcesAudio: e
|
|
2624
2671
|
}) => {
|
|
@@ -2629,14 +2676,14 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2629
2676
|
remoteOutboundRtp: void 0,
|
|
2630
2677
|
synchronizationSources: e
|
|
2631
2678
|
};
|
|
2632
|
-
const t =
|
|
2679
|
+
const t = U(n);
|
|
2633
2680
|
return {
|
|
2634
2681
|
inboundRtp: t[A.INBOUND_RTP],
|
|
2635
2682
|
codec: t[A.CODEC],
|
|
2636
2683
|
remoteOutboundRtp: t[A.REMOTE_OUTBOUND_RTP],
|
|
2637
2684
|
synchronizationSources: e
|
|
2638
2685
|
};
|
|
2639
|
-
},
|
|
2686
|
+
}, Re = (n) => {
|
|
2640
2687
|
if (!n)
|
|
2641
2688
|
return {
|
|
2642
2689
|
candidatePair: void 0,
|
|
@@ -2645,7 +2692,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2645
2692
|
remoteCandidate: void 0,
|
|
2646
2693
|
transport: void 0
|
|
2647
2694
|
};
|
|
2648
|
-
const e =
|
|
2695
|
+
const e = U(n);
|
|
2649
2696
|
return {
|
|
2650
2697
|
candidatePair: e[A.CANDIDATE_PAIR],
|
|
2651
2698
|
certificate: e[A.CERTIFICATE],
|
|
@@ -2653,114 +2700,114 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2653
2700
|
remoteCandidate: e[A.REMOTE_CANDIDATE],
|
|
2654
2701
|
transport: e[A.TRANSPORT]
|
|
2655
2702
|
};
|
|
2656
|
-
},
|
|
2703
|
+
}, xt = ({
|
|
2657
2704
|
audioSenderStats: n,
|
|
2658
2705
|
videoSenderFirstStats: e,
|
|
2659
2706
|
videoSenderSecondStats: t
|
|
2660
2707
|
}) => ({
|
|
2661
|
-
video:
|
|
2662
|
-
secondVideo:
|
|
2663
|
-
audio:
|
|
2664
|
-
additional:
|
|
2708
|
+
video: K(e),
|
|
2709
|
+
secondVideo: K(t),
|
|
2710
|
+
audio: Ht(n),
|
|
2711
|
+
additional: Re(
|
|
2665
2712
|
n ?? e ?? t
|
|
2666
2713
|
)
|
|
2667
|
-
}),
|
|
2714
|
+
}), Gt = ({
|
|
2668
2715
|
audioReceiverStats: n,
|
|
2669
2716
|
videoReceiverFirstStats: e,
|
|
2670
2717
|
videoReceiverSecondStats: t,
|
|
2671
2718
|
synchronizationSources: s
|
|
2672
2719
|
}) => ({
|
|
2673
|
-
video:
|
|
2720
|
+
video: j({
|
|
2674
2721
|
videoReceiversStats: e,
|
|
2675
2722
|
synchronizationSourcesVideo: s.video
|
|
2676
2723
|
}),
|
|
2677
|
-
secondVideo:
|
|
2724
|
+
secondVideo: j({
|
|
2678
2725
|
videoReceiversStats: t,
|
|
2679
2726
|
synchronizationSourcesVideo: s.video
|
|
2680
2727
|
}),
|
|
2681
|
-
audio:
|
|
2728
|
+
audio: Wt({
|
|
2682
2729
|
audioReceiverStats: n,
|
|
2683
2730
|
synchronizationSourcesAudio: s.audio
|
|
2684
2731
|
}),
|
|
2685
|
-
additional:
|
|
2732
|
+
additional: Re(
|
|
2686
2733
|
n ?? e ?? t
|
|
2687
2734
|
)
|
|
2688
|
-
}),
|
|
2735
|
+
}), Qt = ({
|
|
2689
2736
|
audioSenderStats: n,
|
|
2690
2737
|
videoSenderFirstStats: e,
|
|
2691
2738
|
videoSenderSecondStats: t,
|
|
2692
2739
|
audioReceiverStats: s,
|
|
2693
|
-
videoReceiverFirstStats:
|
|
2694
|
-
videoReceiverSecondStats:
|
|
2740
|
+
videoReceiverFirstStats: i,
|
|
2741
|
+
videoReceiverSecondStats: r,
|
|
2695
2742
|
synchronizationSources: a
|
|
2696
2743
|
}) => {
|
|
2697
|
-
const o =
|
|
2744
|
+
const o = xt({
|
|
2698
2745
|
audioSenderStats: n,
|
|
2699
2746
|
videoSenderFirstStats: e,
|
|
2700
2747
|
videoSenderSecondStats: t
|
|
2701
|
-
}),
|
|
2748
|
+
}), h = Gt({
|
|
2702
2749
|
audioReceiverStats: s,
|
|
2703
|
-
videoReceiverFirstStats:
|
|
2704
|
-
videoReceiverSecondStats:
|
|
2750
|
+
videoReceiverFirstStats: i,
|
|
2751
|
+
videoReceiverSecondStats: r,
|
|
2705
2752
|
synchronizationSources: a
|
|
2706
2753
|
});
|
|
2707
2754
|
return {
|
|
2708
2755
|
outbound: o,
|
|
2709
|
-
inbound:
|
|
2756
|
+
inbound: h
|
|
2710
2757
|
};
|
|
2711
|
-
},
|
|
2712
|
-
const e = "audio", t = "video", s = n.getSenders(),
|
|
2758
|
+
}, Yt = async (n) => {
|
|
2759
|
+
const e = "audio", t = "video", s = n.getSenders(), i = s.find((u) => u.track?.kind === e), r = s.filter((u) => u.track?.kind === t), a = n.getReceivers(), o = a.find((u) => u.track.kind === e), h = a.filter((u) => u.track.kind === t), d = {
|
|
2713
2760
|
trackIdentifier: o?.track.id,
|
|
2714
2761
|
item: o?.getSynchronizationSources()[0]
|
|
2715
2762
|
}, T = {
|
|
2716
|
-
trackIdentifier:
|
|
2717
|
-
item:
|
|
2763
|
+
trackIdentifier: h[0]?.track.id,
|
|
2764
|
+
item: h[0]?.getSynchronizationSources()[0]
|
|
2718
2765
|
}, S = {
|
|
2719
2766
|
audio: d,
|
|
2720
2767
|
video: T
|
|
2721
2768
|
};
|
|
2722
2769
|
return Promise.all([
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2770
|
+
i?.getStats() ?? Promise.resolve(void 0),
|
|
2771
|
+
r[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2772
|
+
r[1]?.getStats() ?? Promise.resolve(void 0),
|
|
2726
2773
|
o?.getStats() ?? Promise.resolve(void 0),
|
|
2727
|
-
|
|
2728
|
-
|
|
2774
|
+
h[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2775
|
+
h[1]?.getStats() ?? Promise.resolve(void 0)
|
|
2729
2776
|
]).then((u) => {
|
|
2730
2777
|
const [
|
|
2731
2778
|
E,
|
|
2732
|
-
m,
|
|
2733
2779
|
I,
|
|
2734
|
-
|
|
2735
|
-
|
|
2780
|
+
N,
|
|
2781
|
+
M,
|
|
2782
|
+
k,
|
|
2736
2783
|
$
|
|
2737
2784
|
] = u;
|
|
2738
2785
|
return {
|
|
2739
2786
|
synchronizationSources: S,
|
|
2740
2787
|
audioSenderStats: E,
|
|
2741
|
-
videoSenderFirstStats:
|
|
2742
|
-
videoSenderSecondStats:
|
|
2743
|
-
audioReceiverStats:
|
|
2744
|
-
videoReceiverFirstStats:
|
|
2788
|
+
videoSenderFirstStats: I,
|
|
2789
|
+
videoSenderSecondStats: N,
|
|
2790
|
+
audioReceiverStats: M,
|
|
2791
|
+
videoReceiverFirstStats: k,
|
|
2745
2792
|
videoReceiverSecondStats: $
|
|
2746
2793
|
};
|
|
2747
2794
|
});
|
|
2748
|
-
},
|
|
2749
|
-
|
|
2795
|
+
}, zt = (n) => {
|
|
2796
|
+
c(String(n));
|
|
2750
2797
|
};
|
|
2751
|
-
class
|
|
2798
|
+
class Xt {
|
|
2752
2799
|
events;
|
|
2753
2800
|
setTimeoutRequest;
|
|
2754
|
-
requesterAllStatistics = new G(
|
|
2801
|
+
requesterAllStatistics = new G(Yt);
|
|
2755
2802
|
constructor() {
|
|
2756
|
-
this.events = new
|
|
2803
|
+
this.events = new w(Ae), this.setTimeoutRequest = new ee();
|
|
2757
2804
|
}
|
|
2758
2805
|
get requested() {
|
|
2759
2806
|
return this.setTimeoutRequest.requested;
|
|
2760
2807
|
}
|
|
2761
2808
|
start(e, {
|
|
2762
|
-
interval: t =
|
|
2763
|
-
onError: s =
|
|
2809
|
+
interval: t = D,
|
|
2810
|
+
onError: s = zt
|
|
2764
2811
|
} = {}) {
|
|
2765
2812
|
this.stop(), this.setTimeoutRequest.request(() => {
|
|
2766
2813
|
this.collectStatistics(e, {
|
|
@@ -2789,21 +2836,21 @@ class Yt {
|
|
|
2789
2836
|
collectStatistics = (e, {
|
|
2790
2837
|
onError: t
|
|
2791
2838
|
}) => {
|
|
2792
|
-
const s =
|
|
2793
|
-
this.requesterAllStatistics.request(e).then((
|
|
2794
|
-
this.events.trigger("collected",
|
|
2795
|
-
const a =
|
|
2796
|
-
let o =
|
|
2797
|
-
a > 48 ? o =
|
|
2839
|
+
const s = J();
|
|
2840
|
+
this.requesterAllStatistics.request(e).then((i) => {
|
|
2841
|
+
this.events.trigger("collected", Qt(i));
|
|
2842
|
+
const a = J() - s;
|
|
2843
|
+
let o = D;
|
|
2844
|
+
a > 48 ? o = D * 4 : a > 32 ? o = D * 3 : a > 16 && (o = D * 2), this.start(e, {
|
|
2798
2845
|
onError: t,
|
|
2799
2846
|
interval: o
|
|
2800
2847
|
});
|
|
2801
|
-
}).catch((
|
|
2802
|
-
t && t(
|
|
2848
|
+
}).catch((i) => {
|
|
2849
|
+
t && t(i);
|
|
2803
2850
|
});
|
|
2804
2851
|
};
|
|
2805
2852
|
}
|
|
2806
|
-
class
|
|
2853
|
+
class Jt {
|
|
2807
2854
|
availableIncomingBitrate;
|
|
2808
2855
|
statsPeerConnection;
|
|
2809
2856
|
callManager;
|
|
@@ -2813,7 +2860,7 @@ class zt {
|
|
|
2813
2860
|
callManager: e,
|
|
2814
2861
|
apiManager: t
|
|
2815
2862
|
}) {
|
|
2816
|
-
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new
|
|
2863
|
+
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Xt(), this.subscribe();
|
|
2817
2864
|
}
|
|
2818
2865
|
get events() {
|
|
2819
2866
|
return this.statsPeerConnection.events;
|
|
@@ -2851,30 +2898,30 @@ class zt {
|
|
|
2851
2898
|
};
|
|
2852
2899
|
maybeSendStats() {
|
|
2853
2900
|
this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
|
|
2854
|
-
|
|
2901
|
+
c("Failed to send stats", e);
|
|
2855
2902
|
});
|
|
2856
2903
|
}
|
|
2857
2904
|
}
|
|
2858
|
-
const
|
|
2859
|
-
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs,
|
|
2860
|
-
return
|
|
2861
|
-
},
|
|
2862
|
-
const
|
|
2905
|
+
const Kt = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), jt = (n) => {
|
|
2906
|
+
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
|
|
2907
|
+
return Kt(s, i);
|
|
2908
|
+
}, Zt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
|
|
2909
|
+
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;
|
|
2863
2910
|
return a - o;
|
|
2864
|
-
}),
|
|
2911
|
+
}), en = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), tn = (n, {
|
|
2865
2912
|
preferredMimeTypesVideoCodecs: e,
|
|
2866
2913
|
excludeMimeTypesVideoCodecs: t
|
|
2867
2914
|
}) => {
|
|
2868
2915
|
try {
|
|
2869
2916
|
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
2870
|
-
const s =
|
|
2871
|
-
n.setCodecPreferences(
|
|
2917
|
+
const s = jt("video"), i = en(s, t), r = Zt(i, e);
|
|
2918
|
+
n.setCodecPreferences(r);
|
|
2872
2919
|
}
|
|
2873
2920
|
} catch (s) {
|
|
2874
|
-
|
|
2921
|
+
c("setCodecPreferences error", s);
|
|
2875
2922
|
}
|
|
2876
2923
|
};
|
|
2877
|
-
class
|
|
2924
|
+
class nn {
|
|
2878
2925
|
/**
|
|
2879
2926
|
* Хранилище основных transceiver'ов
|
|
2880
2927
|
*/
|
|
@@ -2895,8 +2942,8 @@ class en {
|
|
|
2895
2942
|
if (s === "audio")
|
|
2896
2943
|
this.transceivers.mainAudio ??= e;
|
|
2897
2944
|
else {
|
|
2898
|
-
const { mid:
|
|
2899
|
-
|
|
2945
|
+
const { mid: i } = e;
|
|
2946
|
+
i === "2" ? this.transceivers.presentationVideo ??= e : this.transceivers.mainVideo ??= e;
|
|
2900
2947
|
}
|
|
2901
2948
|
}
|
|
2902
2949
|
/**
|
|
@@ -2953,10 +3000,10 @@ class en {
|
|
|
2953
3000
|
*/
|
|
2954
3001
|
handleRestart = (e) => {
|
|
2955
3002
|
this.updateTransceivers(e).catch((t) => {
|
|
2956
|
-
|
|
3003
|
+
c("Failed to update transceivers", t);
|
|
2957
3004
|
}).finally(() => {
|
|
2958
3005
|
this.callManager.restartIce().catch((t) => {
|
|
2959
|
-
|
|
3006
|
+
c("Failed to restart ICE", t);
|
|
2960
3007
|
});
|
|
2961
3008
|
});
|
|
2962
3009
|
};
|
|
@@ -2967,8 +3014,8 @@ class en {
|
|
|
2967
3014
|
const { videoTrackCount: t } = e;
|
|
2968
3015
|
t === 2 && (this.getTransceivers().presentationVideo !== void 0 || await this.callManager.addTransceiver("video", {
|
|
2969
3016
|
direction: "recvonly"
|
|
2970
|
-
}).catch((
|
|
2971
|
-
|
|
3017
|
+
}).catch((r) => {
|
|
3018
|
+
c("Failed to add presentation video transceiver", r);
|
|
2972
3019
|
}));
|
|
2973
3020
|
};
|
|
2974
3021
|
subscribe() {
|
|
@@ -2981,15 +3028,15 @@ class en {
|
|
|
2981
3028
|
this.clear();
|
|
2982
3029
|
};
|
|
2983
3030
|
}
|
|
2984
|
-
const
|
|
2985
|
-
class
|
|
3031
|
+
const sn = (n) => [...n.keys()].map((e) => n.get(e)), rn = (n, e) => sn(n).find((t) => t?.type === e), an = async (n) => n.getStats().then((e) => rn(e, "codec")?.mimeType);
|
|
3032
|
+
class on {
|
|
2986
3033
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
2987
3034
|
async getCodecFromSender(e) {
|
|
2988
|
-
return await
|
|
3035
|
+
return await an(e) ?? "";
|
|
2989
3036
|
}
|
|
2990
3037
|
}
|
|
2991
|
-
class
|
|
2992
|
-
stackPromises =
|
|
3038
|
+
class cn {
|
|
3039
|
+
stackPromises = ne({
|
|
2993
3040
|
noRunIsNotActual: !0
|
|
2994
3041
|
});
|
|
2995
3042
|
/**
|
|
@@ -3009,34 +3056,34 @@ class an {
|
|
|
3009
3056
|
*/
|
|
3010
3057
|
async run() {
|
|
3011
3058
|
return this.stackPromises().catch((e) => {
|
|
3012
|
-
|
|
3059
|
+
c("TaskQueue: error", e);
|
|
3013
3060
|
});
|
|
3014
3061
|
}
|
|
3015
3062
|
}
|
|
3016
|
-
class
|
|
3063
|
+
class hn {
|
|
3017
3064
|
taskQueue;
|
|
3018
3065
|
onSetParameters;
|
|
3019
3066
|
constructor(e) {
|
|
3020
|
-
this.onSetParameters = e, this.taskQueue = new
|
|
3067
|
+
this.onSetParameters = e, this.taskQueue = new cn();
|
|
3021
3068
|
}
|
|
3022
3069
|
async setEncodingsToSender(e, t) {
|
|
3023
|
-
return this.taskQueue.add(async () =>
|
|
3070
|
+
return this.taskQueue.add(async () => de(e, t, this.onSetParameters));
|
|
3024
3071
|
}
|
|
3025
3072
|
stop() {
|
|
3026
3073
|
this.taskQueue.stop();
|
|
3027
3074
|
}
|
|
3028
3075
|
}
|
|
3029
|
-
const Ne = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()),
|
|
3030
|
-
const t =
|
|
3076
|
+
const Ne = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), dn = 1e6, v = (n) => n * dn, me = v(0.06), Ie = v(4), ln = (n) => n <= 64 ? me : n <= 128 ? v(0.12) : n <= 256 ? v(0.25) : n <= 384 ? v(0.32) : n <= 426 ? v(0.38) : n <= 640 ? v(0.5) : n <= 848 ? v(0.7) : n <= 1280 ? v(1) : n <= 1920 ? v(2) : Ie, un = "av1", gn = (n) => Ne(n, un), Tn = 0.6, Y = (n, e) => gn(e) ? n * Tn : n, Sn = (n) => Y(me, n), Cn = (n) => Y(Ie, n), Z = (n, e) => {
|
|
3077
|
+
const t = ln(n);
|
|
3031
3078
|
return Y(t, e);
|
|
3032
|
-
}, q = 1,
|
|
3079
|
+
}, q = 1, En = ({
|
|
3033
3080
|
videoTrack: n,
|
|
3034
3081
|
targetSize: e
|
|
3035
3082
|
}) => {
|
|
3036
|
-
const t = n.getSettings(), s = t.width,
|
|
3037
|
-
return Math.max(
|
|
3083
|
+
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? q : s / e.width, a = i === void 0 ? q : i / e.height;
|
|
3084
|
+
return Math.max(r, a, q);
|
|
3038
3085
|
};
|
|
3039
|
-
class
|
|
3086
|
+
class An {
|
|
3040
3087
|
ignoreForCodec;
|
|
3041
3088
|
senderFinder;
|
|
3042
3089
|
codecProvider;
|
|
@@ -3055,8 +3102,8 @@ class Cn {
|
|
|
3055
3102
|
senderFinder: e,
|
|
3056
3103
|
codecProvider: t,
|
|
3057
3104
|
parametersSetter: s
|
|
3058
|
-
},
|
|
3059
|
-
this.senderFinder = e, this.codecProvider = t, this.parametersSetter = s, this.ignoreForCodec =
|
|
3105
|
+
}, i) {
|
|
3106
|
+
this.senderFinder = e, this.codecProvider = t, this.parametersSetter = s, this.ignoreForCodec = i.ignoreForCodec;
|
|
3060
3107
|
}
|
|
3061
3108
|
/**
|
|
3062
3109
|
* Выполняет балансировку на основе заголовков от сервера
|
|
@@ -3065,21 +3112,21 @@ class Cn {
|
|
|
3065
3112
|
* @returns Promise с результатом балансировки
|
|
3066
3113
|
*/
|
|
3067
3114
|
async balance(e, t) {
|
|
3068
|
-
const s = e.getSenders(),
|
|
3069
|
-
if (!
|
|
3070
|
-
return { ...this.resultNoChanged, sender:
|
|
3071
|
-
const
|
|
3072
|
-
if (Ne(
|
|
3073
|
-
return { ...this.resultNoChanged, sender:
|
|
3115
|
+
const s = e.getSenders(), i = this.senderFinder.findVideoSender(s);
|
|
3116
|
+
if (!i?.track)
|
|
3117
|
+
return { ...this.resultNoChanged, sender: i };
|
|
3118
|
+
const r = await this.codecProvider.getCodecFromSender(i);
|
|
3119
|
+
if (Ne(r, this.ignoreForCodec))
|
|
3120
|
+
return { ...this.resultNoChanged, sender: i };
|
|
3074
3121
|
const { mainCam: a, resolutionMainCam: o } = t ?? {};
|
|
3075
3122
|
return this.processSender(
|
|
3076
3123
|
{ mainCam: a, resolutionMainCam: o },
|
|
3077
3124
|
{
|
|
3078
|
-
sender:
|
|
3079
|
-
codec:
|
|
3080
|
-
videoTrack:
|
|
3125
|
+
sender: i,
|
|
3126
|
+
codec: r,
|
|
3127
|
+
videoTrack: i.track
|
|
3081
3128
|
}
|
|
3082
|
-
).then((
|
|
3129
|
+
).then((h) => ({ ...h, sender: i }));
|
|
3083
3130
|
}
|
|
3084
3131
|
/**
|
|
3085
3132
|
* Обрабатывает отправитель в зависимости от команды управления
|
|
@@ -3087,16 +3134,16 @@ class Cn {
|
|
|
3087
3134
|
* @returns Promise с результатом обработки
|
|
3088
3135
|
*/
|
|
3089
3136
|
async processSender(e, t) {
|
|
3090
|
-
const { mainCam: s, resolutionMainCam:
|
|
3137
|
+
const { mainCam: s, resolutionMainCam: i } = e;
|
|
3091
3138
|
switch (s) {
|
|
3092
|
-
case
|
|
3139
|
+
case f.PAUSE_MAIN_CAM:
|
|
3093
3140
|
return this.downgradeResolutionSender(t);
|
|
3094
|
-
case
|
|
3141
|
+
case f.RESUME_MAIN_CAM:
|
|
3095
3142
|
return this.setBitrateByTrackResolution(t);
|
|
3096
|
-
case
|
|
3097
|
-
return
|
|
3098
|
-
case
|
|
3099
|
-
case
|
|
3143
|
+
case f.MAX_MAIN_CAM_RESOLUTION:
|
|
3144
|
+
return i !== void 0 ? this.setResolutionSender(i, t) : this.setBitrateByTrackResolution(t);
|
|
3145
|
+
case f.ADMIN_STOP_MAIN_CAM:
|
|
3146
|
+
case f.ADMIN_START_MAIN_CAM:
|
|
3100
3147
|
case void 0:
|
|
3101
3148
|
return this.setBitrateByTrackResolution(t);
|
|
3102
3149
|
default:
|
|
@@ -3109,11 +3156,11 @@ class Cn {
|
|
|
3109
3156
|
* @returns Promise с результатом
|
|
3110
3157
|
*/
|
|
3111
3158
|
async downgradeResolutionSender(e) {
|
|
3112
|
-
const { sender: t, codec: s } = e,
|
|
3159
|
+
const { sender: t, codec: s } = e, i = {
|
|
3113
3160
|
scaleResolutionDownBy: 200,
|
|
3114
|
-
maxBitrate:
|
|
3161
|
+
maxBitrate: Sn(s)
|
|
3115
3162
|
};
|
|
3116
|
-
return this.parametersSetter.setEncodingsToSender(t,
|
|
3163
|
+
return this.parametersSetter.setEncodingsToSender(t, i);
|
|
3117
3164
|
}
|
|
3118
3165
|
/**
|
|
3119
3166
|
* Устанавливает битрейт на основе разрешения трека
|
|
@@ -3121,7 +3168,7 @@ class Cn {
|
|
|
3121
3168
|
* @returns Promise с результатом
|
|
3122
3169
|
*/
|
|
3123
3170
|
async setBitrateByTrackResolution(e) {
|
|
3124
|
-
const { sender: t, videoTrack: s, codec:
|
|
3171
|
+
const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? Cn(i) : Z(a, i);
|
|
3125
3172
|
return this.parametersSetter.setEncodingsToSender(t, {
|
|
3126
3173
|
scaleResolutionDownBy: 1,
|
|
3127
3174
|
maxBitrate: o
|
|
@@ -3134,27 +3181,27 @@ class Cn {
|
|
|
3134
3181
|
* @returns Promise с результатом
|
|
3135
3182
|
*/
|
|
3136
3183
|
async setResolutionSender(e, t) {
|
|
3137
|
-
const [s,
|
|
3184
|
+
const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, h = {
|
|
3138
3185
|
width: Number(s),
|
|
3139
|
-
height: Number(
|
|
3140
|
-
}, d =
|
|
3186
|
+
height: Number(i)
|
|
3187
|
+
}, d = En({
|
|
3141
3188
|
videoTrack: a,
|
|
3142
|
-
targetSize:
|
|
3143
|
-
}), T =
|
|
3189
|
+
targetSize: h
|
|
3190
|
+
}), T = Z(h.width, o), S = {
|
|
3144
3191
|
scaleResolutionDownBy: d,
|
|
3145
3192
|
maxBitrate: T
|
|
3146
3193
|
};
|
|
3147
|
-
return this.parametersSetter.setEncodingsToSender(
|
|
3194
|
+
return this.parametersSetter.setEncodingsToSender(r, S);
|
|
3148
3195
|
}
|
|
3149
3196
|
}
|
|
3150
|
-
const
|
|
3151
|
-
class
|
|
3197
|
+
const Rn = (n) => n.find((e) => e.track?.kind === "video");
|
|
3198
|
+
class Nn {
|
|
3152
3199
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
3153
3200
|
findVideoSender(e) {
|
|
3154
|
-
return
|
|
3201
|
+
return Rn(e);
|
|
3155
3202
|
}
|
|
3156
3203
|
}
|
|
3157
|
-
class
|
|
3204
|
+
class mn {
|
|
3158
3205
|
currentSender;
|
|
3159
3206
|
originalReplaceTrack;
|
|
3160
3207
|
lastWidth;
|
|
@@ -3167,7 +3214,7 @@ class Nn {
|
|
|
3167
3214
|
pollIntervalMs: e = 1e3,
|
|
3168
3215
|
maxPollIntervalMs: t
|
|
3169
3216
|
}) {
|
|
3170
|
-
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new
|
|
3217
|
+
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new ee();
|
|
3171
3218
|
}
|
|
3172
3219
|
/**
|
|
3173
3220
|
* Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
|
|
@@ -3186,8 +3233,8 @@ class Nn {
|
|
|
3186
3233
|
attachSender(e, t) {
|
|
3187
3234
|
this.currentSender = e;
|
|
3188
3235
|
const s = e.replaceTrack.bind(e);
|
|
3189
|
-
this.originalReplaceTrack = s, e.replaceTrack = async (
|
|
3190
|
-
await s(
|
|
3236
|
+
this.originalReplaceTrack = s, e.replaceTrack = async (i) => {
|
|
3237
|
+
await s(i), this.attachTrack(t, i ?? void 0), t();
|
|
3191
3238
|
}, this.attachTrack(t, e.track);
|
|
3192
3239
|
}
|
|
3193
3240
|
detachSender() {
|
|
@@ -3196,8 +3243,8 @@ class Nn {
|
|
|
3196
3243
|
attachTrack(e, t) {
|
|
3197
3244
|
if (this.detachTrack(), !t)
|
|
3198
3245
|
return;
|
|
3199
|
-
const { width: s, height:
|
|
3200
|
-
this.lastWidth = s, this.lastHeight =
|
|
3246
|
+
const { width: s, height: i } = t.getSettings();
|
|
3247
|
+
this.lastWidth = s, this.lastHeight = i, this.currentPollIntervalMs = this.pollIntervalMs, this.schedulePoll(t, e);
|
|
3201
3248
|
}
|
|
3202
3249
|
/**
|
|
3203
3250
|
* Периодически опрашивает track с экспоненциальной адаптацией частоты.
|
|
@@ -3206,8 +3253,8 @@ class Nn {
|
|
|
3206
3253
|
*/
|
|
3207
3254
|
schedulePoll(e, t) {
|
|
3208
3255
|
const s = () => {
|
|
3209
|
-
const { width:
|
|
3210
|
-
|
|
3256
|
+
const { width: i, height: r } = e.getSettings();
|
|
3257
|
+
i !== this.lastWidth || r !== this.lastHeight ? (this.lastWidth = i, this.lastHeight = r, this.currentPollIntervalMs = this.pollIntervalMs, t()) : this.currentPollIntervalMs = Math.min(
|
|
3211
3258
|
this.currentPollIntervalMs * 2,
|
|
3212
3259
|
this.maxPollIntervalMs
|
|
3213
3260
|
), this.setTimeoutRequest.request(s, this.currentPollIntervalMs);
|
|
@@ -3218,7 +3265,7 @@ class Nn {
|
|
|
3218
3265
|
this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
|
|
3219
3266
|
}
|
|
3220
3267
|
}
|
|
3221
|
-
class
|
|
3268
|
+
class In {
|
|
3222
3269
|
apiManager;
|
|
3223
3270
|
currentHandler;
|
|
3224
3271
|
constructor(e) {
|
|
@@ -3238,7 +3285,7 @@ class Rn {
|
|
|
3238
3285
|
this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
|
|
3239
3286
|
}
|
|
3240
3287
|
}
|
|
3241
|
-
class
|
|
3288
|
+
class pn {
|
|
3242
3289
|
eventHandler;
|
|
3243
3290
|
senderBalancer;
|
|
3244
3291
|
parametersSetterWithQueue;
|
|
@@ -3247,19 +3294,19 @@ class In {
|
|
|
3247
3294
|
trackMonitor;
|
|
3248
3295
|
constructor(e, t, {
|
|
3249
3296
|
ignoreForCodec: s,
|
|
3250
|
-
onSetParameters:
|
|
3251
|
-
pollIntervalMs:
|
|
3297
|
+
onSetParameters: i,
|
|
3298
|
+
pollIntervalMs: r
|
|
3252
3299
|
} = {}) {
|
|
3253
|
-
this.getConnection = t, this.eventHandler = new
|
|
3300
|
+
this.getConnection = t, this.eventHandler = new In(e), this.parametersSetterWithQueue = new hn(i), this.senderBalancer = new An(
|
|
3254
3301
|
{
|
|
3255
|
-
senderFinder: new
|
|
3256
|
-
codecProvider: new
|
|
3302
|
+
senderFinder: new Nn(),
|
|
3303
|
+
codecProvider: new on(),
|
|
3257
3304
|
parametersSetter: this.parametersSetterWithQueue
|
|
3258
3305
|
},
|
|
3259
3306
|
{
|
|
3260
3307
|
ignoreForCodec: s
|
|
3261
3308
|
}
|
|
3262
|
-
), this.trackMonitor = new
|
|
3309
|
+
), this.trackMonitor = new mn({ pollIntervalMs: r });
|
|
3263
3310
|
}
|
|
3264
3311
|
/**
|
|
3265
3312
|
* Подписывается на события управления главной камерой
|
|
@@ -3290,7 +3337,7 @@ class In {
|
|
|
3290
3337
|
const t = await this.senderBalancer.balance(e, this.serverHeaders);
|
|
3291
3338
|
return this.trackMonitor.subscribe(t.sender, () => {
|
|
3292
3339
|
this.balance().catch((s) => {
|
|
3293
|
-
|
|
3340
|
+
c("balance on track change: error", s);
|
|
3294
3341
|
});
|
|
3295
3342
|
}), t;
|
|
3296
3343
|
}
|
|
@@ -3300,7 +3347,7 @@ class In {
|
|
|
3300
3347
|
*/
|
|
3301
3348
|
handleMainCamControl = (e) => {
|
|
3302
3349
|
this.serverHeaders = e, this.balance().catch((t) => {
|
|
3303
|
-
|
|
3350
|
+
c("handleMainCamControl: error", t);
|
|
3304
3351
|
});
|
|
3305
3352
|
};
|
|
3306
3353
|
}
|
|
@@ -3310,7 +3357,7 @@ const pe = [
|
|
|
3310
3357
|
"balancing-stopped",
|
|
3311
3358
|
"parameters-updated"
|
|
3312
3359
|
];
|
|
3313
|
-
class
|
|
3360
|
+
class _n {
|
|
3314
3361
|
isBalancingActive = !1;
|
|
3315
3362
|
events;
|
|
3316
3363
|
callManager;
|
|
@@ -3318,13 +3365,13 @@ class pn {
|
|
|
3318
3365
|
videoSendingBalancer;
|
|
3319
3366
|
startBalancingTimer;
|
|
3320
3367
|
constructor(e, t, s = {}) {
|
|
3321
|
-
this.events = new
|
|
3368
|
+
this.events = new w(pe), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new pn(
|
|
3322
3369
|
t,
|
|
3323
3370
|
() => e.connection,
|
|
3324
3371
|
{
|
|
3325
3372
|
...s,
|
|
3326
|
-
onSetParameters: (
|
|
3327
|
-
this.events.trigger("parameters-updated",
|
|
3373
|
+
onSetParameters: (i) => {
|
|
3374
|
+
this.events.trigger("parameters-updated", i), s.onSetParameters?.(i);
|
|
3328
3375
|
}
|
|
3329
3376
|
}
|
|
3330
3377
|
), this.subscribe();
|
|
@@ -3380,7 +3427,7 @@ class pn {
|
|
|
3380
3427
|
scheduleBalancingStart() {
|
|
3381
3428
|
this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
|
|
3382
3429
|
this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
|
|
3383
|
-
|
|
3430
|
+
c("startBalancing: error", e);
|
|
3384
3431
|
});
|
|
3385
3432
|
}, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
|
|
3386
3433
|
}
|
|
@@ -3388,17 +3435,17 @@ class pn {
|
|
|
3388
3435
|
this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
|
|
3389
3436
|
}
|
|
3390
3437
|
}
|
|
3391
|
-
const
|
|
3392
|
-
..._n,
|
|
3393
|
-
...Mn,
|
|
3394
|
-
...fn,
|
|
3438
|
+
const Mn = 1e6, vn = Ce.map((n) => `auto-connect:${n}`), fn = ge.map((n) => `connection:${n}`), Pn = re.map((n) => `call:${n}`), On = se.map((n) => `api:${n}`), yn = Ee.map((n) => `incoming-call:${n}`), Dn = le.map((n) => `presentation:${n}`), bn = Ae.map((n) => `stats:${n}`), wn = pe.map((n) => `video-balancer:${n}`), Un = [
|
|
3395
3439
|
...vn,
|
|
3440
|
+
...fn,
|
|
3396
3441
|
...Pn,
|
|
3397
3442
|
...On,
|
|
3398
3443
|
...yn,
|
|
3399
|
-
...Dn
|
|
3444
|
+
...Dn,
|
|
3445
|
+
...bn,
|
|
3446
|
+
...wn
|
|
3400
3447
|
];
|
|
3401
|
-
class
|
|
3448
|
+
class Yn {
|
|
3402
3449
|
events;
|
|
3403
3450
|
connectionManager;
|
|
3404
3451
|
connectionQueueManager;
|
|
@@ -3415,34 +3462,34 @@ class Gn {
|
|
|
3415
3462
|
constructor({ JsSIP: e }, {
|
|
3416
3463
|
preferredMimeTypesVideoCodecs: t,
|
|
3417
3464
|
excludeMimeTypesVideoCodecs: s,
|
|
3418
|
-
videoBalancerOptions:
|
|
3419
|
-
autoConnectorOptions:
|
|
3465
|
+
videoBalancerOptions: i,
|
|
3466
|
+
autoConnectorOptions: r
|
|
3420
3467
|
} = {}) {
|
|
3421
|
-
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new
|
|
3468
|
+
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new F(Un), this.connectionManager = new _t({ JsSIP: e }), this.connectionQueueManager = new Mt({
|
|
3422
3469
|
connectionManager: this.connectionManager
|
|
3423
|
-
}), this.callManager = new
|
|
3470
|
+
}), this.callManager = new Je(), this.apiManager = new ke({
|
|
3424
3471
|
connectionManager: this.connectionManager,
|
|
3425
3472
|
callManager: this.callManager
|
|
3426
|
-
}), this.incomingCallManager = new
|
|
3473
|
+
}), this.incomingCallManager = new Vt(this.connectionManager), this.presentationManager = new lt({
|
|
3427
3474
|
callManager: this.callManager,
|
|
3428
|
-
maxBitrate:
|
|
3429
|
-
}), this.statsManager = new
|
|
3475
|
+
maxBitrate: Mn
|
|
3476
|
+
}), this.statsManager = new Jt({
|
|
3430
3477
|
callManager: this.callManager,
|
|
3431
3478
|
apiManager: this.apiManager
|
|
3432
|
-
}), this.autoConnectorManager = new
|
|
3479
|
+
}), this.autoConnectorManager = new kt(
|
|
3433
3480
|
{
|
|
3434
3481
|
connectionQueueManager: this.connectionQueueManager,
|
|
3435
3482
|
connectionManager: this.connectionManager,
|
|
3436
3483
|
callManager: this.callManager
|
|
3437
3484
|
},
|
|
3438
|
-
|
|
3439
|
-
), this.transceiverManager = new
|
|
3485
|
+
r
|
|
3486
|
+
), this.transceiverManager = new nn({
|
|
3440
3487
|
callManager: this.callManager,
|
|
3441
3488
|
apiManager: this.apiManager
|
|
3442
|
-
}), this.videoSendingBalancerManager = new
|
|
3489
|
+
}), this.videoSendingBalancerManager = new _n(
|
|
3443
3490
|
this.callManager,
|
|
3444
3491
|
this.apiManager,
|
|
3445
|
-
|
|
3492
|
+
i
|
|
3446
3493
|
), this.subscribe();
|
|
3447
3494
|
}
|
|
3448
3495
|
get requestedConnection() {
|
|
@@ -3472,9 +3519,6 @@ class Gn {
|
|
|
3472
3519
|
get connection() {
|
|
3473
3520
|
return this.callManager.connection;
|
|
3474
3521
|
}
|
|
3475
|
-
get establishedRTCSession() {
|
|
3476
|
-
return this.callManager.establishedRTCSession;
|
|
3477
|
-
}
|
|
3478
3522
|
get isCallActive() {
|
|
3479
3523
|
return this.callManager.isCallActive;
|
|
3480
3524
|
}
|
|
@@ -3549,7 +3593,7 @@ class Gn {
|
|
|
3549
3593
|
getRemoteStreams = () => this.callManager.getRemoteStreams();
|
|
3550
3594
|
replaceMediaStream = async (...e) => this.callManager.replaceMediaStream(...e);
|
|
3551
3595
|
async startPresentation(e, t = {}) {
|
|
3552
|
-
const { isP2P: s, callLimit:
|
|
3596
|
+
const { isP2P: s, callLimit: i, onAddedTransceiver: r, ...a } = t;
|
|
3553
3597
|
return this.presentationManager.startPresentation(
|
|
3554
3598
|
async () => {
|
|
3555
3599
|
s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
|
|
@@ -3557,9 +3601,9 @@ class Gn {
|
|
|
3557
3601
|
e,
|
|
3558
3602
|
{
|
|
3559
3603
|
...a,
|
|
3560
|
-
onAddedTransceiver: this.resolveHandleAddTransceiver(
|
|
3604
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(r)
|
|
3561
3605
|
},
|
|
3562
|
-
|
|
3606
|
+
i === void 0 ? void 0 : { callLimit: i }
|
|
3563
3607
|
);
|
|
3564
3608
|
}
|
|
3565
3609
|
async stopPresentation(e = {}) {
|
|
@@ -3569,15 +3613,15 @@ class Gn {
|
|
|
3569
3613
|
});
|
|
3570
3614
|
}
|
|
3571
3615
|
async updatePresentation(e, t = {}) {
|
|
3572
|
-
const { isP2P: s, onAddedTransceiver:
|
|
3616
|
+
const { isP2P: s, onAddedTransceiver: i, ...r } = t;
|
|
3573
3617
|
return this.presentationManager.updatePresentation(
|
|
3574
3618
|
async () => {
|
|
3575
3619
|
s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
|
|
3576
3620
|
},
|
|
3577
3621
|
e,
|
|
3578
3622
|
{
|
|
3579
|
-
...
|
|
3580
|
-
onAddedTransceiver: this.resolveHandleAddTransceiver(
|
|
3623
|
+
...r,
|
|
3624
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(i)
|
|
3581
3625
|
}
|
|
3582
3626
|
);
|
|
3583
3627
|
}
|
|
@@ -3624,7 +3668,7 @@ class Gn {
|
|
|
3624
3668
|
return this.apiManager.askPermissionToEnableCam(...e);
|
|
3625
3669
|
}
|
|
3626
3670
|
setCodecPreferences(e) {
|
|
3627
|
-
|
|
3671
|
+
tn(e, {
|
|
3628
3672
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
3629
3673
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
3630
3674
|
});
|
|
@@ -3633,30 +3677,30 @@ class Gn {
|
|
|
3633
3677
|
this.bridgeEvents("auto-connect", this.autoConnectorManager), this.bridgeEvents("connection", this.connectionManager), this.bridgeEvents("call", this.callManager), this.bridgeEvents("api", this.apiManager), this.bridgeEvents("incoming-call", this.incomingCallManager), this.bridgeEvents("presentation", this.presentationManager), this.bridgeEvents("stats", this.statsManager), this.bridgeEvents("video-balancer", this.videoSendingBalancerManager);
|
|
3634
3678
|
}
|
|
3635
3679
|
bridgeEvents = (e, t) => {
|
|
3636
|
-
t.events.eachTriggers((s,
|
|
3637
|
-
t.on(
|
|
3638
|
-
this.events.trigger(`${e}:${
|
|
3680
|
+
t.events.eachTriggers((s, i) => {
|
|
3681
|
+
t.on(i, (r) => {
|
|
3682
|
+
this.events.trigger(`${e}:${i}`, r);
|
|
3639
3683
|
});
|
|
3640
3684
|
});
|
|
3641
3685
|
};
|
|
3642
|
-
resolveHandleAddTransceiver = (e) => async (t, s,
|
|
3643
|
-
this.setCodecPreferences(t), await e?.(t, s,
|
|
3686
|
+
resolveHandleAddTransceiver = (e) => async (t, s, i) => {
|
|
3687
|
+
this.setCodecPreferences(t), await e?.(t, s, i);
|
|
3644
3688
|
};
|
|
3645
3689
|
}
|
|
3646
3690
|
export {
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3691
|
+
oe as E,
|
|
3692
|
+
$e as O,
|
|
3693
|
+
Yn as S,
|
|
3694
|
+
ot as a,
|
|
3695
|
+
Fe as b,
|
|
3696
|
+
Qn as c,
|
|
3697
|
+
Gn as d,
|
|
3698
|
+
xn as e,
|
|
3655
3699
|
A as f,
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3700
|
+
Xt as g,
|
|
3701
|
+
mt as h,
|
|
3702
|
+
an as i,
|
|
3703
|
+
c as l,
|
|
3704
|
+
B as p,
|
|
3705
|
+
de as s
|
|
3662
3706
|
};
|