sip-connector 22.0.0 → 23.1.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-OAqRbRF0.js → @SipConnector-B599bzsb.js} +914 -671
- package/dist/@SipConnector-Cf-5oSvs.cjs +1 -0
- package/dist/ApiManager/@ApiManager.d.ts +8 -10
- package/dist/ApiManager/constants.d.ts +80 -44
- package/dist/ApiManager/events.d.ts +7 -5
- package/dist/ApiManager/getHeader.d.ts +3 -0
- package/dist/ApiManager/index.d.ts +3 -2
- package/dist/CallManager/@CallManager.d.ts +9 -1
- package/dist/CallManager/RecvSession.d.ts +1 -0
- package/dist/CallManager/StreamsChangeTracker.d.ts +35 -0
- package/dist/CallManager/StreamsManagerProvider.d.ts +12 -3
- package/dist/ConnectionManager/ConnectionStateMachine.d.ts +0 -2
- package/dist/ContentedStreamManager/@ContentedStreamManager.d.ts +19 -0
- package/dist/ContentedStreamManager/ContentedStreamStateMachine.d.ts +52 -0
- package/dist/ContentedStreamManager/events.d.ts +15 -0
- package/dist/ContentedStreamManager/index.d.ts +4 -0
- package/dist/ContentedStreamManager/types.d.ts +7 -0
- package/dist/SipConnector/@SipConnector.d.ts +2 -5
- package/dist/SipConnectorFacade/@SipConnectorFacade.d.ts +3 -3
- package/dist/StatsPeerConnection/@StatsPeerConnection.d.ts +2 -1
- package/dist/VideoSendingBalancer/types.d.ts +2 -2
- package/dist/__fixtures__/Request.mock.d.ts +1 -1
- package/dist/__fixtures__/UA.mock.d.ts +13 -3
- package/dist/__fixtures__/createManagers.d.ts +12 -0
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +162 -134
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -22
- package/dist/tools/BaseStateMachine.d.ts +2 -0
- package/package.json +3 -3
- package/dist/@SipConnector-mL9nMhkX.cjs +0 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { TypedEvents as
|
|
3
|
-
import { CancelableRequest as
|
|
4
|
-
import { resolveRequesterByTimeout as
|
|
5
|
-
import { hasCanceledError as
|
|
6
|
-
import { createActor as
|
|
7
|
-
import { createStackPromises as
|
|
1
|
+
import Z from "debug";
|
|
2
|
+
import { TypedEvents as R } from "events-constructor";
|
|
3
|
+
import { CancelableRequest as Y, isCanceledError as Qe } from "@krivega/cancelable-promise";
|
|
4
|
+
import { resolveRequesterByTimeout as Ye, requesterByTimeoutsWithFailCalls as Xe, DelayRequester as Je, hasCanceledError as ze, SetTimeoutRequest as ue } from "@krivega/timeout-requester";
|
|
5
|
+
import { hasCanceledError as je, repeatedCallsAsync as Te } from "repeated-calls";
|
|
6
|
+
import { createActor as Ke, setup as G, assign as M } from "xstate";
|
|
7
|
+
import { createStackPromises as Ee, isPromiseIsNotActualError as Ze } from "stack-promises";
|
|
8
8
|
import "ua-parser-js";
|
|
9
9
|
import "sequent-promises";
|
|
10
|
-
import
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
var
|
|
17
|
-
const
|
|
10
|
+
import et from "lodash";
|
|
11
|
+
const ee = "sip-connector", d = Z(ee), di = () => {
|
|
12
|
+
Z.enable(ee);
|
|
13
|
+
}, hi = () => {
|
|
14
|
+
Z.enable(`-${ee}`);
|
|
15
|
+
}, tt = "Error decline with 603", nt = 1006, st = (n) => typeof n == "object" && n !== null && "code" in n && n.code === nt, it = (n) => n.message === tt;
|
|
16
|
+
var W = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(W || {}), y = /* @__PURE__ */ ((n) => (n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n))(y || {}), _ = /* @__PURE__ */ ((n) => (n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.STATS = "application/vinteo.webrtc.stats", n))(_ || {}), 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 || {}), x = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(x || {}), Se = /* @__PURE__ */ ((n) => (n.H264 = "H264", n.VP8 = "VP8", n.VP9 = "VP9", n.AV1 = "AV1", n))(Se || {}), h = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENTED_STREAM_STATE = "x-webrtc-share-state", n.CONTENTED_STREAM_CODEC = "x-webrtc-share-codec", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n.AUDIO_ID = "X-WEBRTC-AUDIOID", n))(h || {}), $ = /* @__PURE__ */ ((n) => (n.AVAILABLE_CONTENTED_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_CONTENTED_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))($ || {}), U = /* @__PURE__ */ ((n) => (n.AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: CONTENTEND", n.ACK_PERMISSION_TO_START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.STOPPED_CLIENT_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n))(U || {}), Q = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(Q || {}), Ce = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Ce || {}), g = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "enter-room", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "use-license", n.NEW_DTMF = "new-dtmf", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CONTENTED_STREAM_AVAILABLE = "contented-stream:available", n.CONTENTED_STREAM_NOT_AVAILABLE = "contented-stream:not-available", n.PRESENTATION_MUST_STOP = "presentation:must-stop", n.CHANNELS_ALL = "channels:all", n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC = "participant:move-request-to-spectators-synthetic", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.ADMIN_START_MAIN_CAM = "admin:start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin:stop-main-cam", n.ADMIN_START_MIC = "admin:start-mic", n.ADMIN_STOP_MIC = "admin:stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin:force-sync-media-state", n))(g || {});
|
|
17
|
+
const pe = [
|
|
18
18
|
"enter-room",
|
|
19
19
|
"main-cam-control",
|
|
20
20
|
"use-license",
|
|
@@ -43,23 +43,76 @@ const ge = [
|
|
|
43
43
|
"admin:start-mic",
|
|
44
44
|
"admin:stop-mic",
|
|
45
45
|
"admin:force-sync-media-state"
|
|
46
|
-
],
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
], rt = () => new R(pe), at = (n) => typeof n == "string" && n.trim().length > 0, L = (n, e) => {
|
|
47
|
+
const t = e.toLowerCase(), s = Object.entries(n).find(([, i]) => typeof i == "string" && i.toLowerCase() === t);
|
|
48
|
+
return s ? s[1] : void 0;
|
|
49
|
+
}, ot = (n) => typeof n == "string" && !Number.isNaN(Number(n)) && Number.isFinite(Number(n)), ct = (n) => {
|
|
50
|
+
if (ot(n))
|
|
51
|
+
return Number(n);
|
|
52
|
+
}, N = (n, e) => {
|
|
53
|
+
const t = n.getHeader(e);
|
|
54
|
+
if (!at(t))
|
|
55
|
+
return;
|
|
56
|
+
const s = t.toLowerCase();
|
|
57
|
+
switch (e) {
|
|
58
|
+
case h.CONTENT_ENTER_ROOM:
|
|
59
|
+
case h.PARTICIPANT_NAME:
|
|
60
|
+
case h.INPUT_CHANNELS:
|
|
61
|
+
case h.OUTPUT_CHANNELS:
|
|
62
|
+
case h.TRACKS_DIRECTION:
|
|
63
|
+
case h.AUDIO_ID:
|
|
64
|
+
case h.MAIN_CAM_RESOLUTION:
|
|
65
|
+
case h.MEDIA_STATE:
|
|
66
|
+
case h.NOTIFY:
|
|
67
|
+
case h.CONTENT_ENABLE_MEDIA_DEVICE:
|
|
68
|
+
return s;
|
|
69
|
+
case h.MEDIA_TYPE:
|
|
70
|
+
case h.MAIN_CAM_STATE:
|
|
71
|
+
case h.MIC_STATE:
|
|
72
|
+
case h.AVAILABLE_INCOMING_BITRATE:
|
|
73
|
+
case h.AUDIO_TRACK_COUNT:
|
|
74
|
+
case h.VIDEO_TRACK_COUNT:
|
|
75
|
+
return ct(s);
|
|
76
|
+
case h.CONTENTED_STREAM_CODEC:
|
|
77
|
+
return L(Se, s);
|
|
78
|
+
case h.CONTENT_TYPE:
|
|
79
|
+
return L(y, s);
|
|
80
|
+
case h.CONTENT_USE_LICENSE:
|
|
81
|
+
return L(Ce, s);
|
|
82
|
+
case h.MAIN_CAM:
|
|
83
|
+
return L(f, s);
|
|
84
|
+
case h.MIC:
|
|
85
|
+
return L(x, s);
|
|
86
|
+
case h.MEDIA_SYNC:
|
|
87
|
+
return L(Q, s);
|
|
88
|
+
case h.CONTENT_PARTICIPANT_STATE:
|
|
89
|
+
return L(W, s);
|
|
90
|
+
case h.CONTENTED_STREAM_STATE:
|
|
91
|
+
return L($, s);
|
|
92
|
+
default:
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var I = /* @__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))(I || {});
|
|
97
|
+
class dt {
|
|
49
98
|
events;
|
|
50
|
-
connectionManager;
|
|
51
99
|
callManager;
|
|
52
|
-
constructor({
|
|
100
|
+
constructor() {
|
|
101
|
+
this.events = rt();
|
|
102
|
+
}
|
|
103
|
+
subscribe({
|
|
53
104
|
connectionManager: e,
|
|
54
105
|
callManager: t
|
|
55
106
|
}) {
|
|
56
|
-
this.
|
|
107
|
+
this.callManager = t, e.on("sipEvent", this.handleSipEvent), t.on("newInfo", this.handleNewInfo), t.on("newDTMF", ({ originator: s }) => {
|
|
108
|
+
this.events.trigger(g.NEW_DTMF, { originator: s });
|
|
109
|
+
});
|
|
57
110
|
}
|
|
58
111
|
async waitChannels() {
|
|
59
|
-
return this.wait(
|
|
112
|
+
return this.wait(g.CHANNELS_ALL);
|
|
60
113
|
}
|
|
61
114
|
async waitSyncMediaState() {
|
|
62
|
-
return this.wait(
|
|
115
|
+
return this.wait(g.ADMIN_FORCE_SYNC_MEDIA_STATE);
|
|
63
116
|
}
|
|
64
117
|
async sendDTMF(e) {
|
|
65
118
|
return new Promise((t, s) => {
|
|
@@ -69,7 +122,7 @@ class tt {
|
|
|
69
122
|
} catch (r) {
|
|
70
123
|
s(r);
|
|
71
124
|
}
|
|
72
|
-
i && (this.callManager
|
|
125
|
+
i && (this.callManager?.once("newDTMF", ({ originator: r }) => {
|
|
73
126
|
r === "local" && t();
|
|
74
127
|
}), i.sendDTMF(e, {
|
|
75
128
|
duration: 120,
|
|
@@ -78,19 +131,19 @@ class tt {
|
|
|
78
131
|
});
|
|
79
132
|
}
|
|
80
133
|
async sendChannels({ inputChannels: e, outputChannels: t }) {
|
|
81
|
-
const s = this.getEstablishedRTCSessionProtected(), i = `${
|
|
134
|
+
const s = this.getEstablishedRTCSessionProtected(), i = `${h.INPUT_CHANNELS}: ${e}`, r = `${h.OUTPUT_CHANNELS}: ${t}`, a = [
|
|
82
135
|
i,
|
|
83
136
|
r
|
|
84
137
|
];
|
|
85
|
-
return s.sendInfo(
|
|
138
|
+
return s.sendInfo(_.CHANNELS, void 0, { extraHeaders: a });
|
|
86
139
|
}
|
|
87
140
|
async sendMediaState({ cam: e, mic: t }, s = {}) {
|
|
88
|
-
const i = this.getEstablishedRTCSessionProtected(), r = `${
|
|
141
|
+
const i = this.getEstablishedRTCSessionProtected(), r = `${h.MEDIA_STATE}: currentstate`, a = `${h.MAIN_CAM_STATE}: ${Number(e)}`, o = `${h.MIC_STATE}: ${Number(t)}`, c = [
|
|
89
142
|
r,
|
|
90
143
|
a,
|
|
91
144
|
o
|
|
92
145
|
];
|
|
93
|
-
return i.sendInfo(
|
|
146
|
+
return i.sendInfo(_.MEDIA_STATE, void 0, {
|
|
94
147
|
noTerminateWhenError: !0,
|
|
95
148
|
...s,
|
|
96
149
|
extraHeaders: c
|
|
@@ -99,15 +152,15 @@ class tt {
|
|
|
99
152
|
async sendStats({
|
|
100
153
|
availableIncomingBitrate: e
|
|
101
154
|
}) {
|
|
102
|
-
const t = this.getEstablishedRTCSessionProtected(), i = [`${
|
|
103
|
-
return t.sendInfo(
|
|
155
|
+
const t = this.getEstablishedRTCSessionProtected(), i = [`${h.AVAILABLE_INCOMING_BITRATE}: ${e}`];
|
|
156
|
+
return t.sendInfo(_.STATS, void 0, {
|
|
104
157
|
noTerminateWhenError: !0,
|
|
105
158
|
extraHeaders: i
|
|
106
159
|
});
|
|
107
160
|
}
|
|
108
161
|
async sendRefusalToTurnOn(e, t = {}) {
|
|
109
|
-
const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${
|
|
110
|
-
return s.sendInfo(
|
|
162
|
+
const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${h.MEDIA_TYPE}: ${a}`];
|
|
163
|
+
return s.sendInfo(_.REFUSAL, void 0, {
|
|
111
164
|
noTerminateWhenError: !0,
|
|
112
165
|
...t,
|
|
113
166
|
extraHeaders: c
|
|
@@ -119,39 +172,34 @@ class tt {
|
|
|
119
172
|
async sendRefusalToTurnOnCam(e = {}) {
|
|
120
173
|
return this.sendRefusalToTurnOn("cam", { noTerminateWhenError: !0, ...e });
|
|
121
174
|
}
|
|
122
|
-
async
|
|
123
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
124
|
-
extraHeaders: [
|
|
175
|
+
async sendAvailableContentedStream() {
|
|
176
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
|
|
177
|
+
extraHeaders: [U.AVAILABLE_CONTENTED_STREAM]
|
|
125
178
|
});
|
|
126
179
|
}
|
|
127
|
-
async
|
|
128
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
129
|
-
extraHeaders: [
|
|
180
|
+
async askPermissionToStartPresentation() {
|
|
181
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
|
|
182
|
+
extraHeaders: [U.ACK_PERMISSION_TO_START_PRESENTATION]
|
|
130
183
|
});
|
|
131
184
|
}
|
|
132
185
|
async sendStoppedPresentation() {
|
|
133
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
134
|
-
extraHeaders: [
|
|
186
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
|
|
187
|
+
extraHeaders: [U.STOPPED_CLIENT_PRESENTATION]
|
|
135
188
|
});
|
|
136
189
|
}
|
|
137
|
-
async
|
|
138
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
139
|
-
extraHeaders: [
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
async askPermissionToStartPresentation() {
|
|
143
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
|
|
144
|
-
extraHeaders: [T.START_PRESENTATION]
|
|
190
|
+
async sendNotAvailableContentedStream() {
|
|
191
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
|
|
192
|
+
extraHeaders: [U.NOT_AVAILABLE_CONTENTED_STREAM]
|
|
145
193
|
});
|
|
146
194
|
}
|
|
147
195
|
async askPermissionToEnableCam(e = {}) {
|
|
148
|
-
const t = this.getEstablishedRTCSessionProtected(), s = [
|
|
149
|
-
return t.sendInfo(
|
|
196
|
+
const t = this.getEstablishedRTCSessionProtected(), s = [U.ENABLE_MAIN_CAM];
|
|
197
|
+
return t.sendInfo(_.MAIN_CAM, void 0, {
|
|
150
198
|
noTerminateWhenError: !0,
|
|
151
199
|
...e,
|
|
152
200
|
extraHeaders: s
|
|
153
201
|
}).catch((i) => {
|
|
154
|
-
if (
|
|
202
|
+
if (it(i))
|
|
155
203
|
throw i;
|
|
156
204
|
});
|
|
157
205
|
}
|
|
@@ -171,22 +219,17 @@ class tt {
|
|
|
171
219
|
this.events.off(e, t);
|
|
172
220
|
}
|
|
173
221
|
getEstablishedRTCSessionProtected = () => {
|
|
174
|
-
const e = this.callManager
|
|
222
|
+
const e = this.callManager?.getEstablishedRTCSession();
|
|
175
223
|
if (!e)
|
|
176
224
|
throw new Error("No rtcSession established");
|
|
177
225
|
return e;
|
|
178
226
|
};
|
|
179
|
-
subscribe() {
|
|
180
|
-
this.connectionManager.on("sipEvent", this.handleSipEvent), this.callManager.on("newInfo", this.handleNewInfo), this.callManager.on("newDTMF", (e) => {
|
|
181
|
-
this.events.trigger(l.NEW_DTMF, e);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
227
|
handleSipEvent = ({ request: e }) => {
|
|
185
228
|
this.maybeHandleNotify(e);
|
|
186
229
|
};
|
|
187
230
|
maybeHandleNotify = (e) => {
|
|
188
231
|
try {
|
|
189
|
-
const t = e.getHeader(
|
|
232
|
+
const t = e.getHeader(h.NOTIFY);
|
|
190
233
|
if (t) {
|
|
191
234
|
const s = JSON.parse(t);
|
|
192
235
|
this.handleNotify(s);
|
|
@@ -197,55 +240,55 @@ class tt {
|
|
|
197
240
|
};
|
|
198
241
|
handleNotify = (e) => {
|
|
199
242
|
switch (e.cmd) {
|
|
200
|
-
case
|
|
243
|
+
case I.CHANNELS: {
|
|
201
244
|
const t = e;
|
|
202
245
|
this.triggerChannelsNotify(t);
|
|
203
246
|
break;
|
|
204
247
|
}
|
|
205
|
-
case
|
|
248
|
+
case I.WEBCAST_STARTED: {
|
|
206
249
|
const t = e;
|
|
207
250
|
this.triggerWebcastStartedNotify(t);
|
|
208
251
|
break;
|
|
209
252
|
}
|
|
210
|
-
case
|
|
253
|
+
case I.WEBCAST_STOPPED: {
|
|
211
254
|
const t = e;
|
|
212
255
|
this.triggerWebcastStoppedNotify(t);
|
|
213
256
|
break;
|
|
214
257
|
}
|
|
215
|
-
case
|
|
258
|
+
case I.ADDED_TO_LIST_MODERATORS: {
|
|
216
259
|
const t = e;
|
|
217
260
|
this.triggerAddedToListModeratorsNotify(t);
|
|
218
261
|
break;
|
|
219
262
|
}
|
|
220
|
-
case
|
|
263
|
+
case I.REMOVED_FROM_LIST_MODERATORS: {
|
|
221
264
|
const t = e;
|
|
222
265
|
this.triggerRemovedFromListModeratorsNotify(t);
|
|
223
266
|
break;
|
|
224
267
|
}
|
|
225
|
-
case
|
|
268
|
+
case I.ACCEPTING_WORD_REQUEST: {
|
|
226
269
|
const t = e;
|
|
227
270
|
this.triggerParticipationAcceptingWordRequest(t);
|
|
228
271
|
break;
|
|
229
272
|
}
|
|
230
|
-
case
|
|
273
|
+
case I.CANCELLING_WORD_REQUEST: {
|
|
231
274
|
const t = e;
|
|
232
275
|
this.triggerParticipationCancellingWordRequest(t);
|
|
233
276
|
break;
|
|
234
277
|
}
|
|
235
|
-
case
|
|
278
|
+
case I.MOVE_REQUEST_TO_STREAM: {
|
|
236
279
|
const t = e;
|
|
237
280
|
this.triggerParticipantMoveRequestToStream(t);
|
|
238
281
|
break;
|
|
239
282
|
}
|
|
240
|
-
case
|
|
283
|
+
case I.ACCOUNT_CHANGED: {
|
|
241
284
|
this.triggerAccountChangedNotify();
|
|
242
285
|
break;
|
|
243
286
|
}
|
|
244
|
-
case
|
|
287
|
+
case I.ACCOUNT_DELETED: {
|
|
245
288
|
this.triggerAccountDeletedNotify();
|
|
246
289
|
break;
|
|
247
290
|
}
|
|
248
|
-
case
|
|
291
|
+
case I.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
|
|
249
292
|
const t = e;
|
|
250
293
|
this.triggerConferenceParticipantTokenIssued(t);
|
|
251
294
|
break;
|
|
@@ -258,34 +301,34 @@ class tt {
|
|
|
258
301
|
const { originator: t } = e;
|
|
259
302
|
if (t !== "remote")
|
|
260
303
|
return;
|
|
261
|
-
const { request: s } = e, i = s, r = i.
|
|
304
|
+
const { request: s } = e, i = s, r = N(i, h.CONTENT_TYPE);
|
|
262
305
|
if (r !== void 0)
|
|
263
306
|
switch (r) {
|
|
264
|
-
case
|
|
307
|
+
case y.ENTER_ROOM: {
|
|
265
308
|
this.triggerEnterRoom(i), this.maybeTriggerChannels(i);
|
|
266
309
|
break;
|
|
267
310
|
}
|
|
268
|
-
case
|
|
311
|
+
case y.NOTIFY: {
|
|
269
312
|
this.maybeHandleNotify(i);
|
|
270
313
|
break;
|
|
271
314
|
}
|
|
272
|
-
case
|
|
273
|
-
this.
|
|
315
|
+
case y.SHARE_STATE: {
|
|
316
|
+
this.triggerContentedStreamState(i);
|
|
274
317
|
break;
|
|
275
318
|
}
|
|
276
|
-
case
|
|
319
|
+
case y.MAIN_CAM: {
|
|
277
320
|
this.triggerMainCamControl(i);
|
|
278
321
|
break;
|
|
279
322
|
}
|
|
280
|
-
case
|
|
323
|
+
case y.MIC: {
|
|
281
324
|
this.triggerMicControl(i);
|
|
282
325
|
break;
|
|
283
326
|
}
|
|
284
|
-
case
|
|
327
|
+
case y.USE_LICENSE: {
|
|
285
328
|
this.triggerUseLicense(i);
|
|
286
329
|
break;
|
|
287
330
|
}
|
|
288
|
-
case
|
|
331
|
+
case y.PARTICIPANT_STATE: {
|
|
289
332
|
this.maybeTriggerParticipantMoveRequest(i);
|
|
290
333
|
break;
|
|
291
334
|
}
|
|
@@ -296,7 +339,7 @@ class tt {
|
|
|
296
339
|
inputChannels: t,
|
|
297
340
|
outputChannels: s
|
|
298
341
|
};
|
|
299
|
-
this.events.trigger(
|
|
342
|
+
this.events.trigger(g.CHANNELS_NOTIFY, i);
|
|
300
343
|
};
|
|
301
344
|
triggerWebcastStartedNotify = ({
|
|
302
345
|
body: { conference: e, type: t }
|
|
@@ -305,7 +348,7 @@ class tt {
|
|
|
305
348
|
conference: e,
|
|
306
349
|
type: t
|
|
307
350
|
};
|
|
308
|
-
this.events.trigger(
|
|
351
|
+
this.events.trigger(g.WEBCAST_STARTED, s);
|
|
309
352
|
};
|
|
310
353
|
triggerWebcastStoppedNotify = ({
|
|
311
354
|
body: { conference: e, type: t }
|
|
@@ -314,7 +357,7 @@ class tt {
|
|
|
314
357
|
conference: e,
|
|
315
358
|
type: t
|
|
316
359
|
};
|
|
317
|
-
this.events.trigger(
|
|
360
|
+
this.events.trigger(g.WEBCAST_STOPPED, s);
|
|
318
361
|
};
|
|
319
362
|
triggerAddedToListModeratorsNotify = ({
|
|
320
363
|
conference: e
|
|
@@ -323,7 +366,7 @@ class tt {
|
|
|
323
366
|
conference: e
|
|
324
367
|
};
|
|
325
368
|
this.events.trigger(
|
|
326
|
-
|
|
369
|
+
g.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
|
|
327
370
|
t
|
|
328
371
|
);
|
|
329
372
|
};
|
|
@@ -334,7 +377,7 @@ class tt {
|
|
|
334
377
|
conference: e
|
|
335
378
|
};
|
|
336
379
|
this.events.trigger(
|
|
337
|
-
|
|
380
|
+
g.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
|
|
338
381
|
t
|
|
339
382
|
);
|
|
340
383
|
};
|
|
@@ -344,7 +387,7 @@ class tt {
|
|
|
344
387
|
const t = {
|
|
345
388
|
conference: e
|
|
346
389
|
};
|
|
347
|
-
this.events.trigger(
|
|
390
|
+
this.events.trigger(g.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
|
|
348
391
|
};
|
|
349
392
|
triggerParticipationCancellingWordRequest = ({
|
|
350
393
|
body: { conference: e }
|
|
@@ -352,7 +395,7 @@ class tt {
|
|
|
352
395
|
const t = {
|
|
353
396
|
conference: e
|
|
354
397
|
};
|
|
355
|
-
this.events.trigger(
|
|
398
|
+
this.events.trigger(g.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
|
|
356
399
|
};
|
|
357
400
|
triggerParticipantMoveRequestToStream = ({
|
|
358
401
|
body: { conference: e }
|
|
@@ -360,13 +403,13 @@ class tt {
|
|
|
360
403
|
const t = {
|
|
361
404
|
conference: e
|
|
362
405
|
};
|
|
363
|
-
this.events.trigger(
|
|
406
|
+
this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
|
|
364
407
|
};
|
|
365
408
|
triggerAccountChangedNotify = () => {
|
|
366
|
-
this.events.trigger(
|
|
409
|
+
this.events.trigger(g.ACCOUNT_CHANGED, {});
|
|
367
410
|
};
|
|
368
411
|
triggerAccountDeletedNotify = () => {
|
|
369
|
-
this.events.trigger(
|
|
412
|
+
this.events.trigger(g.ACCOUNT_DELETED, {});
|
|
370
413
|
};
|
|
371
414
|
triggerConferenceParticipantTokenIssued = ({
|
|
372
415
|
body: { conference: e, participant: t, jwt: s }
|
|
@@ -377,82 +420,91 @@ class tt {
|
|
|
377
420
|
jwt: s
|
|
378
421
|
};
|
|
379
422
|
this.events.trigger(
|
|
380
|
-
|
|
423
|
+
g.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
|
|
381
424
|
i
|
|
382
425
|
);
|
|
383
426
|
};
|
|
384
427
|
maybeTriggerChannels = (e) => {
|
|
385
|
-
const t = e.
|
|
386
|
-
if (t && s) {
|
|
428
|
+
const t = N(e, h.INPUT_CHANNELS), s = N(e, h.OUTPUT_CHANNELS);
|
|
429
|
+
if (t !== void 0 && s !== void 0) {
|
|
387
430
|
const i = {
|
|
388
431
|
inputChannels: t,
|
|
389
432
|
outputChannels: s
|
|
390
433
|
};
|
|
391
|
-
this.events.trigger(
|
|
434
|
+
this.events.trigger(g.CHANNELS_ALL, i);
|
|
392
435
|
}
|
|
393
436
|
};
|
|
394
437
|
triggerEnterRoom = (e) => {
|
|
395
|
-
const t = e.
|
|
396
|
-
this.events.trigger(
|
|
438
|
+
const t = N(e, h.CONTENT_ENTER_ROOM), s = N(e, h.PARTICIPANT_NAME);
|
|
439
|
+
t !== void 0 && this.events.trigger(g.ENTER_ROOM, { room: t, participantName: s });
|
|
397
440
|
};
|
|
398
|
-
|
|
399
|
-
const t = e.
|
|
441
|
+
triggerContentedStreamState = (e) => {
|
|
442
|
+
const t = N(e, h.CONTENTED_STREAM_STATE);
|
|
400
443
|
if (t !== void 0)
|
|
401
444
|
switch (t) {
|
|
402
|
-
case
|
|
403
|
-
|
|
445
|
+
case $.AVAILABLE_CONTENTED_STREAM: {
|
|
446
|
+
const s = N(e, h.CONTENTED_STREAM_CODEC);
|
|
447
|
+
this.events.trigger(g.CONTENTED_STREAM_AVAILABLE, { codec: s });
|
|
404
448
|
break;
|
|
405
449
|
}
|
|
406
|
-
case
|
|
407
|
-
this.events.trigger(
|
|
450
|
+
case $.NOT_AVAILABLE_CONTENTED_STREAM: {
|
|
451
|
+
this.events.trigger(g.CONTENTED_STREAM_NOT_AVAILABLE, {});
|
|
408
452
|
break;
|
|
409
453
|
}
|
|
410
|
-
case
|
|
411
|
-
this.events.trigger(
|
|
454
|
+
case $.MUST_STOP_PRESENTATION: {
|
|
455
|
+
this.events.trigger(g.PRESENTATION_MUST_STOP, {});
|
|
412
456
|
break;
|
|
413
457
|
}
|
|
414
458
|
}
|
|
415
459
|
};
|
|
416
460
|
maybeTriggerParticipantMoveRequest = (e) => {
|
|
417
|
-
const t = e.
|
|
418
|
-
t ===
|
|
461
|
+
const t = N(e, h.CONTENT_PARTICIPANT_STATE), s = N(e, h.AUDIO_ID);
|
|
462
|
+
t === W.SPECTATOR && (s === void 0 ? (this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC, {}), this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, { isSynthetic: !0 })) : (this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID, {
|
|
419
463
|
audioId: s
|
|
420
|
-
}), this.events.trigger(
|
|
464
|
+
}), this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, {
|
|
421
465
|
isSynthetic: !1,
|
|
422
466
|
audioId: s
|
|
423
|
-
}))
|
|
467
|
+
}))), t === W.PARTICIPANT && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, {});
|
|
424
468
|
};
|
|
425
469
|
triggerMainCamControl = (e) => {
|
|
426
|
-
const t = e.
|
|
427
|
-
if (t ===
|
|
428
|
-
this.events.trigger(
|
|
470
|
+
const t = N(e, h.MAIN_CAM), s = N(e, h.MEDIA_SYNC), i = s === Q.ADMIN_SYNC_FORCED;
|
|
471
|
+
if (t === f.ADMIN_START_MAIN_CAM) {
|
|
472
|
+
this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: i });
|
|
429
473
|
return;
|
|
430
474
|
}
|
|
431
|
-
if (t ===
|
|
432
|
-
this.events.trigger(
|
|
475
|
+
if (t === f.ADMIN_STOP_MAIN_CAM) {
|
|
476
|
+
this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
|
|
433
477
|
return;
|
|
434
478
|
}
|
|
435
|
-
(t ===
|
|
436
|
-
const r = e.
|
|
437
|
-
this.events.trigger(
|
|
479
|
+
(t === f.RESUME_MAIN_CAM || t === f.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
|
|
480
|
+
const r = N(e, h.MAIN_CAM_RESOLUTION);
|
|
481
|
+
this.events.trigger(g.MAIN_CAM_CONTROL, {
|
|
438
482
|
mainCam: t,
|
|
439
483
|
resolutionMainCam: r
|
|
440
484
|
});
|
|
441
485
|
};
|
|
442
486
|
triggerMicControl = (e) => {
|
|
443
|
-
const t = e.
|
|
444
|
-
t ===
|
|
487
|
+
const t = N(e, h.MIC), i = N(e, h.MEDIA_SYNC) === Q.ADMIN_SYNC_FORCED;
|
|
488
|
+
t === x.ADMIN_START_MIC ? this.events.trigger(g.ADMIN_START_MIC, { isSyncForced: i }) : t === x.ADMIN_STOP_MIC && this.events.trigger(g.ADMIN_STOP_MIC, { isSyncForced: i });
|
|
445
489
|
};
|
|
446
490
|
triggerUseLicense = (e) => {
|
|
447
|
-
const t = e.
|
|
448
|
-
this.events.trigger(
|
|
491
|
+
const t = N(e, h.CONTENT_USE_LICENSE);
|
|
492
|
+
t !== void 0 && this.events.trigger(g.USE_LICENSE, t);
|
|
449
493
|
};
|
|
450
494
|
}
|
|
451
|
-
class
|
|
495
|
+
class V {
|
|
452
496
|
actor;
|
|
453
497
|
subscriptions = [];
|
|
498
|
+
stateChangeListeners = /* @__PURE__ */ new Set();
|
|
454
499
|
constructor(e) {
|
|
455
|
-
this.actor =
|
|
500
|
+
this.actor = Ke(e), this.actor.start(), this.addSubscription(
|
|
501
|
+
this.subscribe((t) => {
|
|
502
|
+
const s = t.value;
|
|
503
|
+
this.stateChangeListeners.forEach((i) => {
|
|
504
|
+
i(s);
|
|
505
|
+
});
|
|
506
|
+
})
|
|
507
|
+
);
|
|
456
508
|
}
|
|
457
509
|
get actorRef() {
|
|
458
510
|
return this.actor;
|
|
@@ -470,8 +522,13 @@ class q {
|
|
|
470
522
|
const t = this.actor.subscribe(e);
|
|
471
523
|
return this.addSubscription(t), t;
|
|
472
524
|
}
|
|
525
|
+
onStateChange(e) {
|
|
526
|
+
return this.stateChangeListeners.add(e), () => {
|
|
527
|
+
this.stateChangeListeners.delete(e);
|
|
528
|
+
};
|
|
529
|
+
}
|
|
473
530
|
stop() {
|
|
474
|
-
this.subscriptions.forEach((e) => {
|
|
531
|
+
this.stateChangeListeners.clear(), this.subscriptions.forEach((e) => {
|
|
475
532
|
e();
|
|
476
533
|
}), this.subscriptions.length = 0, this.actor.stop();
|
|
477
534
|
}
|
|
@@ -482,17 +539,17 @@ class q {
|
|
|
482
539
|
return this.subscriptions.push(t), t;
|
|
483
540
|
}
|
|
484
541
|
}
|
|
485
|
-
var
|
|
486
|
-
const
|
|
542
|
+
var ht = /* @__PURE__ */ ((n) => (n.IDLE = "call:idle", n.CONNECTING = "call:connecting", n.ACCEPTED = "call:accepted", n.IN_CALL = "call:inCall", n.ENDED = "call:ended", n.FAILED = "call:failed", n))(ht || {});
|
|
543
|
+
const lt = G({
|
|
487
544
|
types: {
|
|
488
545
|
context: {},
|
|
489
546
|
events: {}
|
|
490
547
|
},
|
|
491
548
|
actions: {
|
|
492
|
-
rememberError:
|
|
549
|
+
rememberError: M(({ event: n }) => "error" in n && n.error !== void 0 ? {
|
|
493
550
|
lastError: n.error instanceof Error ? n.error : new Error(JSON.stringify(n.error))
|
|
494
551
|
} : { lastError: void 0 }),
|
|
495
|
-
resetError:
|
|
552
|
+
resetError: M({ lastError: void 0 })
|
|
496
553
|
}
|
|
497
554
|
}).createMachine({
|
|
498
555
|
id: "call",
|
|
@@ -566,9 +623,9 @@ const st = $({
|
|
|
566
623
|
}
|
|
567
624
|
}
|
|
568
625
|
});
|
|
569
|
-
class
|
|
626
|
+
class gt extends V {
|
|
570
627
|
constructor(e) {
|
|
571
|
-
super(
|
|
628
|
+
super(lt), this.subscribeToEvents(e);
|
|
572
629
|
}
|
|
573
630
|
get isIdle() {
|
|
574
631
|
return this.state === "call:idle";
|
|
@@ -633,8 +690,8 @@ class it extends q {
|
|
|
633
690
|
);
|
|
634
691
|
}
|
|
635
692
|
}
|
|
636
|
-
var S = /* @__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.REMOTE_TRACKS_CHANGED = "remote-tracks-changed", n.REMOTE_STREAMS_CHANGED = "remote-streams-changed", n))(S || {}),
|
|
637
|
-
const
|
|
693
|
+
var S = /* @__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.REMOTE_TRACKS_CHANGED = "remote-tracks-changed", n.REMOTE_STREAMS_CHANGED = "remote-streams-changed", n))(S || {}), ut = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(ut || {});
|
|
694
|
+
const me = [
|
|
638
695
|
"peerconnection",
|
|
639
696
|
"connecting",
|
|
640
697
|
"sending",
|
|
@@ -665,21 +722,21 @@ const ue = [
|
|
|
665
722
|
"peerconnection:createanswerfailed",
|
|
666
723
|
"peerconnection:setlocaldescriptionfailed",
|
|
667
724
|
"peerconnection:setremotedescriptionfailed"
|
|
668
|
-
],
|
|
725
|
+
], Tt = [
|
|
669
726
|
"peerconnection:confirmed",
|
|
670
727
|
"peerconnection:ontrack",
|
|
671
728
|
"ended:fromserver",
|
|
672
729
|
"call-status-changed",
|
|
673
730
|
"remote-tracks-changed",
|
|
674
731
|
"remote-streams-changed"
|
|
675
|
-
],
|
|
676
|
-
...
|
|
677
|
-
...
|
|
678
|
-
],
|
|
732
|
+
], Ne = [
|
|
733
|
+
...me,
|
|
734
|
+
...Tt
|
|
735
|
+
], Et = () => new R(Ne), St = (n, e) => {
|
|
679
736
|
n.getVideoTracks().forEach((s) => {
|
|
680
737
|
"contentHint" in s && s.contentHint !== e && (s.contentHint = e);
|
|
681
738
|
});
|
|
682
|
-
},
|
|
739
|
+
}, H = (n, {
|
|
683
740
|
directionVideo: e,
|
|
684
741
|
directionAudio: t,
|
|
685
742
|
contentHint: s
|
|
@@ -687,10 +744,10 @@ const ue = [
|
|
|
687
744
|
if (!n || e === "recvonly" && t === "recvonly")
|
|
688
745
|
return;
|
|
689
746
|
const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
|
|
690
|
-
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" &&
|
|
747
|
+
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && St(o, s), o;
|
|
691
748
|
};
|
|
692
|
-
var
|
|
693
|
-
class
|
|
749
|
+
var Ae = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(Ae || {});
|
|
750
|
+
class Ct {
|
|
694
751
|
events;
|
|
695
752
|
rtcSession;
|
|
696
753
|
disposers = /* @__PURE__ */ new Set();
|
|
@@ -717,27 +774,27 @@ class dt {
|
|
|
717
774
|
iceServers: a,
|
|
718
775
|
directionVideo: o,
|
|
719
776
|
directionAudio: c,
|
|
720
|
-
contentHint:
|
|
721
|
-
offerToReceiveAudio:
|
|
722
|
-
offerToReceiveVideo:
|
|
777
|
+
contentHint: l,
|
|
778
|
+
offerToReceiveAudio: T = !0,
|
|
779
|
+
offerToReceiveVideo: u = !0,
|
|
723
780
|
degradationPreference: E,
|
|
724
781
|
sendEncodings: m,
|
|
725
|
-
onAddedTransceiver:
|
|
726
|
-
}) => new Promise((
|
|
727
|
-
this.handleCall().then(
|
|
728
|
-
|
|
782
|
+
onAddedTransceiver: D
|
|
783
|
+
}) => new Promise((A, w) => {
|
|
784
|
+
this.handleCall().then(A).catch((X) => {
|
|
785
|
+
w(X);
|
|
729
786
|
}), this.rtcSession = e.call(t(s), {
|
|
730
|
-
mediaStream:
|
|
787
|
+
mediaStream: H(i, {
|
|
731
788
|
directionVideo: o,
|
|
732
789
|
directionAudio: c,
|
|
733
|
-
contentHint:
|
|
790
|
+
contentHint: l
|
|
734
791
|
}),
|
|
735
792
|
pcConfig: {
|
|
736
793
|
iceServers: a
|
|
737
794
|
},
|
|
738
795
|
rtcOfferConstraints: {
|
|
739
|
-
offerToReceiveAudio:
|
|
740
|
-
offerToReceiveVideo:
|
|
796
|
+
offerToReceiveAudio: T,
|
|
797
|
+
offerToReceiveVideo: u
|
|
741
798
|
},
|
|
742
799
|
// необходимо передавать в методе call, чтобы подписаться на события peerconnection,
|
|
743
800
|
// так как в методе call создается RTCSession
|
|
@@ -748,14 +805,14 @@ class dt {
|
|
|
748
805
|
directionAudio: c,
|
|
749
806
|
degradationPreference: E,
|
|
750
807
|
sendEncodings: m,
|
|
751
|
-
onAddedTransceiver:
|
|
808
|
+
onAddedTransceiver: D
|
|
752
809
|
});
|
|
753
810
|
});
|
|
754
811
|
async endCall() {
|
|
755
812
|
const { rtcSession: e } = this;
|
|
756
813
|
if (e && !e.isEnded())
|
|
757
814
|
return e.terminateAsync({
|
|
758
|
-
cause:
|
|
815
|
+
cause: Ae.CANCELED
|
|
759
816
|
}).finally(() => {
|
|
760
817
|
this.reset();
|
|
761
818
|
});
|
|
@@ -769,14 +826,14 @@ class dt {
|
|
|
769
826
|
directionAudio: a,
|
|
770
827
|
offerToReceiveAudio: o,
|
|
771
828
|
offerToReceiveVideo: c,
|
|
772
|
-
contentHint:
|
|
773
|
-
degradationPreference:
|
|
774
|
-
sendEncodings:
|
|
829
|
+
contentHint: l,
|
|
830
|
+
degradationPreference: T,
|
|
831
|
+
sendEncodings: u,
|
|
775
832
|
onAddedTransceiver: E
|
|
776
|
-
}) => new Promise((m,
|
|
833
|
+
}) => new Promise((m, D) => {
|
|
777
834
|
try {
|
|
778
|
-
this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall().then(m).catch((
|
|
779
|
-
|
|
835
|
+
this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall().then(m).catch((A) => {
|
|
836
|
+
D(A);
|
|
780
837
|
}), e.answer({
|
|
781
838
|
pcConfig: {
|
|
782
839
|
iceServers: i
|
|
@@ -785,26 +842,26 @@ class dt {
|
|
|
785
842
|
offerToReceiveAudio: o,
|
|
786
843
|
offerToReceiveVideo: c
|
|
787
844
|
},
|
|
788
|
-
mediaStream:
|
|
845
|
+
mediaStream: H(t, {
|
|
789
846
|
directionVideo: r,
|
|
790
847
|
directionAudio: a,
|
|
791
|
-
contentHint:
|
|
848
|
+
contentHint: l
|
|
792
849
|
}),
|
|
793
850
|
extraHeaders: s,
|
|
794
851
|
directionVideo: r,
|
|
795
852
|
directionAudio: a,
|
|
796
|
-
degradationPreference:
|
|
797
|
-
sendEncodings:
|
|
853
|
+
degradationPreference: T,
|
|
854
|
+
sendEncodings: u,
|
|
798
855
|
onAddedTransceiver: E
|
|
799
856
|
});
|
|
800
|
-
} catch (
|
|
801
|
-
|
|
857
|
+
} catch (A) {
|
|
858
|
+
D(A);
|
|
802
859
|
}
|
|
803
860
|
});
|
|
804
861
|
async replaceMediaStream(e, t) {
|
|
805
862
|
if (!this.rtcSession)
|
|
806
863
|
throw new Error("No rtcSession established");
|
|
807
|
-
const { contentHint: s } = t ?? {}, i =
|
|
864
|
+
const { contentHint: s } = t ?? {}, i = H(e, { contentHint: s });
|
|
808
865
|
if (i === void 0)
|
|
809
866
|
throw new Error("No preparedMediaStream");
|
|
810
867
|
return this.rtcSession.replaceMediaStream(i, t);
|
|
@@ -816,33 +873,33 @@ class dt {
|
|
|
816
873
|
}
|
|
817
874
|
handleCall = async () => new Promise((e, t) => {
|
|
818
875
|
const s = () => {
|
|
819
|
-
this.events.on(S.PEER_CONNECTION,
|
|
876
|
+
this.events.on(S.PEER_CONNECTION, l), this.events.on(S.CONFIRMED, T);
|
|
820
877
|
}, i = () => {
|
|
821
|
-
this.events.off(S.PEER_CONNECTION,
|
|
878
|
+
this.events.off(S.PEER_CONNECTION, l), this.events.off(S.CONFIRMED, T);
|
|
822
879
|
}, r = () => {
|
|
823
880
|
this.events.on(S.FAILED, o), this.events.on(S.ENDED, o);
|
|
824
881
|
}, a = () => {
|
|
825
882
|
this.events.off(S.FAILED, o), this.events.off(S.ENDED, o);
|
|
826
|
-
}, o = (
|
|
827
|
-
i(), a(), t(
|
|
883
|
+
}, o = (u) => {
|
|
884
|
+
i(), a(), t(u);
|
|
828
885
|
};
|
|
829
886
|
let c;
|
|
830
|
-
const
|
|
831
|
-
c =
|
|
887
|
+
const l = ({ peerconnection: u }) => {
|
|
888
|
+
c = u;
|
|
832
889
|
const E = (m) => {
|
|
833
890
|
this.events.trigger(S.PEER_CONNECTION_ONTRACK, m);
|
|
834
891
|
};
|
|
835
|
-
|
|
836
|
-
|
|
892
|
+
u.addEventListener("track", E), this.disposers.add(() => {
|
|
893
|
+
u.removeEventListener("track", E);
|
|
837
894
|
});
|
|
838
|
-
},
|
|
895
|
+
}, T = () => {
|
|
839
896
|
c !== void 0 && this.events.trigger(S.PEER_CONNECTION_CONFIRMED, c), i(), a(), e(c);
|
|
840
897
|
};
|
|
841
898
|
s(), r();
|
|
842
899
|
});
|
|
843
900
|
subscribeToSessionEvents(e) {
|
|
844
901
|
this.events.eachTriggers((t, s) => {
|
|
845
|
-
const i =
|
|
902
|
+
const i = me.find((r) => r === s);
|
|
846
903
|
i && (e.on(i, t), this.disposers.add(() => {
|
|
847
904
|
e.off(i, t);
|
|
848
905
|
}));
|
|
@@ -861,7 +918,7 @@ class dt {
|
|
|
861
918
|
delete this.rtcSession, this.unsubscribeFromSessionEvents(), this.onReset();
|
|
862
919
|
};
|
|
863
920
|
}
|
|
864
|
-
class
|
|
921
|
+
class pt {
|
|
865
922
|
config;
|
|
866
923
|
tools;
|
|
867
924
|
connection;
|
|
@@ -878,11 +935,15 @@ class ht {
|
|
|
878
935
|
this.connection.close();
|
|
879
936
|
}
|
|
880
937
|
async call(e) {
|
|
881
|
-
const t = this.waitForTracks()
|
|
938
|
+
const t = this.waitForTracks();
|
|
939
|
+
await this.renegotiate(e), await t;
|
|
940
|
+
}
|
|
941
|
+
async renegotiate(e) {
|
|
942
|
+
const t = await this.createOffer(), s = await this.tools.sendOffer(
|
|
882
943
|
{ conferenceNumber: e, quality: this.config.quality, audioChannel: this.config.audioChannel },
|
|
883
|
-
|
|
944
|
+
t
|
|
884
945
|
);
|
|
885
|
-
await this.setRemoteDescription(
|
|
946
|
+
return await this.setRemoteDescription(s), !0;
|
|
886
947
|
}
|
|
887
948
|
async createOffer() {
|
|
888
949
|
const e = await this.connection.createOffer();
|
|
@@ -910,18 +971,18 @@ class ht {
|
|
|
910
971
|
return this.connection.addTransceiver(e, t);
|
|
911
972
|
}
|
|
912
973
|
}
|
|
913
|
-
const
|
|
914
|
-
const t =
|
|
974
|
+
const Re = (n) => n.getSettings(), mt = (n, e) => {
|
|
975
|
+
const t = Re(n);
|
|
915
976
|
let s = e;
|
|
916
977
|
s ??= n.label;
|
|
917
978
|
let i = t?.msid;
|
|
918
979
|
return i ??= s, i ??= n.id, i;
|
|
919
|
-
},
|
|
920
|
-
const t =
|
|
980
|
+
}, Nt = (n, e) => {
|
|
981
|
+
const t = Re(n);
|
|
921
982
|
let s = e;
|
|
922
983
|
return s ??= t?.msid, s ??= n.label, (s && s.length > 0 ? s : void 0) ?? n.id;
|
|
923
984
|
};
|
|
924
|
-
class
|
|
985
|
+
class se {
|
|
925
986
|
participantGroups = /* @__PURE__ */ new Map();
|
|
926
987
|
trackToGroup = /* @__PURE__ */ new Map();
|
|
927
988
|
trackDisposers = /* @__PURE__ */ new Map();
|
|
@@ -938,28 +999,28 @@ class Z {
|
|
|
938
999
|
onRemoved: t,
|
|
939
1000
|
streamHint: s
|
|
940
1001
|
} = {}) {
|
|
941
|
-
const i =
|
|
1002
|
+
const i = Nt(e, s), r = mt(e, s);
|
|
942
1003
|
if (this.trackToGroup.has(e.id))
|
|
943
1004
|
return { isAddedTrack: !1, isAddedStream: !1 };
|
|
944
1005
|
const a = this.getParticipantGroups(i), o = a.get(r), c = !o;
|
|
945
|
-
let
|
|
946
|
-
|
|
1006
|
+
let l = o;
|
|
1007
|
+
l || (l = {
|
|
947
1008
|
participantId: i,
|
|
948
1009
|
groupId: r,
|
|
949
1010
|
stream: new MediaStream(),
|
|
950
1011
|
trackIds: /* @__PURE__ */ new Set()
|
|
951
|
-
}, a.set(r,
|
|
952
|
-
const
|
|
1012
|
+
}, a.set(r, l)), l.stream.addTrack(e), l.trackIds.add(e.id), this.trackToGroup.set(e.id, { participantId: i, groupId: r });
|
|
1013
|
+
const T = () => {
|
|
953
1014
|
this.disposeTrackListener(e.id);
|
|
954
|
-
const
|
|
955
|
-
|
|
1015
|
+
const u = this.removeTrack(e.id);
|
|
1016
|
+
u.isRemovedTrack && t?.({
|
|
956
1017
|
participantId: i,
|
|
957
1018
|
trackId: e.id,
|
|
958
|
-
isRemovedStream:
|
|
1019
|
+
isRemovedStream: u.isRemovedStream
|
|
959
1020
|
});
|
|
960
1021
|
};
|
|
961
|
-
return e.addEventListener("ended",
|
|
962
|
-
e.removeEventListener("ended",
|
|
1022
|
+
return e.addEventListener("ended", T), this.trackDisposers.set(e.id, () => {
|
|
1023
|
+
e.removeEventListener("ended", T);
|
|
963
1024
|
}), { isAddedTrack: !0, isAddedStream: c, participantId: i };
|
|
964
1025
|
}
|
|
965
1026
|
removeTrack(e) {
|
|
@@ -970,7 +1031,7 @@ class Z {
|
|
|
970
1031
|
const { participantId: s, groupId: i } = t, r = this.participantGroups.get(s), a = r?.get(i);
|
|
971
1032
|
if (!a)
|
|
972
1033
|
return this.trackToGroup.delete(e), { isRemovedTrack: !1, isRemovedStream: !1 };
|
|
973
|
-
const o = a.stream.getTracks().find((
|
|
1034
|
+
const o = a.stream.getTracks().find((l) => l.id === e);
|
|
974
1035
|
o && a.stream.removeTrack(o), a.trackIds.delete(e), this.trackToGroup.delete(e);
|
|
975
1036
|
const c = a.trackIds.size === 0;
|
|
976
1037
|
return c && (r?.delete(i), r?.size === 0 && this.participantGroups.delete(s)), { isRemovedTrack: !0, isRemovedStream: c };
|
|
@@ -982,8 +1043,8 @@ class Z {
|
|
|
982
1043
|
let i = !1;
|
|
983
1044
|
return [...s.values()].forEach((a) => {
|
|
984
1045
|
[...a.trackIds].filter((c) => !t.includes(c)).forEach((c) => {
|
|
985
|
-
const
|
|
986
|
-
i ||=
|
|
1046
|
+
const l = this.removeTrack(c);
|
|
1047
|
+
i ||= l.isRemovedTrack;
|
|
987
1048
|
});
|
|
988
1049
|
}), i;
|
|
989
1050
|
}
|
|
@@ -1006,16 +1067,16 @@ class Z {
|
|
|
1006
1067
|
return this.participantGroups.set(e, s), s;
|
|
1007
1068
|
}
|
|
1008
1069
|
}
|
|
1009
|
-
const
|
|
1070
|
+
const J = {
|
|
1010
1071
|
type: "participant"
|
|
1011
|
-
},
|
|
1072
|
+
}, At = {
|
|
1012
1073
|
type: "spectator_synthetic"
|
|
1013
|
-
},
|
|
1074
|
+
}, Rt = (n) => ({
|
|
1014
1075
|
type: "spectator",
|
|
1015
1076
|
recvParams: n
|
|
1016
1077
|
});
|
|
1017
|
-
class
|
|
1018
|
-
role =
|
|
1078
|
+
class O {
|
|
1079
|
+
role = J;
|
|
1019
1080
|
onRoleChanged;
|
|
1020
1081
|
constructor(e) {
|
|
1021
1082
|
this.onRoleChanged = e;
|
|
@@ -1033,13 +1094,13 @@ class _ {
|
|
|
1033
1094
|
return this.role;
|
|
1034
1095
|
}
|
|
1035
1096
|
setCallRoleParticipant() {
|
|
1036
|
-
this.changeRole(
|
|
1097
|
+
this.changeRole(J);
|
|
1037
1098
|
}
|
|
1038
1099
|
setCallRoleSpectatorSynthetic() {
|
|
1039
|
-
this.changeRole(
|
|
1100
|
+
this.changeRole(At);
|
|
1040
1101
|
}
|
|
1041
1102
|
setCallRoleSpectator(e) {
|
|
1042
|
-
this.changeRole(
|
|
1103
|
+
this.changeRole(Rt(e));
|
|
1043
1104
|
}
|
|
1044
1105
|
changeRole(e) {
|
|
1045
1106
|
const t = this.role;
|
|
@@ -1047,69 +1108,126 @@ class _ {
|
|
|
1047
1108
|
this.setRole(e);
|
|
1048
1109
|
return;
|
|
1049
1110
|
}
|
|
1050
|
-
|
|
1111
|
+
O.hasSpectator(e) && O.hasSpectator(t) && t.recvParams.audioId !== e.recvParams.audioId && this.setRole(e);
|
|
1051
1112
|
}
|
|
1052
1113
|
reset() {
|
|
1053
|
-
this.role =
|
|
1114
|
+
this.role = J;
|
|
1054
1115
|
}
|
|
1055
1116
|
hasParticipant() {
|
|
1056
|
-
return
|
|
1117
|
+
return O.hasParticipant(this.role);
|
|
1057
1118
|
}
|
|
1058
1119
|
hasSpectatorSynthetic() {
|
|
1059
|
-
return
|
|
1120
|
+
return O.hasSpectatorSynthetic(this.role);
|
|
1060
1121
|
}
|
|
1061
1122
|
hasSpectator() {
|
|
1062
|
-
return
|
|
1123
|
+
return O.hasSpectator(this.role);
|
|
1063
1124
|
}
|
|
1064
1125
|
setRole(e) {
|
|
1065
1126
|
const t = this.role;
|
|
1066
1127
|
this.role = e, this.onRoleChanged?.({ previous: t, next: e });
|
|
1067
1128
|
}
|
|
1068
1129
|
}
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1130
|
+
const It = (n, e) => {
|
|
1131
|
+
if (!n || !e)
|
|
1132
|
+
return n === e;
|
|
1133
|
+
const t = n.mainStream?.id, s = e.mainStream?.id, i = n.contentedStream?.id, r = e.contentedStream?.id;
|
|
1134
|
+
return t === s && i === r;
|
|
1135
|
+
};
|
|
1136
|
+
class vt {
|
|
1137
|
+
lastEmittedStreams;
|
|
1138
|
+
/**
|
|
1139
|
+
* Проверяет, изменились ли streams с последнего сохраненного состояния
|
|
1140
|
+
* @param streams - Текущие streams для проверки
|
|
1141
|
+
* @returns true, если streams изменились
|
|
1142
|
+
*/
|
|
1143
|
+
hasChanged(e) {
|
|
1144
|
+
return !It(this.lastEmittedStreams, e);
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* Сохраняет текущие streams как последнее эмитнутое состояние
|
|
1148
|
+
* @param streams - Streams для сохранения
|
|
1149
|
+
*/
|
|
1150
|
+
updateLastEmittedStreams(e) {
|
|
1151
|
+
this.lastEmittedStreams = e;
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Получает последние эмитнутые streams
|
|
1155
|
+
* @returns Последние сохраненные streams или undefined
|
|
1156
|
+
*/
|
|
1157
|
+
getLastEmittedStreams() {
|
|
1158
|
+
return this.lastEmittedStreams;
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Сбрасывает состояние трекера
|
|
1162
|
+
*/
|
|
1163
|
+
reset() {
|
|
1164
|
+
this.lastEmittedStreams = void 0;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
const ft = "default", Mt = "dual", _t = "content_", bt = (n) => `${_t}${n.toLowerCase()}`, ie = (n) => [...n.getTracks()].some((e) => e.label.includes(Mt));
|
|
1168
|
+
class Ot {
|
|
1071
1169
|
mainRemoteStreamsManager;
|
|
1072
1170
|
recvRemoteStreamsManager;
|
|
1073
1171
|
constructor(e, t) {
|
|
1074
1172
|
this.mainRemoteStreamsManager = e, this.recvRemoteStreamsManager = t;
|
|
1075
1173
|
}
|
|
1076
|
-
getActiveStreamsManagerTools(
|
|
1077
|
-
|
|
1174
|
+
getActiveStreamsManagerTools({
|
|
1175
|
+
isSpectator: e,
|
|
1176
|
+
stateInfo: t
|
|
1177
|
+
}) {
|
|
1178
|
+
return e ? this.getRecvRemoteStreamsManagerTools({ stateInfo: t }) : this.getMainRemoteStreamsManagerTools({ stateInfo: t });
|
|
1179
|
+
}
|
|
1180
|
+
getMainRemoteStreamsManagerTools({
|
|
1181
|
+
stateInfo: e
|
|
1182
|
+
}) {
|
|
1183
|
+
const t = this.mainRemoteStreamsManager;
|
|
1184
|
+
return { manager: t, getRemoteStreams: () => {
|
|
1185
|
+
const i = t.getStreams(), r = i.find((o) => !ie(o)), a = e.isAvailable ? i.find((o) => ie(o)) : void 0;
|
|
1186
|
+
return { mainStream: r, contentedStream: a };
|
|
1187
|
+
} };
|
|
1078
1188
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1189
|
+
getRecvRemoteStreamsManagerTools({
|
|
1190
|
+
stateInfo: e
|
|
1191
|
+
}) {
|
|
1192
|
+
const t = this.recvRemoteStreamsManager;
|
|
1193
|
+
return { manager: t, getRemoteStreams: () => {
|
|
1194
|
+
const r = t.getStreams(ft)[0], a = this.getRecvRemoteContentedStream({ stateInfo: e });
|
|
1195
|
+
return { mainStream: r, contentedStream: a };
|
|
1084
1196
|
} };
|
|
1085
1197
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1198
|
+
getRecvRemoteContentedStream({
|
|
1199
|
+
stateInfo: e
|
|
1200
|
+
}) {
|
|
1201
|
+
if (!e.isAvailable || e.codec === void 0)
|
|
1202
|
+
return;
|
|
1203
|
+
const t = bt(e.codec);
|
|
1204
|
+
return this.recvRemoteStreamsManager.getStreams(t)[0];
|
|
1089
1205
|
}
|
|
1090
1206
|
}
|
|
1091
|
-
const
|
|
1092
|
-
class
|
|
1207
|
+
const re = (n) => n.streams[0]?.id;
|
|
1208
|
+
class Dt {
|
|
1093
1209
|
events;
|
|
1094
1210
|
callStateMachine;
|
|
1095
1211
|
isPendingCall = !1;
|
|
1096
1212
|
isPendingAnswer = !1;
|
|
1097
1213
|
rtcSession;
|
|
1098
1214
|
conferenceStateManager;
|
|
1099
|
-
mainRemoteStreamsManager = new
|
|
1100
|
-
recvRemoteStreamsManager = new
|
|
1215
|
+
mainRemoteStreamsManager = new se();
|
|
1216
|
+
recvRemoteStreamsManager = new se();
|
|
1101
1217
|
streamsManagerProvider;
|
|
1102
|
-
|
|
1218
|
+
contentedStreamManager;
|
|
1219
|
+
roleManager = new O((e) => {
|
|
1103
1220
|
this.onRoleChanged(e);
|
|
1104
1221
|
});
|
|
1105
1222
|
mcuSession;
|
|
1106
1223
|
recvSession;
|
|
1107
1224
|
disposeRecvSessionTrackListener;
|
|
1108
|
-
|
|
1109
|
-
|
|
1225
|
+
streamsChangeTracker = new vt();
|
|
1226
|
+
constructor(e, t) {
|
|
1227
|
+
this.conferenceStateManager = e, this.contentedStreamManager = t, this.events = Et(), this.mcuSession = new Ct(this.events, { onReset: this.reset }), this.callStateMachine = new gt(this.events), this.streamsManagerProvider = new Ot(
|
|
1110
1228
|
this.mainRemoteStreamsManager,
|
|
1111
1229
|
this.recvRemoteStreamsManager
|
|
1112
|
-
), this.subscribeCallStatusChange(), this.subscribeMcuRemoteTrackEvents();
|
|
1230
|
+
), this.subscribeCallStatusChange(), this.subscribeMcuRemoteTrackEvents(), this.subscribeContentedStreamEvents();
|
|
1113
1231
|
}
|
|
1114
1232
|
get callActor() {
|
|
1115
1233
|
return this.callStateMachine.actorRef;
|
|
@@ -1127,6 +1245,9 @@ class Ct {
|
|
|
1127
1245
|
getStreamsManagerProvider() {
|
|
1128
1246
|
return this.streamsManagerProvider;
|
|
1129
1247
|
}
|
|
1248
|
+
getContentedStreamManager() {
|
|
1249
|
+
return this.contentedStreamManager;
|
|
1250
|
+
}
|
|
1130
1251
|
getEstablishedRTCSession = () => this.mcuSession.getEstablishedRTCSession();
|
|
1131
1252
|
on(e, t) {
|
|
1132
1253
|
return this.events.on(e, t);
|
|
@@ -1153,7 +1274,7 @@ class Ct {
|
|
|
1153
1274
|
return this.mcuSession.endCall();
|
|
1154
1275
|
}
|
|
1155
1276
|
async renegotiate() {
|
|
1156
|
-
return this.
|
|
1277
|
+
return this.roleManager.hasSpectator() ? this.renegotiateRecvSession() : this.renegotiateMcuSession();
|
|
1157
1278
|
}
|
|
1158
1279
|
answerToIncomingCall = async (e, t) => {
|
|
1159
1280
|
this.isPendingAnswer = !0;
|
|
@@ -1173,6 +1294,7 @@ class Ct {
|
|
|
1173
1294
|
const { getRemoteStreams: e } = this.getActiveStreamsManagerTools();
|
|
1174
1295
|
return e();
|
|
1175
1296
|
}
|
|
1297
|
+
getActivePeerConnection = () => this.roleManager.hasSpectator() ? this.recvSession?.peerConnection : this.mcuSession.connection;
|
|
1176
1298
|
setCallRoleParticipant() {
|
|
1177
1299
|
this.roleManager.setCallRoleParticipant();
|
|
1178
1300
|
}
|
|
@@ -1189,7 +1311,7 @@ class Ct {
|
|
|
1189
1311
|
return this.mcuSession.restartIce(e);
|
|
1190
1312
|
}
|
|
1191
1313
|
reset = () => {
|
|
1192
|
-
this.mainRemoteStreamsManager.reset(), this.conferenceStateManager.updateState({ number: void 0, answer: !1 }), this.roleManager.reset(), this.recvRemoteStreamsManager.reset(), this.stopRecvSession();
|
|
1314
|
+
this.mainRemoteStreamsManager.reset(), this.conferenceStateManager.updateState({ number: void 0, answer: !1 }), this.roleManager.reset(), this.recvRemoteStreamsManager.reset(), this.stopRecvSession(), this.streamsChangeTracker.reset();
|
|
1193
1315
|
};
|
|
1194
1316
|
subscribeCallStatusChange() {
|
|
1195
1317
|
let { isCallActive: e } = this;
|
|
@@ -1204,7 +1326,7 @@ class Ct {
|
|
|
1204
1326
|
}
|
|
1205
1327
|
subscribeMcuRemoteTrackEvents() {
|
|
1206
1328
|
this.on(S.PEER_CONNECTION_ONTRACK, (e) => {
|
|
1207
|
-
this.addRemoteTrack(this.mainRemoteStreamsManager, e.track,
|
|
1329
|
+
this.addRemoteTrack(this.mainRemoteStreamsManager, e.track, re(e));
|
|
1208
1330
|
});
|
|
1209
1331
|
}
|
|
1210
1332
|
addRemoteTrack(e, t, s) {
|
|
@@ -1247,16 +1369,17 @@ class Ct {
|
|
|
1247
1369
|
});
|
|
1248
1370
|
}
|
|
1249
1371
|
emitEventChangedRemoteStreams(e) {
|
|
1250
|
-
this.events.trigger(S.REMOTE_STREAMS_CHANGED, { streams: e });
|
|
1372
|
+
this.streamsChangeTracker.hasChanged(e) && (this.streamsChangeTracker.updateLastEmittedStreams(e), this.events.trigger(S.REMOTE_STREAMS_CHANGED, { streams: e }));
|
|
1251
1373
|
}
|
|
1252
1374
|
getActiveStreamsManagerTools() {
|
|
1253
|
-
return this.streamsManagerProvider.getActiveStreamsManagerTools(
|
|
1254
|
-
this.roleManager.hasSpectator()
|
|
1255
|
-
|
|
1375
|
+
return this.streamsManagerProvider.getActiveStreamsManagerTools({
|
|
1376
|
+
isSpectator: this.roleManager.hasSpectator(),
|
|
1377
|
+
stateInfo: this.contentedStreamManager.getStateInfo()
|
|
1378
|
+
});
|
|
1256
1379
|
}
|
|
1257
1380
|
attachRecvSessionTracks(e) {
|
|
1258
1381
|
const { peerConnection: t } = e, s = (i) => {
|
|
1259
|
-
this.addRemoteTrack(this.recvRemoteStreamsManager, i.track,
|
|
1382
|
+
this.addRemoteTrack(this.recvRemoteStreamsManager, i.track, re(i));
|
|
1260
1383
|
};
|
|
1261
1384
|
t.addEventListener("track", s), this.disposeRecvSessionTrackListener = () => {
|
|
1262
1385
|
t.removeEventListener("track", s);
|
|
@@ -1270,7 +1393,7 @@ class Ct {
|
|
|
1270
1393
|
const i = {
|
|
1271
1394
|
quality: "high",
|
|
1272
1395
|
audioChannel: e
|
|
1273
|
-
}, r = new
|
|
1396
|
+
}, r = new pt(i, { sendOffer: t });
|
|
1274
1397
|
this.recvSession = r, this.recvRemoteStreamsManager.reset(), this.attachRecvSessionTracks(r), r.call(s).catch(() => {
|
|
1275
1398
|
this.stopRecvSession();
|
|
1276
1399
|
});
|
|
@@ -1282,45 +1405,59 @@ class Ct {
|
|
|
1282
1405
|
previous: e,
|
|
1283
1406
|
next: t
|
|
1284
1407
|
}) => {
|
|
1285
|
-
if (
|
|
1408
|
+
if (O.hasSpectator(e) && !O.hasSpectator(t) && (this.stopRecvSession(), this.emitEventChangedRemoteStreams(this.getRemoteStreams())), O.hasSpectator(t)) {
|
|
1286
1409
|
const s = t.recvParams;
|
|
1287
1410
|
this.startRecvSession(s.audioId, s.sendOffer);
|
|
1288
1411
|
}
|
|
1289
1412
|
};
|
|
1413
|
+
subscribeContentedStreamEvents() {
|
|
1414
|
+
this.contentedStreamManager.on("available", () => {
|
|
1415
|
+
this.emitEventChangedRemoteStreams(this.getRemoteStreams());
|
|
1416
|
+
}), this.contentedStreamManager.on("not-available", () => {
|
|
1417
|
+
this.emitEventChangedRemoteStreams(this.getRemoteStreams());
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
async renegotiateRecvSession() {
|
|
1421
|
+
const e = this.conferenceStateManager.getNumber();
|
|
1422
|
+
return e === void 0 || this.recvSession === void 0 ? !1 : this.recvSession.renegotiate(e);
|
|
1423
|
+
}
|
|
1424
|
+
async renegotiateMcuSession() {
|
|
1425
|
+
return this.mcuSession.renegotiate();
|
|
1426
|
+
}
|
|
1290
1427
|
}
|
|
1291
|
-
const
|
|
1428
|
+
const Pt = (n, e) => (n.degradationPreference = e.degradationPreference, n), yt = (n, e) => {
|
|
1292
1429
|
n.encodings ??= [];
|
|
1293
1430
|
for (let t = n.encodings.length; t < e; t += 1)
|
|
1294
1431
|
n.encodings.push({});
|
|
1295
1432
|
return n;
|
|
1296
|
-
},
|
|
1297
|
-
if (
|
|
1433
|
+
}, Ie = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, Lt = Ie(), wt = (n, e) => {
|
|
1434
|
+
if (Lt(n, e))
|
|
1298
1435
|
return n;
|
|
1299
|
-
},
|
|
1300
|
-
const t = n.maxBitrate, s =
|
|
1436
|
+
}, Ut = (n, e) => {
|
|
1437
|
+
const t = n.maxBitrate, s = wt(e, t);
|
|
1301
1438
|
return s !== void 0 && (n.maxBitrate = s), n;
|
|
1302
|
-
},
|
|
1303
|
-
|
|
1304
|
-
),
|
|
1305
|
-
const t = n === void 0 ? void 0 : Math.max(n,
|
|
1306
|
-
if (t !== void 0 &&
|
|
1439
|
+
}, ve = 1, Ft = Ie(
|
|
1440
|
+
ve
|
|
1441
|
+
), Bt = (n, e) => {
|
|
1442
|
+
const t = n === void 0 ? void 0 : Math.max(n, ve);
|
|
1443
|
+
if (t !== void 0 && Ft(
|
|
1307
1444
|
t,
|
|
1308
1445
|
e
|
|
1309
1446
|
))
|
|
1310
1447
|
return t;
|
|
1311
|
-
},
|
|
1312
|
-
const t = n.scaleResolutionDownBy, s =
|
|
1448
|
+
}, kt = (n, e) => {
|
|
1449
|
+
const t = n.scaleResolutionDownBy, s = Bt(
|
|
1313
1450
|
e,
|
|
1314
1451
|
t
|
|
1315
1452
|
);
|
|
1316
1453
|
return s !== void 0 && (n.scaleResolutionDownBy = s), n;
|
|
1317
|
-
},
|
|
1454
|
+
}, $t = (n, e) => {
|
|
1318
1455
|
const t = e.encodings?.length ?? 0;
|
|
1319
|
-
return
|
|
1456
|
+
return yt(n, t), n.encodings.forEach((s, i) => {
|
|
1320
1457
|
const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
|
|
1321
|
-
|
|
1458
|
+
Ut(s, a), kt(s, o);
|
|
1322
1459
|
}), n;
|
|
1323
|
-
},
|
|
1460
|
+
}, Gt = (n, e) => {
|
|
1324
1461
|
if (n.codecs?.length !== e.codecs?.length)
|
|
1325
1462
|
return !0;
|
|
1326
1463
|
for (let t = 0; t < (n.codecs?.length ?? 0); t++)
|
|
@@ -1337,15 +1474,15 @@ const mt = (n, e) => (n.degradationPreference = e.degradationPreference, n), Nt
|
|
|
1337
1474
|
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
1338
1475
|
return !0;
|
|
1339
1476
|
return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
|
|
1340
|
-
},
|
|
1477
|
+
}, Vt = async (n, e) => {
|
|
1341
1478
|
const t = n.getParameters(), s = JSON.parse(
|
|
1342
1479
|
JSON.stringify(t)
|
|
1343
1480
|
);
|
|
1344
|
-
|
|
1345
|
-
const i =
|
|
1481
|
+
$t(t, e), Pt(t, e);
|
|
1482
|
+
const i = Gt(s, t);
|
|
1346
1483
|
return i && await n.setParameters(t), { parameters: t, isChanged: i };
|
|
1347
|
-
},
|
|
1348
|
-
const { isChanged: s, parameters: i } = await
|
|
1484
|
+
}, fe = async (n, e, t) => {
|
|
1485
|
+
const { isChanged: s, parameters: i } = await Vt(n, {
|
|
1349
1486
|
encodings: [
|
|
1350
1487
|
{
|
|
1351
1488
|
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
@@ -1354,21 +1491,21 @@ const mt = (n, e) => (n.degradationPreference = e.degradationPreference, n), Nt
|
|
|
1354
1491
|
]
|
|
1355
1492
|
});
|
|
1356
1493
|
return s && t && t(i), { isChanged: s, parameters: i };
|
|
1357
|
-
},
|
|
1358
|
-
const s =
|
|
1494
|
+
}, qt = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), Ht = async (n, e, t) => {
|
|
1495
|
+
const s = qt(n, e);
|
|
1359
1496
|
if (s)
|
|
1360
|
-
return
|
|
1497
|
+
return fe(s, { maxBitrate: t });
|
|
1361
1498
|
};
|
|
1362
1499
|
var P = /* @__PURE__ */ ((n) => (n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n))(P || {});
|
|
1363
|
-
const
|
|
1500
|
+
const Me = [
|
|
1364
1501
|
"presentation:start",
|
|
1365
1502
|
"presentation:started",
|
|
1366
1503
|
"presentation:end",
|
|
1367
1504
|
"presentation:ended",
|
|
1368
1505
|
"presentation:failed"
|
|
1369
|
-
],
|
|
1370
|
-
var
|
|
1371
|
-
const
|
|
1506
|
+
], Wt = () => new R(Me);
|
|
1507
|
+
var xt = /* @__PURE__ */ ((n) => (n.IDLE = "presentation:idle", n.STARTING = "presentation:starting", n.ACTIVE = "presentation:active", n.STOPPING = "presentation:stopping", n.FAILED = "presentation:failed", n))(xt || {});
|
|
1508
|
+
const Qt = G({
|
|
1372
1509
|
types: {
|
|
1373
1510
|
context: {},
|
|
1374
1511
|
events: {}
|
|
@@ -1380,10 +1517,10 @@ const Lt = $({
|
|
|
1380
1517
|
logStateChange: (n, e) => {
|
|
1381
1518
|
d("PresentationStateMachine state changed", e.state);
|
|
1382
1519
|
},
|
|
1383
|
-
setError:
|
|
1520
|
+
setError: M(({ event: n }) => "error" in n && n.error !== void 0 ? {
|
|
1384
1521
|
lastError: n.error instanceof Error ? n.error : new Error(JSON.stringify(n.error))
|
|
1385
1522
|
} : { lastError: void 0 }),
|
|
1386
|
-
clearError:
|
|
1523
|
+
clearError: M({ lastError: void 0 })
|
|
1387
1524
|
}
|
|
1388
1525
|
}).createMachine({
|
|
1389
1526
|
id: "presentation",
|
|
@@ -1693,9 +1830,9 @@ const Lt = $({
|
|
|
1693
1830
|
}
|
|
1694
1831
|
}
|
|
1695
1832
|
});
|
|
1696
|
-
class
|
|
1833
|
+
class Yt extends V {
|
|
1697
1834
|
constructor(e) {
|
|
1698
|
-
super(
|
|
1835
|
+
super(Qt), this.subscribeCallEvents(e);
|
|
1699
1836
|
}
|
|
1700
1837
|
get isIdle() {
|
|
1701
1838
|
return this.state === "presentation:idle";
|
|
@@ -1765,8 +1902,8 @@ class Ut extends q {
|
|
|
1765
1902
|
);
|
|
1766
1903
|
}
|
|
1767
1904
|
}
|
|
1768
|
-
const
|
|
1769
|
-
class
|
|
1905
|
+
const Xt = 1, li = (n) => je(n);
|
|
1906
|
+
class Jt {
|
|
1770
1907
|
events;
|
|
1771
1908
|
presentationStateMachine;
|
|
1772
1909
|
promisePendingStartPresentation;
|
|
@@ -1779,7 +1916,7 @@ class kt {
|
|
|
1779
1916
|
callManager: e,
|
|
1780
1917
|
maxBitrate: t
|
|
1781
1918
|
}) {
|
|
1782
|
-
this.callManager = e, this.maxBitrate = t, this.events =
|
|
1919
|
+
this.callManager = e, this.maxBitrate = t, this.events = Wt(), this.presentationStateMachine = new Yt(this.callManager.events), this.subscribe();
|
|
1783
1920
|
}
|
|
1784
1921
|
get presentationActor() {
|
|
1785
1922
|
return this.presentationStateMachine.actorRef;
|
|
@@ -1877,7 +2014,7 @@ class kt {
|
|
|
1877
2014
|
stream: s,
|
|
1878
2015
|
presentationOptions: i,
|
|
1879
2016
|
options: r = {
|
|
1880
|
-
callLimit:
|
|
2017
|
+
callLimit: Xt
|
|
1881
2018
|
}
|
|
1882
2019
|
}) {
|
|
1883
2020
|
const a = async () => this.sendPresentation(
|
|
@@ -1886,7 +2023,7 @@ class kt {
|
|
|
1886
2023
|
s,
|
|
1887
2024
|
i
|
|
1888
2025
|
), o = () => !!this.streamPresentationCurrent;
|
|
1889
|
-
return this.cancelableSendPresentationWithRepeatedCalls =
|
|
2026
|
+
return this.cancelableSendPresentationWithRepeatedCalls = Te({
|
|
1890
2027
|
targetFunction: a,
|
|
1891
2028
|
isComplete: o,
|
|
1892
2029
|
isRejectAsValid: !0,
|
|
@@ -1901,20 +2038,20 @@ class kt {
|
|
|
1901
2038
|
sendEncodings: o,
|
|
1902
2039
|
onAddedTransceiver: c
|
|
1903
2040
|
}) {
|
|
1904
|
-
const
|
|
1905
|
-
if (
|
|
2041
|
+
const l = H(s, { contentHint: r });
|
|
2042
|
+
if (l === void 0)
|
|
1906
2043
|
throw new Error("No streamPresentationTarget");
|
|
1907
|
-
this.streamPresentationCurrent =
|
|
1908
|
-
const
|
|
2044
|
+
this.streamPresentationCurrent = l;
|
|
2045
|
+
const T = e().then(async () => t.startPresentation(l, i, {
|
|
1909
2046
|
degradationPreference: a,
|
|
1910
2047
|
sendEncodings: o,
|
|
1911
2048
|
onAddedTransceiver: c
|
|
1912
|
-
})).then(this.setMaxBitrate).then(() => s).catch((
|
|
2049
|
+
})).then(this.setMaxBitrate).then(() => s).catch((u) => {
|
|
1913
2050
|
this.removeStreamPresentationCurrent();
|
|
1914
|
-
const E =
|
|
1915
|
-
throw this.events.trigger(P.FAILED_PRESENTATION, E),
|
|
2051
|
+
const E = u instanceof Error ? u : new Error(String(u));
|
|
2052
|
+
throw this.events.trigger(P.FAILED_PRESENTATION, E), u;
|
|
1916
2053
|
});
|
|
1917
|
-
return this.promisePendingStartPresentation =
|
|
2054
|
+
return this.promisePendingStartPresentation = T, T.finally(() => {
|
|
1918
2055
|
this.promisePendingStartPresentation = void 0;
|
|
1919
2056
|
});
|
|
1920
2057
|
}
|
|
@@ -1923,7 +2060,7 @@ class kt {
|
|
|
1923
2060
|
if (!e || !t || s === void 0)
|
|
1924
2061
|
return;
|
|
1925
2062
|
const i = e.getSenders();
|
|
1926
|
-
await
|
|
2063
|
+
await Ht(i, t, s);
|
|
1927
2064
|
};
|
|
1928
2065
|
getRtcSessionProtected = () => {
|
|
1929
2066
|
const e = this.callManager.getEstablishedRTCSession();
|
|
@@ -1944,7 +2081,7 @@ class kt {
|
|
|
1944
2081
|
delete this.streamPresentationCurrent;
|
|
1945
2082
|
}
|
|
1946
2083
|
}
|
|
1947
|
-
class
|
|
2084
|
+
class zt {
|
|
1948
2085
|
data;
|
|
1949
2086
|
getUa;
|
|
1950
2087
|
constructor(e) {
|
|
@@ -2030,8 +2167,8 @@ class Bt {
|
|
|
2030
2167
|
return this.data?.register === !0;
|
|
2031
2168
|
}
|
|
2032
2169
|
}
|
|
2033
|
-
var
|
|
2034
|
-
const
|
|
2170
|
+
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 || {});
|
|
2171
|
+
const _e = [
|
|
2035
2172
|
"connecting",
|
|
2036
2173
|
"connected",
|
|
2037
2174
|
"disconnected",
|
|
@@ -2041,7 +2178,7 @@ const Re = [
|
|
|
2041
2178
|
"registrationFailed",
|
|
2042
2179
|
"newMessage",
|
|
2043
2180
|
"sipEvent"
|
|
2044
|
-
],
|
|
2181
|
+
], jt = [
|
|
2045
2182
|
"disconnecting",
|
|
2046
2183
|
"connect-started",
|
|
2047
2184
|
"connect-succeeded",
|
|
@@ -2049,12 +2186,12 @@ const Re = [
|
|
|
2049
2186
|
"connect-parameters-resolve-success",
|
|
2050
2187
|
"connect-parameters-resolve-failed",
|
|
2051
2188
|
"connected-with-configuration"
|
|
2052
|
-
],
|
|
2053
|
-
function
|
|
2189
|
+
], be = [..._e, ...jt], Kt = () => new R(be);
|
|
2190
|
+
function Zt(n) {
|
|
2054
2191
|
return (e) => `sip:${e}@${n}`;
|
|
2055
2192
|
}
|
|
2056
|
-
const
|
|
2057
|
-
class
|
|
2193
|
+
const en = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, Oe = (n) => n.trim().replaceAll(" ", "_"), tn = en(1e5, 99999999), nn = 3;
|
|
2194
|
+
class sn {
|
|
2058
2195
|
cancelableConnectWithRepeatedCalls;
|
|
2059
2196
|
JsSIP;
|
|
2060
2197
|
events;
|
|
@@ -2080,30 +2217,30 @@ class xt {
|
|
|
2080
2217
|
}
|
|
2081
2218
|
let r = !1;
|
|
2082
2219
|
const a = this.getConnectionConfiguration();
|
|
2083
|
-
e !== void 0 && e !== a?.displayName && (r = i.set("display_name",
|
|
2220
|
+
e !== void 0 && e !== a?.displayName && (r = i.set("display_name", Oe(e)), this.updateConnectionConfiguration("displayName", e));
|
|
2084
2221
|
const o = r;
|
|
2085
2222
|
o ? t(o) : s(new Error("nothing changed"));
|
|
2086
2223
|
});
|
|
2087
2224
|
disconnect = async () => {
|
|
2088
|
-
this.events.trigger(
|
|
2225
|
+
this.events.trigger(C.DISCONNECTING, {});
|
|
2089
2226
|
const e = new Promise((s) => {
|
|
2090
|
-
this.events.once(
|
|
2227
|
+
this.events.once(C.DISCONNECTED, () => {
|
|
2091
2228
|
s();
|
|
2092
2229
|
});
|
|
2093
2230
|
}), t = this.getUa();
|
|
2094
|
-
return t ? t.stop() : this.events.trigger(
|
|
2231
|
+
return t ? t.stop() : this.events.trigger(C.DISCONNECTED, { socket: {}, error: !1 }), e.finally(() => {
|
|
2095
2232
|
t?.removeAllListeners(), this.setUa(void 0), this.stateMachine.reset();
|
|
2096
2233
|
});
|
|
2097
2234
|
};
|
|
2098
2235
|
cancelRequests() {
|
|
2099
2236
|
this.cancelConnectWithRepeatedCalls();
|
|
2100
2237
|
}
|
|
2101
|
-
connectWithDuplicatedCalls = async (e, { callLimit: t =
|
|
2238
|
+
connectWithDuplicatedCalls = async (e, { callLimit: t = nn } = {}) => {
|
|
2102
2239
|
const s = async () => this.connectInner(e), i = (r) => {
|
|
2103
|
-
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e),
|
|
2104
|
-
return c ||
|
|
2240
|
+
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), l = r != null && !st(r);
|
|
2241
|
+
return c || l;
|
|
2105
2242
|
};
|
|
2106
|
-
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls =
|
|
2243
|
+
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = Te({
|
|
2107
2244
|
targetFunction: s,
|
|
2108
2245
|
isComplete: i,
|
|
2109
2246
|
callLimit: t,
|
|
@@ -2137,39 +2274,39 @@ class xt {
|
|
|
2137
2274
|
sessionTimers: a,
|
|
2138
2275
|
registerExpires: o,
|
|
2139
2276
|
connectionRecoveryMinInterval: c,
|
|
2140
|
-
connectionRecoveryMaxInterval:
|
|
2141
|
-
userAgent:
|
|
2142
|
-
displayName:
|
|
2277
|
+
connectionRecoveryMaxInterval: l,
|
|
2278
|
+
userAgent: T,
|
|
2279
|
+
displayName: u = "",
|
|
2143
2280
|
register: E = !1,
|
|
2144
2281
|
extraHeaders: m = []
|
|
2145
2282
|
}) => {
|
|
2146
2283
|
this.stateMachine.startInitUa(), this.setConnectionConfiguration({
|
|
2147
2284
|
sipServerIp: s,
|
|
2148
2285
|
sipServerUrl: i,
|
|
2149
|
-
displayName:
|
|
2286
|
+
displayName: u,
|
|
2150
2287
|
register: E,
|
|
2151
2288
|
user: e,
|
|
2152
2289
|
password: t
|
|
2153
2290
|
}), this.getUa() && await this.disconnect();
|
|
2154
|
-
const { ua:
|
|
2291
|
+
const { ua: A, helpers: w } = this.uaFactory.createUAWithConfiguration(
|
|
2155
2292
|
{
|
|
2156
2293
|
user: e,
|
|
2157
2294
|
password: t,
|
|
2158
2295
|
sipServerIp: s,
|
|
2159
2296
|
sipServerUrl: i,
|
|
2160
|
-
displayName:
|
|
2297
|
+
displayName: u,
|
|
2161
2298
|
register: E,
|
|
2162
2299
|
sessionTimers: a,
|
|
2163
2300
|
registerExpires: o,
|
|
2164
2301
|
connectionRecoveryMinInterval: c,
|
|
2165
|
-
connectionRecoveryMaxInterval:
|
|
2166
|
-
userAgent:
|
|
2302
|
+
connectionRecoveryMaxInterval: l,
|
|
2303
|
+
userAgent: T,
|
|
2167
2304
|
remoteAddress: r,
|
|
2168
2305
|
extraHeaders: m
|
|
2169
2306
|
},
|
|
2170
2307
|
this.events
|
|
2171
2308
|
);
|
|
2172
|
-
return this.setUa(
|
|
2309
|
+
return this.setUa(A), this.setGetUri(w.getUri), this.setSocket(w.socket), A;
|
|
2173
2310
|
};
|
|
2174
2311
|
start = async () => new Promise((e, t) => {
|
|
2175
2312
|
const s = this.getUa();
|
|
@@ -2178,15 +2315,15 @@ class xt {
|
|
|
2178
2315
|
return;
|
|
2179
2316
|
}
|
|
2180
2317
|
let i;
|
|
2181
|
-
i = ((c,
|
|
2318
|
+
i = ((c, l) => {
|
|
2182
2319
|
if (this.getConnectionConfiguration()?.register === !0)
|
|
2183
|
-
return this.registrationManager.subscribeToStartEvents(c,
|
|
2184
|
-
const
|
|
2185
|
-
return this.events.on(
|
|
2186
|
-
this.events.on(m,
|
|
2320
|
+
return this.registrationManager.subscribeToStartEvents(c, l);
|
|
2321
|
+
const u = C.CONNECTED, E = [C.DISCONNECTED];
|
|
2322
|
+
return this.events.on(u, c), E.forEach((m) => {
|
|
2323
|
+
this.events.on(m, l);
|
|
2187
2324
|
}), () => {
|
|
2188
|
-
this.events.off(
|
|
2189
|
-
this.events.off(m,
|
|
2325
|
+
this.events.off(u, c), E.forEach((m) => {
|
|
2326
|
+
this.events.off(m, l);
|
|
2190
2327
|
});
|
|
2191
2328
|
};
|
|
2192
2329
|
})(() => {
|
|
@@ -2199,17 +2336,17 @@ class xt {
|
|
|
2199
2336
|
this.cancelableConnectWithRepeatedCalls?.cancel();
|
|
2200
2337
|
}
|
|
2201
2338
|
proxyEvents() {
|
|
2202
|
-
this.events.on(
|
|
2339
|
+
this.events.on(C.CONNECTED, () => {
|
|
2203
2340
|
const e = this.getConnectionConfiguration(), t = this.getUa();
|
|
2204
|
-
e !== void 0 && t !== void 0 && this.events.trigger(
|
|
2341
|
+
e !== void 0 && t !== void 0 && this.events.trigger(C.CONNECTED_WITH_CONFIGURATION, {
|
|
2205
2342
|
...e,
|
|
2206
2343
|
ua: t
|
|
2207
2344
|
});
|
|
2208
2345
|
});
|
|
2209
2346
|
}
|
|
2210
2347
|
}
|
|
2211
|
-
var
|
|
2212
|
-
const
|
|
2348
|
+
var rn = /* @__PURE__ */ ((n) => (n.IDLE = "connection:idle", n.PREPARING = "connection:preparing", n.CONNECTING = "connection:connecting", n.CONNECTED = "connection:connected", n.REGISTERED = "connection:registered", n.ESTABLISHED = "connection:established", n.DISCONNECTED = "connection:disconnected", n.FAILED = "connection:failed", n))(rn || {}), De = /* @__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))(De || {});
|
|
2349
|
+
const an = Object.values(De), on = G({
|
|
2213
2350
|
types: {
|
|
2214
2351
|
context: {},
|
|
2215
2352
|
events: {}
|
|
@@ -2221,13 +2358,13 @@ const Yt = Object.values(fe), Xt = $({
|
|
|
2221
2358
|
logStateChange: (n, e) => {
|
|
2222
2359
|
d("ConnectionStateMachine state changed", e.state);
|
|
2223
2360
|
},
|
|
2224
|
-
setError:
|
|
2361
|
+
setError: M({
|
|
2225
2362
|
error: ({ event: n }) => {
|
|
2226
2363
|
if (n.type === "CONNECTION_FAILED" && "error" in n)
|
|
2227
2364
|
return n.error;
|
|
2228
2365
|
}
|
|
2229
2366
|
}),
|
|
2230
|
-
clearError:
|
|
2367
|
+
clearError: M({
|
|
2231
2368
|
error: () => {
|
|
2232
2369
|
}
|
|
2233
2370
|
})
|
|
@@ -2589,19 +2726,11 @@ const Yt = Object.values(fe), Xt = $({
|
|
|
2589
2726
|
}
|
|
2590
2727
|
}
|
|
2591
2728
|
});
|
|
2592
|
-
class
|
|
2593
|
-
stateChangeListeners = /* @__PURE__ */ new Set();
|
|
2729
|
+
class cn extends V {
|
|
2594
2730
|
events;
|
|
2595
2731
|
unsubscribeFromEvents;
|
|
2596
2732
|
constructor(e) {
|
|
2597
|
-
super(
|
|
2598
|
-
this.subscribe((t) => {
|
|
2599
|
-
const s = t.value;
|
|
2600
|
-
this.stateChangeListeners.forEach((i) => {
|
|
2601
|
-
i(s);
|
|
2602
|
-
});
|
|
2603
|
-
})
|
|
2604
|
-
), this.subscribeToEvents();
|
|
2733
|
+
super(on), this.events = e, this.subscribeToEvents();
|
|
2605
2734
|
}
|
|
2606
2735
|
get isIdle() {
|
|
2607
2736
|
return this.hasState(
|
|
@@ -2677,18 +2806,13 @@ class Jt extends q {
|
|
|
2677
2806
|
this.toIdle();
|
|
2678
2807
|
}
|
|
2679
2808
|
destroy() {
|
|
2680
|
-
this.
|
|
2681
|
-
}
|
|
2682
|
-
onStateChange(e) {
|
|
2683
|
-
return this.stateChangeListeners.add(e), () => {
|
|
2684
|
-
this.stateChangeListeners.delete(e);
|
|
2685
|
-
};
|
|
2809
|
+
this.unsubscribeFromEvents?.(), this.stop();
|
|
2686
2810
|
}
|
|
2687
2811
|
canTransition(e) {
|
|
2688
2812
|
return this.getSnapshot().can({ type: e });
|
|
2689
2813
|
}
|
|
2690
2814
|
getValidEvents() {
|
|
2691
|
-
return
|
|
2815
|
+
return an.filter((e) => this.canTransition(e));
|
|
2692
2816
|
}
|
|
2693
2817
|
hasState(e) {
|
|
2694
2818
|
return this.getSnapshot().matches(e);
|
|
@@ -2760,7 +2884,7 @@ class Jt extends q {
|
|
|
2760
2884
|
this.toFailed(e instanceof Error ? e : void 0);
|
|
2761
2885
|
};
|
|
2762
2886
|
}
|
|
2763
|
-
class
|
|
2887
|
+
class dn {
|
|
2764
2888
|
events;
|
|
2765
2889
|
getUaProtected;
|
|
2766
2890
|
constructor(e) {
|
|
@@ -2769,13 +2893,13 @@ class zt {
|
|
|
2769
2893
|
async register() {
|
|
2770
2894
|
const e = this.getUaProtected();
|
|
2771
2895
|
return new Promise((t, s) => {
|
|
2772
|
-
e.on(
|
|
2896
|
+
e.on(C.REGISTERED, t), e.on(C.REGISTRATION_FAILED, s), e.register();
|
|
2773
2897
|
});
|
|
2774
2898
|
}
|
|
2775
2899
|
async unregister() {
|
|
2776
2900
|
const e = this.getUaProtected();
|
|
2777
2901
|
return new Promise((t) => {
|
|
2778
|
-
e.on(
|
|
2902
|
+
e.on(C.UNREGISTERED, t), e.unregister();
|
|
2779
2903
|
});
|
|
2780
2904
|
}
|
|
2781
2905
|
async tryRegister() {
|
|
@@ -2787,7 +2911,7 @@ class zt {
|
|
|
2787
2911
|
return this.register();
|
|
2788
2912
|
}
|
|
2789
2913
|
subscribeToStartEvents(e, t) {
|
|
2790
|
-
const s =
|
|
2914
|
+
const s = C.REGISTERED, i = [C.REGISTRATION_FAILED, C.DISCONNECTED];
|
|
2791
2915
|
return this.events.on(s, e), i.forEach((r) => {
|
|
2792
2916
|
this.events.on(r, t);
|
|
2793
2917
|
}), () => {
|
|
@@ -2797,7 +2921,7 @@ class zt {
|
|
|
2797
2921
|
};
|
|
2798
2922
|
}
|
|
2799
2923
|
}
|
|
2800
|
-
class
|
|
2924
|
+
class hn {
|
|
2801
2925
|
uaFactory;
|
|
2802
2926
|
getUaProtected;
|
|
2803
2927
|
constructor(e) {
|
|
@@ -2843,30 +2967,30 @@ class Kt {
|
|
|
2843
2967
|
extraHeaders: a
|
|
2844
2968
|
}) {
|
|
2845
2969
|
return new Promise((o, c) => {
|
|
2846
|
-
const { configuration:
|
|
2970
|
+
const { configuration: l } = this.uaFactory.createConfiguration({
|
|
2847
2971
|
sipServerUrl: i,
|
|
2848
2972
|
displayName: t,
|
|
2849
2973
|
userAgent: e,
|
|
2850
2974
|
sipServerIp: s
|
|
2851
|
-
}),
|
|
2975
|
+
}), T = this.uaFactory.createUA({ ...l, remoteAddress: r, extraHeaders: a }), u = () => {
|
|
2852
2976
|
const m = new Error("Telephony is not available");
|
|
2853
2977
|
c(m);
|
|
2854
2978
|
};
|
|
2855
|
-
|
|
2979
|
+
T.once(C.DISCONNECTED, u);
|
|
2856
2980
|
const E = () => {
|
|
2857
|
-
|
|
2981
|
+
T.removeAllListeners(), T.once(C.DISCONNECTED, () => {
|
|
2858
2982
|
o();
|
|
2859
|
-
}),
|
|
2983
|
+
}), T.stop();
|
|
2860
2984
|
};
|
|
2861
|
-
|
|
2985
|
+
T.once(C.CONNECTED, E), T.start();
|
|
2862
2986
|
});
|
|
2863
2987
|
}
|
|
2864
2988
|
}
|
|
2865
|
-
const
|
|
2989
|
+
const ln = (n) => {
|
|
2866
2990
|
const e = [];
|
|
2867
2991
|
return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
|
|
2868
2992
|
};
|
|
2869
|
-
class
|
|
2993
|
+
class F {
|
|
2870
2994
|
JsSIP;
|
|
2871
2995
|
constructor(e) {
|
|
2872
2996
|
this.JsSIP = e;
|
|
@@ -2891,10 +3015,10 @@ class w {
|
|
|
2891
3015
|
throw new Error("user is required for authorized connection");
|
|
2892
3016
|
}
|
|
2893
3017
|
static resolveAuthorizationUser(e, t) {
|
|
2894
|
-
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${
|
|
3018
|
+
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${tn()}`;
|
|
2895
3019
|
}
|
|
2896
3020
|
static buildExtraHeaders(e, t) {
|
|
2897
|
-
const s = e !== void 0 && e !== "" ?
|
|
3021
|
+
const s = e !== void 0 && e !== "" ? ln(e) : [];
|
|
2898
3022
|
return t === void 0 ? s : [...s, ...t];
|
|
2899
3023
|
}
|
|
2900
3024
|
createConfiguration({
|
|
@@ -2907,40 +3031,40 @@ class w {
|
|
|
2907
3031
|
sessionTimers: o = !1,
|
|
2908
3032
|
registerExpires: c = 300,
|
|
2909
3033
|
// 5 minutes in sec
|
|
2910
|
-
connectionRecoveryMinInterval:
|
|
2911
|
-
connectionRecoveryMaxInterval:
|
|
2912
|
-
userAgent:
|
|
3034
|
+
connectionRecoveryMinInterval: l = 2,
|
|
3035
|
+
connectionRecoveryMaxInterval: T = 6,
|
|
3036
|
+
userAgent: u
|
|
2913
3037
|
}) {
|
|
2914
|
-
|
|
3038
|
+
F.validateParametersConnection({
|
|
2915
3039
|
register: a,
|
|
2916
3040
|
password: t,
|
|
2917
3041
|
user: e,
|
|
2918
3042
|
sipServerIp: r,
|
|
2919
3043
|
sipServerUrl: s
|
|
2920
3044
|
});
|
|
2921
|
-
const E =
|
|
3045
|
+
const E = F.resolveAuthorizationUser(a, e), m = Zt(r), D = m(E), A = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
|
|
2922
3046
|
return {
|
|
2923
3047
|
configuration: {
|
|
2924
3048
|
password: t,
|
|
2925
3049
|
register: a,
|
|
2926
|
-
uri:
|
|
2927
|
-
display_name:
|
|
2928
|
-
user_agent:
|
|
3050
|
+
uri: D,
|
|
3051
|
+
display_name: Oe(i),
|
|
3052
|
+
user_agent: u,
|
|
2929
3053
|
sdpSemantics: "unified-plan",
|
|
2930
|
-
sockets: [
|
|
3054
|
+
sockets: [A],
|
|
2931
3055
|
session_timers: o,
|
|
2932
3056
|
register_expires: c,
|
|
2933
|
-
connection_recovery_min_interval:
|
|
2934
|
-
connection_recovery_max_interval:
|
|
3057
|
+
connection_recovery_min_interval: l,
|
|
3058
|
+
connection_recovery_max_interval: T
|
|
2935
3059
|
},
|
|
2936
3060
|
helpers: {
|
|
2937
|
-
socket:
|
|
3061
|
+
socket: A,
|
|
2938
3062
|
getUri: m
|
|
2939
3063
|
}
|
|
2940
3064
|
};
|
|
2941
3065
|
}
|
|
2942
3066
|
createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
|
|
2943
|
-
const i = new this.JsSIP.UA(s), r =
|
|
3067
|
+
const i = new this.JsSIP.UA(s), r = F.buildExtraHeaders(e, t);
|
|
2944
3068
|
return r.length > 0 && i.registrator().setExtraHeaders(r), i;
|
|
2945
3069
|
}
|
|
2946
3070
|
/**
|
|
@@ -2953,13 +3077,13 @@ class w {
|
|
|
2953
3077
|
extraHeaders: e.extraHeaders
|
|
2954
3078
|
});
|
|
2955
3079
|
return t.eachTriggers((a, o) => {
|
|
2956
|
-
const c =
|
|
3080
|
+
const c = _e.find((l) => l === o);
|
|
2957
3081
|
c && r.on(c, a);
|
|
2958
3082
|
}), { ua: r, helpers: i };
|
|
2959
3083
|
}
|
|
2960
3084
|
}
|
|
2961
|
-
const
|
|
2962
|
-
class
|
|
3085
|
+
const Pe = "Not ready for connection", gn = (n) => n instanceof Error && n.message === Pe, un = () => new Error(Pe), Tn = async (n) => typeof n == "function" ? n() : n;
|
|
3086
|
+
class En {
|
|
2963
3087
|
events;
|
|
2964
3088
|
ua;
|
|
2965
3089
|
socket;
|
|
@@ -2971,15 +3095,15 @@ class nn {
|
|
|
2971
3095
|
configurationManager;
|
|
2972
3096
|
JsSIP;
|
|
2973
3097
|
constructor({ JsSIP: e }) {
|
|
2974
|
-
this.JsSIP = e, this.events =
|
|
3098
|
+
this.JsSIP = e, this.events = Kt(), this.uaFactory = new F(e), this.registrationManager = new dn({
|
|
2975
3099
|
events: this.events,
|
|
2976
3100
|
getUaProtected: this.getUaProtected
|
|
2977
|
-
}), this.stateMachine = new
|
|
3101
|
+
}), this.stateMachine = new cn(this.events), this.configurationManager = new zt({
|
|
2978
3102
|
getUa: this.getUa
|
|
2979
|
-
}), this.sipOperations = new
|
|
3103
|
+
}), this.sipOperations = new hn({
|
|
2980
3104
|
uaFactory: this.uaFactory,
|
|
2981
3105
|
getUaProtected: this.getUaProtected
|
|
2982
|
-
}), this.connectionFlow = new
|
|
3106
|
+
}), this.connectionFlow = new sn({
|
|
2983
3107
|
JsSIP: this.JsSIP,
|
|
2984
3108
|
events: this.events,
|
|
2985
3109
|
uaFactory: this.uaFactory,
|
|
@@ -3029,7 +3153,7 @@ class nn {
|
|
|
3029
3153
|
return this.stateMachine.state;
|
|
3030
3154
|
}
|
|
3031
3155
|
get isRegistered() {
|
|
3032
|
-
return
|
|
3156
|
+
return F.isRegisteredUA(this.ua);
|
|
3033
3157
|
}
|
|
3034
3158
|
get isRegisterConfig() {
|
|
3035
3159
|
return this.configurationManager.isRegister();
|
|
@@ -3084,7 +3208,7 @@ class nn {
|
|
|
3084
3208
|
getUa = () => this.ua;
|
|
3085
3209
|
connectWithProcessError = async (e, t) => {
|
|
3086
3210
|
if (!(t?.hasReadyForConnection?.() ?? !0))
|
|
3087
|
-
throw
|
|
3211
|
+
throw un();
|
|
3088
3212
|
return this.processConnect(e, t).catch(async (i) => {
|
|
3089
3213
|
const r = i;
|
|
3090
3214
|
return this.disconnect().then(() => {
|
|
@@ -3094,18 +3218,18 @@ class nn {
|
|
|
3094
3218
|
});
|
|
3095
3219
|
});
|
|
3096
3220
|
};
|
|
3097
|
-
processConnect = async (e, t) => (this.events.trigger(
|
|
3098
|
-
throw this.events.trigger(
|
|
3099
|
-
}).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(
|
|
3221
|
+
processConnect = async (e, t) => (this.events.trigger(C.CONNECT_STARTED, {}), Tn(e).then((s) => (this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
|
|
3222
|
+
throw this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_FAILED, s), s;
|
|
3223
|
+
}).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(C.CONNECT_SUCCEEDED, {
|
|
3100
3224
|
...s
|
|
3101
3225
|
}), s)).catch((s) => {
|
|
3102
3226
|
const i = s ?? new Error("Failed to connect to server");
|
|
3103
|
-
throw this.events.trigger(
|
|
3227
|
+
throw this.events.trigger(C.CONNECT_FAILED, i), i;
|
|
3104
3228
|
}));
|
|
3105
3229
|
}
|
|
3106
|
-
class
|
|
3230
|
+
class Sn {
|
|
3107
3231
|
connectionManager;
|
|
3108
|
-
stackPromises =
|
|
3232
|
+
stackPromises = Ee({
|
|
3109
3233
|
noRunIsNotActual: !0
|
|
3110
3234
|
});
|
|
3111
3235
|
constructor({ connectionManager: e }) {
|
|
@@ -3117,11 +3241,11 @@ class sn {
|
|
|
3117
3241
|
this.stackPromises.stop();
|
|
3118
3242
|
}
|
|
3119
3243
|
}
|
|
3120
|
-
const
|
|
3121
|
-
class
|
|
3122
|
-
countInner =
|
|
3123
|
-
initialCount =
|
|
3124
|
-
limitInner =
|
|
3244
|
+
const ae = 0, Cn = 30;
|
|
3245
|
+
class pn {
|
|
3246
|
+
countInner = ae;
|
|
3247
|
+
initialCount = ae;
|
|
3248
|
+
limitInner = Cn;
|
|
3125
3249
|
isInProgress = !1;
|
|
3126
3250
|
onStatusChange;
|
|
3127
3251
|
constructor({
|
|
@@ -3154,7 +3278,7 @@ class an {
|
|
|
3154
3278
|
this.countInner = this.initialCount, this.finishAttempt();
|
|
3155
3279
|
}
|
|
3156
3280
|
}
|
|
3157
|
-
class
|
|
3281
|
+
class mn {
|
|
3158
3282
|
connectionManager;
|
|
3159
3283
|
interval;
|
|
3160
3284
|
checkTelephonyByTimeout = void 0;
|
|
@@ -3170,7 +3294,7 @@ class on {
|
|
|
3170
3294
|
onSuccessRequest: t,
|
|
3171
3295
|
onFailRequest: s
|
|
3172
3296
|
}) {
|
|
3173
|
-
this.stop(), this.cancelableBeforeRequest = new
|
|
3297
|
+
this.stop(), this.cancelableBeforeRequest = new Y(e), this.checkTelephonyByTimeout = Ye({
|
|
3174
3298
|
isDontStopOnFail: !0,
|
|
3175
3299
|
requestInterval: this.interval,
|
|
3176
3300
|
request: async () => {
|
|
@@ -3190,8 +3314,8 @@ class on {
|
|
|
3190
3314
|
this.checkTelephonyByTimeout?.stop(), this.checkTelephonyByTimeout = void 0, this.cancelableBeforeRequest?.cancelRequest(), this.cancelableBeforeRequest = void 0;
|
|
3191
3315
|
}
|
|
3192
3316
|
}
|
|
3193
|
-
var
|
|
3194
|
-
const
|
|
3317
|
+
var v = /* @__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))(v || {});
|
|
3318
|
+
const ye = [
|
|
3195
3319
|
"before-attempt",
|
|
3196
3320
|
"success",
|
|
3197
3321
|
"failed-all-attempts",
|
|
@@ -3199,8 +3323,8 @@ const Me = [
|
|
|
3199
3323
|
"changed-attempt-status",
|
|
3200
3324
|
"stop-attempts-by-error",
|
|
3201
3325
|
"limit-reached-attempts"
|
|
3202
|
-
],
|
|
3203
|
-
class
|
|
3326
|
+
], Nn = () => new R(ye);
|
|
3327
|
+
class te {
|
|
3204
3328
|
callManager;
|
|
3205
3329
|
disposers = [];
|
|
3206
3330
|
constructor({ callManager: e }) {
|
|
@@ -3225,15 +3349,15 @@ class K {
|
|
|
3225
3349
|
this.callManager.isCallActive ? e?.() : t();
|
|
3226
3350
|
}
|
|
3227
3351
|
}
|
|
3228
|
-
const
|
|
3229
|
-
class
|
|
3352
|
+
const An = 15e3, Rn = 2;
|
|
3353
|
+
class In {
|
|
3230
3354
|
connectionManager;
|
|
3231
3355
|
pingServerByTimeoutWithFailCalls;
|
|
3232
3356
|
constructor({ connectionManager: e }) {
|
|
3233
|
-
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls =
|
|
3357
|
+
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = Xe(Rn, {
|
|
3234
3358
|
whenPossibleRequest: async () => {
|
|
3235
3359
|
},
|
|
3236
|
-
requestInterval:
|
|
3360
|
+
requestInterval: An,
|
|
3237
3361
|
request: async () => (d("ping"), this.connectionManager.ping().then(() => {
|
|
3238
3362
|
d("ping success");
|
|
3239
3363
|
}))
|
|
@@ -3246,16 +3370,16 @@ class ln {
|
|
|
3246
3370
|
this.pingServerByTimeoutWithFailCalls.stop();
|
|
3247
3371
|
}
|
|
3248
3372
|
}
|
|
3249
|
-
class
|
|
3373
|
+
class vn {
|
|
3250
3374
|
pingServerRequester;
|
|
3251
3375
|
notActiveCallSubscriber;
|
|
3252
3376
|
constructor({
|
|
3253
3377
|
connectionManager: e,
|
|
3254
3378
|
callManager: t
|
|
3255
3379
|
}) {
|
|
3256
|
-
this.pingServerRequester = new
|
|
3380
|
+
this.pingServerRequester = new In({
|
|
3257
3381
|
connectionManager: e
|
|
3258
|
-
}), this.notActiveCallSubscriber = new
|
|
3382
|
+
}), this.notActiveCallSubscriber = new te({ callManager: t });
|
|
3259
3383
|
}
|
|
3260
3384
|
start({ onFailRequest: e }) {
|
|
3261
3385
|
d("start"), this.notActiveCallSubscriber.subscribe({
|
|
@@ -3274,7 +3398,7 @@ class gn {
|
|
|
3274
3398
|
this.notActiveCallSubscriber.unsubscribe();
|
|
3275
3399
|
}
|
|
3276
3400
|
}
|
|
3277
|
-
class
|
|
3401
|
+
class fn {
|
|
3278
3402
|
connectionManager;
|
|
3279
3403
|
isRegistrationFailed = !1;
|
|
3280
3404
|
disposers = [];
|
|
@@ -3283,7 +3407,7 @@ class un {
|
|
|
3283
3407
|
connectionManager: e,
|
|
3284
3408
|
callManager: t
|
|
3285
3409
|
}) {
|
|
3286
|
-
this.connectionManager = e, this.notActiveCallSubscriber = new
|
|
3410
|
+
this.connectionManager = e, this.notActiveCallSubscriber = new te({ callManager: t });
|
|
3287
3411
|
}
|
|
3288
3412
|
subscribe(e) {
|
|
3289
3413
|
this.unsubscribe(), this.disposers.push(
|
|
@@ -3310,12 +3434,12 @@ class un {
|
|
|
3310
3434
|
this.isRegistrationFailed = !1;
|
|
3311
3435
|
}
|
|
3312
3436
|
}
|
|
3313
|
-
const
|
|
3437
|
+
const Mn = 3e3, _n = 15e3, oe = {
|
|
3314
3438
|
LIMIT_REACHED: "Limit reached",
|
|
3315
3439
|
FAILED_TO_RECONNECT: "Failed to reconnect"
|
|
3316
|
-
},
|
|
3317
|
-
},
|
|
3318
|
-
class
|
|
3440
|
+
}, bn = async () => {
|
|
3441
|
+
}, On = (n) => !0;
|
|
3442
|
+
class Dn {
|
|
3319
3443
|
events;
|
|
3320
3444
|
connectionManager;
|
|
3321
3445
|
connectionQueueManager;
|
|
@@ -3335,21 +3459,21 @@ class Cn {
|
|
|
3335
3459
|
connectionManager: t,
|
|
3336
3460
|
callManager: s
|
|
3337
3461
|
}, i) {
|
|
3338
|
-
const r = i?.onBeforeRetry ??
|
|
3339
|
-
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events =
|
|
3462
|
+
const r = i?.onBeforeRetry ?? bn, a = i?.canRetryOnError ?? On;
|
|
3463
|
+
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = Nn(), this.checkTelephonyRequester = new mn({
|
|
3340
3464
|
connectionManager: t,
|
|
3341
|
-
interval: i?.checkTelephonyRequestInterval ??
|
|
3342
|
-
}), this.pingServerIfNotActiveCallRequester = new
|
|
3465
|
+
interval: i?.checkTelephonyRequestInterval ?? _n
|
|
3466
|
+
}), this.pingServerIfNotActiveCallRequester = new vn({
|
|
3343
3467
|
connectionManager: t,
|
|
3344
3468
|
callManager: s
|
|
3345
|
-
}), this.registrationFailedOutOfCallSubscriber = new
|
|
3469
|
+
}), this.registrationFailedOutOfCallSubscriber = new fn({
|
|
3346
3470
|
connectionManager: t,
|
|
3347
3471
|
callManager: s
|
|
3348
|
-
}), this.attemptsState = new
|
|
3472
|
+
}), this.attemptsState = new pn({
|
|
3349
3473
|
onStatusChange: this.emitStatusChange
|
|
3350
|
-
}), this.cancelableRequestBeforeRetry = new
|
|
3351
|
-
i?.timeoutBetweenAttempts ??
|
|
3352
|
-
), this.notActiveCallSubscriber = new
|
|
3474
|
+
}), this.cancelableRequestBeforeRetry = new Y(r), this.delayBetweenAttempts = new Je(
|
|
3475
|
+
i?.timeoutBetweenAttempts ?? Mn
|
|
3476
|
+
), this.notActiveCallSubscriber = new te({ callManager: s });
|
|
3353
3477
|
}
|
|
3354
3478
|
start(e) {
|
|
3355
3479
|
d("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToNotActiveCall(e);
|
|
@@ -3400,7 +3524,7 @@ class Cn {
|
|
|
3400
3524
|
});
|
|
3401
3525
|
}
|
|
3402
3526
|
async attemptConnection(e) {
|
|
3403
|
-
if (d("attemptConnection: attempts.count", this.attemptsState.count), this.events.trigger(
|
|
3527
|
+
if (d("attemptConnection: attempts.count", this.attemptsState.count), this.events.trigger(v.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
|
|
3404
3528
|
d("attemptConnection: limit reached"), this.handleLimitReached(e);
|
|
3405
3529
|
return;
|
|
3406
3530
|
}
|
|
@@ -3414,25 +3538,25 @@ class Cn {
|
|
|
3414
3538
|
}
|
|
3415
3539
|
}
|
|
3416
3540
|
handleConnectionError(e, t) {
|
|
3417
|
-
if (
|
|
3418
|
-
this.attemptsState.finishAttempt(), this.events.trigger(
|
|
3541
|
+
if (gn(e)) {
|
|
3542
|
+
this.attemptsState.finishAttempt(), this.events.trigger(v.STOP_ATTEMPTS_BY_ERROR, e);
|
|
3419
3543
|
return;
|
|
3420
3544
|
}
|
|
3421
3545
|
if (!this.canRetryOnError(e)) {
|
|
3422
|
-
d("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(
|
|
3546
|
+
d("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(v.STOP_ATTEMPTS_BY_ERROR, e);
|
|
3423
3547
|
return;
|
|
3424
3548
|
}
|
|
3425
|
-
if (
|
|
3426
|
-
d("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(
|
|
3549
|
+
if (Ze(e)) {
|
|
3550
|
+
d("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(v.CANCELLED_ATTEMPTS, e);
|
|
3427
3551
|
return;
|
|
3428
3552
|
}
|
|
3429
3553
|
d("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
|
|
3430
3554
|
}
|
|
3431
3555
|
handleLimitReached(e) {
|
|
3432
|
-
this.attemptsState.finishAttempt(), this.events.trigger(
|
|
3556
|
+
this.attemptsState.finishAttempt(), this.events.trigger(v.LIMIT_REACHED_ATTEMPTS, new Error(oe.LIMIT_REACHED)), this.startCheckTelephony(e);
|
|
3433
3557
|
}
|
|
3434
3558
|
handleSucceededAttempt(e) {
|
|
3435
|
-
d("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(
|
|
3559
|
+
d("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(v.SUCCESS);
|
|
3436
3560
|
}
|
|
3437
3561
|
subscribeToConnectTriggers(e) {
|
|
3438
3562
|
this.startPingRequester(e), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
|
|
@@ -3486,12 +3610,12 @@ class Cn {
|
|
|
3486
3610
|
}
|
|
3487
3611
|
connectIfDisconnected(e) {
|
|
3488
3612
|
const t = this.isConnectionUnavailable();
|
|
3489
|
-
d("connectIfDisconnected: isUnavailable", t), t ? this.restartConnectionAttempts(e) : (this.stopConnectTriggers(), this.events.trigger(
|
|
3613
|
+
d("connectIfDisconnected: isUnavailable", t), t ? this.restartConnectionAttempts(e) : (this.stopConnectTriggers(), this.events.trigger(v.SUCCESS));
|
|
3490
3614
|
}
|
|
3491
3615
|
scheduleReconnect(e) {
|
|
3492
3616
|
d("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (d("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (d("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
|
|
3493
|
-
const s = t instanceof Error ? t : new Error(
|
|
3494
|
-
this.attemptsState.finishAttempt(),
|
|
3617
|
+
const s = t instanceof Error ? t : new Error(oe.FAILED_TO_RECONNECT);
|
|
3618
|
+
this.attemptsState.finishAttempt(), Qe(t) || ze(t) ? this.events.trigger(v.CANCELLED_ATTEMPTS, s) : this.events.trigger(v.FAILED_ALL_ATTEMPTS, s), d("scheduleReconnect: error", t);
|
|
3495
3619
|
});
|
|
3496
3620
|
}
|
|
3497
3621
|
isConnectionUnavailable() {
|
|
@@ -3499,30 +3623,30 @@ class Cn {
|
|
|
3499
3623
|
return e || t || s;
|
|
3500
3624
|
}
|
|
3501
3625
|
emitStatusChange = ({ isInProgress: e }) => {
|
|
3502
|
-
this.events.trigger(
|
|
3626
|
+
this.events.trigger(v.CHANGED_ATTEMPT_STATUS, { isInProgress: e });
|
|
3503
3627
|
};
|
|
3504
3628
|
}
|
|
3505
|
-
var
|
|
3506
|
-
const
|
|
3507
|
-
class
|
|
3629
|
+
var j = /* @__PURE__ */ ((n) => (n.STATE_CHANGED = "state-changed", n.STATE_RESET = "state-reset", n))(j || {});
|
|
3630
|
+
const Le = ["state-changed", "state-reset"], Pn = () => new R(Le);
|
|
3631
|
+
class yn {
|
|
3508
3632
|
events;
|
|
3509
3633
|
state = {};
|
|
3510
3634
|
constructor() {
|
|
3511
|
-
this.events =
|
|
3635
|
+
this.events = Pn();
|
|
3512
3636
|
}
|
|
3513
3637
|
getState() {
|
|
3514
3638
|
return { ...this.state };
|
|
3515
3639
|
}
|
|
3516
3640
|
updateState(e) {
|
|
3517
3641
|
const t = { ...this.state };
|
|
3518
|
-
this.state = { ...this.state, ...e }, this.events.trigger(
|
|
3642
|
+
this.state = { ...this.state, ...e }, this.events.trigger(j.STATE_CHANGED, {
|
|
3519
3643
|
previous: t,
|
|
3520
3644
|
current: this.state,
|
|
3521
3645
|
updates: e
|
|
3522
3646
|
});
|
|
3523
3647
|
}
|
|
3524
3648
|
reset() {
|
|
3525
|
-
this.state = {}, this.events.trigger(
|
|
3649
|
+
this.state = {}, this.events.trigger(j.STATE_RESET, {});
|
|
3526
3650
|
}
|
|
3527
3651
|
getToken() {
|
|
3528
3652
|
return this.state.token;
|
|
@@ -3558,15 +3682,142 @@ class Nn {
|
|
|
3558
3682
|
this.events.off(e, t);
|
|
3559
3683
|
}
|
|
3560
3684
|
}
|
|
3561
|
-
|
|
3562
|
-
|
|
3685
|
+
const Ln = G({
|
|
3686
|
+
types: {
|
|
3687
|
+
context: {},
|
|
3688
|
+
events: {}
|
|
3689
|
+
},
|
|
3690
|
+
actions: {
|
|
3691
|
+
setCodec: M(({ event: n }) => "codec" in n ? { codec: n.codec } : {}),
|
|
3692
|
+
clearCodec: M({ codec: void 0 })
|
|
3693
|
+
}
|
|
3694
|
+
}).createMachine({
|
|
3695
|
+
id: "contented-stream",
|
|
3696
|
+
initial: "contented-stream:not-available",
|
|
3697
|
+
context: {},
|
|
3698
|
+
states: {
|
|
3699
|
+
"contented-stream:not-available": {
|
|
3700
|
+
on: {
|
|
3701
|
+
"CONTENTED_STREAM.AVAILABLE": {
|
|
3702
|
+
target: "contented-stream:available",
|
|
3703
|
+
actions: "setCodec"
|
|
3704
|
+
}
|
|
3705
|
+
}
|
|
3706
|
+
},
|
|
3707
|
+
"contented-stream:available": {
|
|
3708
|
+
on: {
|
|
3709
|
+
"CONTENTED_STREAM.NOT_AVAILABLE": {
|
|
3710
|
+
target: "contented-stream:not-available",
|
|
3711
|
+
actions: "clearCodec"
|
|
3712
|
+
},
|
|
3713
|
+
"CONTENTED_STREAM.AVAILABLE": {
|
|
3714
|
+
target: "contented-stream:available",
|
|
3715
|
+
actions: "setCodec",
|
|
3716
|
+
reenter: !0
|
|
3717
|
+
},
|
|
3718
|
+
"CONTENTED_STREAM.RESET": {
|
|
3719
|
+
target: "contented-stream:not-available",
|
|
3720
|
+
actions: "clearCodec"
|
|
3721
|
+
}
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
}
|
|
3725
|
+
});
|
|
3726
|
+
class wn extends V {
|
|
3727
|
+
constructor() {
|
|
3728
|
+
super(Ln);
|
|
3729
|
+
}
|
|
3730
|
+
get isAvailable() {
|
|
3731
|
+
return this.state === "contented-stream:available";
|
|
3732
|
+
}
|
|
3733
|
+
get isNotAvailable() {
|
|
3734
|
+
return this.state === "contented-stream:not-available";
|
|
3735
|
+
}
|
|
3736
|
+
get codec() {
|
|
3737
|
+
return this.getSnapshot().context.codec;
|
|
3738
|
+
}
|
|
3739
|
+
getStateInfo() {
|
|
3740
|
+
return {
|
|
3741
|
+
isAvailable: this.isAvailable,
|
|
3742
|
+
codec: this.codec
|
|
3743
|
+
};
|
|
3744
|
+
}
|
|
3745
|
+
reset() {
|
|
3746
|
+
this.send({ type: "CONTENTED_STREAM.RESET" });
|
|
3747
|
+
}
|
|
3748
|
+
send(e) {
|
|
3749
|
+
if (!this.getSnapshot().can(e)) {
|
|
3750
|
+
console.warn(
|
|
3751
|
+
`[ContentedStreamStateMachine] Invalid transition: ${e.type} from ${this.state}. Event cannot be processed in current state.`
|
|
3752
|
+
);
|
|
3753
|
+
return;
|
|
3754
|
+
}
|
|
3755
|
+
super.send(e);
|
|
3756
|
+
}
|
|
3757
|
+
subscribeToApiEvents(e) {
|
|
3758
|
+
this.addSubscription(
|
|
3759
|
+
e.on("contented-stream:available", (t) => {
|
|
3760
|
+
this.send({ type: "CONTENTED_STREAM.AVAILABLE", codec: t.codec });
|
|
3761
|
+
})
|
|
3762
|
+
), this.addSubscription(
|
|
3763
|
+
e.on("contented-stream:not-available", () => {
|
|
3764
|
+
this.send({ type: "CONTENTED_STREAM.NOT_AVAILABLE" });
|
|
3765
|
+
})
|
|
3766
|
+
);
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
var K = /* @__PURE__ */ ((n) => (n.AVAILABLE = "available", n.NOT_AVAILABLE = "not-available", n))(K || {});
|
|
3770
|
+
const Un = [
|
|
3771
|
+
"available",
|
|
3772
|
+
"not-available"
|
|
3773
|
+
/* NOT_AVAILABLE */
|
|
3774
|
+
], Fn = () => new R(Un);
|
|
3775
|
+
class Bn {
|
|
3776
|
+
events;
|
|
3777
|
+
stateMachine;
|
|
3778
|
+
constructor() {
|
|
3779
|
+
this.events = Fn(), this.stateMachine = new wn(), this.proxyEvents();
|
|
3780
|
+
}
|
|
3781
|
+
get isAvailable() {
|
|
3782
|
+
return this.stateMachine.isAvailable;
|
|
3783
|
+
}
|
|
3784
|
+
get codec() {
|
|
3785
|
+
return this.stateMachine.codec;
|
|
3786
|
+
}
|
|
3787
|
+
getStateInfo() {
|
|
3788
|
+
return this.stateMachine.getStateInfo();
|
|
3789
|
+
}
|
|
3790
|
+
reset() {
|
|
3791
|
+
this.stateMachine.reset();
|
|
3792
|
+
}
|
|
3793
|
+
on(e, t) {
|
|
3794
|
+
return this.events.on(e, t);
|
|
3795
|
+
}
|
|
3796
|
+
once(e, t) {
|
|
3797
|
+
return this.events.once(e, t);
|
|
3798
|
+
}
|
|
3799
|
+
off(e, t) {
|
|
3800
|
+
this.events.off(e, t);
|
|
3801
|
+
}
|
|
3802
|
+
subscribeToApiEvents(e) {
|
|
3803
|
+
this.stateMachine.subscribeToApiEvents(e.events);
|
|
3804
|
+
}
|
|
3805
|
+
proxyEvents() {
|
|
3806
|
+
this.stateMachine.onStateChange(() => {
|
|
3807
|
+
const e = this.getStateInfo();
|
|
3808
|
+
e.isAvailable ? this.events.trigger(K.AVAILABLE, { codec: e.codec }) : this.events.trigger(K.NOT_AVAILABLE, {});
|
|
3809
|
+
});
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
var k = /* @__PURE__ */ ((n) => (n.RINGING = "ringing", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(k || {});
|
|
3813
|
+
const we = [
|
|
3563
3814
|
"ringing",
|
|
3564
3815
|
"declinedIncomingCall",
|
|
3565
3816
|
"terminatedIncomingCall",
|
|
3566
3817
|
"failedIncomingCall"
|
|
3567
|
-
],
|
|
3568
|
-
var
|
|
3569
|
-
const
|
|
3818
|
+
], kn = () => new R(we);
|
|
3819
|
+
var $n = /* @__PURE__ */ ((n) => (n.IDLE = "incoming:idle", n.RINGING = "incoming:ringing", n.CONSUMED = "incoming:consumed", n.DECLINED = "incoming:declined", n.TERMINATED = "incoming:terminated", n.FAILED = "incoming:failed", n))($n || {});
|
|
3820
|
+
const Gn = G({
|
|
3570
3821
|
types: {
|
|
3571
3822
|
context: {},
|
|
3572
3823
|
events: {}
|
|
@@ -3578,11 +3829,11 @@ const In = $({
|
|
|
3578
3829
|
logStateChange: (n, e) => {
|
|
3579
3830
|
d("IncomingCallStateMachine state changed", e.state);
|
|
3580
3831
|
},
|
|
3581
|
-
rememberIncoming:
|
|
3832
|
+
rememberIncoming: M(({ event: n }) => {
|
|
3582
3833
|
const { data: e } = n;
|
|
3583
3834
|
return { remoteCallerData: e, lastReason: void 0 };
|
|
3584
3835
|
}),
|
|
3585
|
-
rememberReason:
|
|
3836
|
+
rememberReason: M(({ event: n, context: e }) => n.type === "INCOMING.CONSUMED" ? {
|
|
3586
3837
|
remoteCallerData: e.remoteCallerData,
|
|
3587
3838
|
lastReason: "incoming:consumed"
|
|
3588
3839
|
/* CONSUMED */
|
|
@@ -3599,7 +3850,7 @@ const In = $({
|
|
|
3599
3850
|
lastReason: "incoming:failed"
|
|
3600
3851
|
/* FAILED */
|
|
3601
3852
|
}),
|
|
3602
|
-
clearIncoming:
|
|
3853
|
+
clearIncoming: M(() => ({ remoteCallerData: void 0, lastReason: void 0 }))
|
|
3603
3854
|
}
|
|
3604
3855
|
}).createMachine({
|
|
3605
3856
|
id: "incoming",
|
|
@@ -3898,9 +4149,9 @@ const In = $({
|
|
|
3898
4149
|
}
|
|
3899
4150
|
}
|
|
3900
4151
|
});
|
|
3901
|
-
class
|
|
4152
|
+
class Vn extends V {
|
|
3902
4153
|
constructor({ incomingEvents: e, connectionEvents: t }) {
|
|
3903
|
-
super(
|
|
4154
|
+
super(Gn), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(t);
|
|
3904
4155
|
}
|
|
3905
4156
|
get isIdle() {
|
|
3906
4157
|
return this.state === "incoming:idle";
|
|
@@ -3968,15 +4219,15 @@ class fn extends q {
|
|
|
3968
4219
|
}
|
|
3969
4220
|
subscribeConnectionEvents(e) {
|
|
3970
4221
|
this.addSubscription(
|
|
3971
|
-
e.on(
|
|
4222
|
+
e.on(C.DISCONNECTED, () => {
|
|
3972
4223
|
this.toClearIncoming();
|
|
3973
4224
|
})
|
|
3974
4225
|
), this.addSubscription(
|
|
3975
|
-
e.on(
|
|
4226
|
+
e.on(C.REGISTRATION_FAILED, () => {
|
|
3976
4227
|
this.toClearIncoming();
|
|
3977
4228
|
})
|
|
3978
4229
|
), this.addSubscription(
|
|
3979
|
-
e.on(
|
|
4230
|
+
e.on(C.CONNECT_FAILED, () => {
|
|
3980
4231
|
this.toClearIncoming();
|
|
3981
4232
|
})
|
|
3982
4233
|
);
|
|
@@ -3985,14 +4236,14 @@ class fn extends q {
|
|
|
3985
4236
|
this.send({ type: "INCOMING.CLEAR" });
|
|
3986
4237
|
}
|
|
3987
4238
|
}
|
|
3988
|
-
const
|
|
3989
|
-
class
|
|
4239
|
+
const qn = 486, Hn = 487;
|
|
4240
|
+
class Wn {
|
|
3990
4241
|
events;
|
|
3991
4242
|
incomingStateMachine;
|
|
3992
4243
|
incomingRTCSession;
|
|
3993
4244
|
connectionManager;
|
|
3994
4245
|
constructor(e) {
|
|
3995
|
-
this.connectionManager = e, this.events =
|
|
4246
|
+
this.connectionManager = e, this.events = kn(), this.incomingStateMachine = new Vn({
|
|
3996
4247
|
incomingEvents: this.events,
|
|
3997
4248
|
connectionEvents: this.connectionManager.events
|
|
3998
4249
|
}), this.start();
|
|
@@ -4028,19 +4279,19 @@ class _n {
|
|
|
4028
4279
|
return this.incomingStateMachine.toConsumed(), this.removeIncomingSession(), e;
|
|
4029
4280
|
};
|
|
4030
4281
|
async declineToIncomingCall({
|
|
4031
|
-
statusCode: e =
|
|
4282
|
+
statusCode: e = Hn
|
|
4032
4283
|
} = {}) {
|
|
4033
4284
|
return new Promise((t, s) => {
|
|
4034
4285
|
try {
|
|
4035
4286
|
const i = this.getIncomingRTCSession(), r = this.remoteCallerData;
|
|
4036
|
-
this.removeIncomingSession(), this.events.trigger(
|
|
4287
|
+
this.removeIncomingSession(), this.events.trigger(k.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
|
|
4037
4288
|
} catch (i) {
|
|
4038
4289
|
s(i);
|
|
4039
4290
|
}
|
|
4040
4291
|
});
|
|
4041
4292
|
}
|
|
4042
4293
|
async busyIncomingCall() {
|
|
4043
|
-
return this.declineToIncomingCall({ statusCode:
|
|
4294
|
+
return this.declineToIncomingCall({ statusCode: qn });
|
|
4044
4295
|
}
|
|
4045
4296
|
on(e, t) {
|
|
4046
4297
|
return this.events.on(e, t);
|
|
@@ -4073,33 +4324,33 @@ class _n {
|
|
|
4073
4324
|
this.incomingRTCSession = e;
|
|
4074
4325
|
const t = this.remoteCallerData;
|
|
4075
4326
|
e.on("failed", (s) => {
|
|
4076
|
-
this.removeIncomingSession(), s.originator === "local" ? this.events.trigger(
|
|
4077
|
-
}), this.events.trigger(
|
|
4327
|
+
this.removeIncomingSession(), s.originator === "local" ? this.events.trigger(k.TERMINATED_INCOMING_CALL, t) : this.events.trigger(k.FAILED_INCOMING_CALL, t);
|
|
4328
|
+
}), this.events.trigger(k.RINGING, t);
|
|
4078
4329
|
}
|
|
4079
4330
|
removeIncomingSession() {
|
|
4080
4331
|
delete this.incomingRTCSession;
|
|
4081
4332
|
}
|
|
4082
4333
|
}
|
|
4083
|
-
var
|
|
4084
|
-
const
|
|
4334
|
+
var Ue = /* @__PURE__ */ ((n) => (n.SNAPSHOT_CHANGED = "snapshot-changed", n))(Ue || {});
|
|
4335
|
+
const Fe = ["snapshot-changed"], xn = () => new R(Fe), Qn = (n, e) => Object.is(n, e), ce = (n) => ({
|
|
4085
4336
|
connection: n.connection.getSnapshot(),
|
|
4086
4337
|
call: n.call.getSnapshot(),
|
|
4087
4338
|
incoming: n.incoming.getSnapshot(),
|
|
4088
4339
|
presentation: n.presentation.getSnapshot()
|
|
4089
4340
|
});
|
|
4090
|
-
class
|
|
4341
|
+
class Yn {
|
|
4091
4342
|
events;
|
|
4092
4343
|
actors;
|
|
4093
4344
|
currentSnapshot;
|
|
4094
4345
|
subscribers = /* @__PURE__ */ new Set();
|
|
4095
4346
|
actorSubscriptions = [];
|
|
4096
4347
|
constructor(e) {
|
|
4097
|
-
this.events =
|
|
4348
|
+
this.events = xn(), this.actors = {
|
|
4098
4349
|
connection: e.connectionManager.connectionActor,
|
|
4099
4350
|
call: e.callManager.callActor,
|
|
4100
4351
|
incoming: e.incomingCallManager.incomingActor,
|
|
4101
4352
|
presentation: e.presentationManager.presentationActor
|
|
4102
|
-
}, this.currentSnapshot =
|
|
4353
|
+
}, this.currentSnapshot = ce(this.actors), this.actorSubscriptions.push(
|
|
4103
4354
|
this.actors.connection.subscribe(this.notifySubscribers),
|
|
4104
4355
|
this.actors.call.subscribe(this.notifySubscribers),
|
|
4105
4356
|
this.actors.incoming.subscribe(this.notifySubscribers),
|
|
@@ -4110,14 +4361,14 @@ class bn {
|
|
|
4110
4361
|
return this.currentSnapshot;
|
|
4111
4362
|
}
|
|
4112
4363
|
subscribe(e, t, s) {
|
|
4113
|
-
const i = typeof t == "function", r = i ? e : (
|
|
4364
|
+
const i = typeof t == "function", r = i ? e : (T) => T, a = i ? t : e, o = (i ? s : void 0) ?? Qn, c = r(this.currentSnapshot), l = {
|
|
4114
4365
|
selector: r,
|
|
4115
4366
|
listener: a,
|
|
4116
4367
|
equals: o,
|
|
4117
4368
|
current: c
|
|
4118
4369
|
};
|
|
4119
|
-
return this.subscribers.add(
|
|
4120
|
-
this.subscribers.delete(
|
|
4370
|
+
return this.subscribers.add(l), () => {
|
|
4371
|
+
this.subscribers.delete(l);
|
|
4121
4372
|
};
|
|
4122
4373
|
}
|
|
4123
4374
|
stop() {
|
|
@@ -4133,20 +4384,20 @@ class bn {
|
|
|
4133
4384
|
}
|
|
4134
4385
|
notifySubscribers = () => {
|
|
4135
4386
|
const e = this.currentSnapshot;
|
|
4136
|
-
this.currentSnapshot =
|
|
4387
|
+
this.currentSnapshot = ce(this.actors);
|
|
4137
4388
|
for (const t of this.subscribers) {
|
|
4138
4389
|
const s = t.selector(this.currentSnapshot);
|
|
4139
4390
|
t.equals(t.current, s) || (t.current = s, t.listener(s));
|
|
4140
4391
|
}
|
|
4141
|
-
this.events.trigger(
|
|
4392
|
+
this.events.trigger(Ue.SNAPSHOT_CHANGED, {
|
|
4142
4393
|
previous: e,
|
|
4143
4394
|
current: this.currentSnapshot
|
|
4144
4395
|
});
|
|
4145
4396
|
};
|
|
4146
4397
|
}
|
|
4147
|
-
const
|
|
4148
|
-
var
|
|
4149
|
-
const
|
|
4398
|
+
const B = 1e3;
|
|
4399
|
+
var p = /* @__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))(p || {});
|
|
4400
|
+
const Be = ["collected"], Xn = () => new R(Be), Jn = "api/v2/rtp2webrtc/offer", zn = async ({
|
|
4150
4401
|
serverUrl: n,
|
|
4151
4402
|
conferenceNumber: e,
|
|
4152
4403
|
quality: t,
|
|
@@ -4155,7 +4406,7 @@ const De = ["collected"], Dn = () => new A(De), yn = "api/v2/rtp2webrtc/offer",
|
|
|
4155
4406
|
token: r
|
|
4156
4407
|
}) => {
|
|
4157
4408
|
const a = new URL(
|
|
4158
|
-
`https://${n.replace(/\/$/, "")}/${
|
|
4409
|
+
`https://${n.replace(/\/$/, "")}/${Jn}/${encodeURIComponent(e)}`
|
|
4159
4410
|
);
|
|
4160
4411
|
a.searchParams.set("quality", t), a.searchParams.set("audio", String(s));
|
|
4161
4412
|
const o = {
|
|
@@ -4170,18 +4421,18 @@ const De = ["collected"], Dn = () => new A(De), yn = "api/v2/rtp2webrtc/offer",
|
|
|
4170
4421
|
});
|
|
4171
4422
|
if (!c.ok)
|
|
4172
4423
|
throw new Error(`sendOffer failed with status ${c.status}`);
|
|
4173
|
-
const
|
|
4424
|
+
const l = await c.json();
|
|
4174
4425
|
return {
|
|
4175
|
-
type:
|
|
4176
|
-
sdp:
|
|
4426
|
+
type: l.type,
|
|
4427
|
+
sdp: l.sdp,
|
|
4177
4428
|
toJSON() {
|
|
4178
|
-
return
|
|
4429
|
+
return l;
|
|
4179
4430
|
}
|
|
4180
4431
|
};
|
|
4181
|
-
},
|
|
4432
|
+
}, de = () => "performance" in window ? performance.now() : Date.now(), q = (n) => [...n.keys()].reduce((e, t) => {
|
|
4182
4433
|
const s = n.get(t);
|
|
4183
4434
|
return s === void 0 ? e : { ...e, [s.type]: s };
|
|
4184
|
-
}, {}),
|
|
4435
|
+
}, {}), jn = (n) => {
|
|
4185
4436
|
if (!n)
|
|
4186
4437
|
return {
|
|
4187
4438
|
outboundRtp: void 0,
|
|
@@ -4189,14 +4440,14 @@ const De = ["collected"], Dn = () => new A(De), yn = "api/v2/rtp2webrtc/offer",
|
|
|
4189
4440
|
mediaSource: void 0,
|
|
4190
4441
|
remoteInboundRtp: void 0
|
|
4191
4442
|
};
|
|
4192
|
-
const e =
|
|
4443
|
+
const e = q(n);
|
|
4193
4444
|
return {
|
|
4194
|
-
outboundRtp: e[
|
|
4195
|
-
codec: e[
|
|
4196
|
-
mediaSource: e[
|
|
4197
|
-
remoteInboundRtp: e[
|
|
4445
|
+
outboundRtp: e[p.OUTBOUND_RTP],
|
|
4446
|
+
codec: e[p.CODEC],
|
|
4447
|
+
mediaSource: e[p.MEDIA_SOURCE],
|
|
4448
|
+
remoteInboundRtp: e[p.REMOTE_INBOUND_RTP]
|
|
4198
4449
|
};
|
|
4199
|
-
},
|
|
4450
|
+
}, he = (n) => {
|
|
4200
4451
|
if (!n)
|
|
4201
4452
|
return {
|
|
4202
4453
|
outboundRtp: void 0,
|
|
@@ -4204,14 +4455,14 @@ const De = ["collected"], Dn = () => new A(De), yn = "api/v2/rtp2webrtc/offer",
|
|
|
4204
4455
|
mediaSource: void 0,
|
|
4205
4456
|
remoteInboundRtp: void 0
|
|
4206
4457
|
};
|
|
4207
|
-
const e =
|
|
4458
|
+
const e = q(n);
|
|
4208
4459
|
return {
|
|
4209
|
-
outboundRtp: e[
|
|
4210
|
-
codec: e[
|
|
4211
|
-
mediaSource: e[
|
|
4212
|
-
remoteInboundRtp: e[
|
|
4460
|
+
outboundRtp: e[p.OUTBOUND_RTP],
|
|
4461
|
+
codec: e[p.CODEC],
|
|
4462
|
+
mediaSource: e[p.MEDIA_SOURCE],
|
|
4463
|
+
remoteInboundRtp: e[p.REMOTE_INBOUND_RTP]
|
|
4213
4464
|
};
|
|
4214
|
-
},
|
|
4465
|
+
}, le = ({
|
|
4215
4466
|
videoReceiversStats: n,
|
|
4216
4467
|
synchronizationSourcesVideo: e
|
|
4217
4468
|
}) => {
|
|
@@ -4221,13 +4472,13 @@ const De = ["collected"], Dn = () => new A(De), yn = "api/v2/rtp2webrtc/offer",
|
|
|
4221
4472
|
codec: void 0,
|
|
4222
4473
|
synchronizationSources: e
|
|
4223
4474
|
};
|
|
4224
|
-
const t =
|
|
4475
|
+
const t = q(n);
|
|
4225
4476
|
return {
|
|
4226
|
-
inboundRtp: t[
|
|
4227
|
-
codec: t[
|
|
4477
|
+
inboundRtp: t[p.INBOUND_RTP],
|
|
4478
|
+
codec: t[p.CODEC],
|
|
4228
4479
|
synchronizationSources: e
|
|
4229
4480
|
};
|
|
4230
|
-
},
|
|
4481
|
+
}, Kn = ({
|
|
4231
4482
|
audioReceiverStats: n,
|
|
4232
4483
|
synchronizationSourcesAudio: e
|
|
4233
4484
|
}) => {
|
|
@@ -4238,14 +4489,14 @@ const De = ["collected"], Dn = () => new A(De), yn = "api/v2/rtp2webrtc/offer",
|
|
|
4238
4489
|
remoteOutboundRtp: void 0,
|
|
4239
4490
|
synchronizationSources: e
|
|
4240
4491
|
};
|
|
4241
|
-
const t =
|
|
4492
|
+
const t = q(n);
|
|
4242
4493
|
return {
|
|
4243
|
-
inboundRtp: t[
|
|
4244
|
-
codec: t[
|
|
4245
|
-
remoteOutboundRtp: t[
|
|
4494
|
+
inboundRtp: t[p.INBOUND_RTP],
|
|
4495
|
+
codec: t[p.CODEC],
|
|
4496
|
+
remoteOutboundRtp: t[p.REMOTE_OUTBOUND_RTP],
|
|
4246
4497
|
synchronizationSources: e
|
|
4247
4498
|
};
|
|
4248
|
-
},
|
|
4499
|
+
}, ke = (n) => {
|
|
4249
4500
|
if (!n)
|
|
4250
4501
|
return {
|
|
4251
4502
|
candidatePair: void 0,
|
|
@@ -4254,47 +4505,47 @@ const De = ["collected"], Dn = () => new A(De), yn = "api/v2/rtp2webrtc/offer",
|
|
|
4254
4505
|
remoteCandidate: void 0,
|
|
4255
4506
|
transport: void 0
|
|
4256
4507
|
};
|
|
4257
|
-
const e =
|
|
4508
|
+
const e = q(n);
|
|
4258
4509
|
return {
|
|
4259
|
-
candidatePair: e[
|
|
4260
|
-
certificate: e[
|
|
4261
|
-
localCandidate: e[
|
|
4262
|
-
remoteCandidate: e[
|
|
4263
|
-
transport: e[
|
|
4510
|
+
candidatePair: e[p.CANDIDATE_PAIR],
|
|
4511
|
+
certificate: e[p.CERTIFICATE],
|
|
4512
|
+
localCandidate: e[p.LOCAL_CANDIDATE],
|
|
4513
|
+
remoteCandidate: e[p.REMOTE_CANDIDATE],
|
|
4514
|
+
transport: e[p.TRANSPORT]
|
|
4264
4515
|
};
|
|
4265
|
-
},
|
|
4516
|
+
}, Zn = ({
|
|
4266
4517
|
audioSenderStats: n,
|
|
4267
4518
|
videoSenderFirstStats: e,
|
|
4268
4519
|
videoSenderSecondStats: t
|
|
4269
4520
|
}) => ({
|
|
4270
|
-
video:
|
|
4271
|
-
secondVideo:
|
|
4272
|
-
audio:
|
|
4273
|
-
additional:
|
|
4521
|
+
video: he(e),
|
|
4522
|
+
secondVideo: he(t),
|
|
4523
|
+
audio: jn(n),
|
|
4524
|
+
additional: ke(
|
|
4274
4525
|
n ?? e ?? t
|
|
4275
4526
|
)
|
|
4276
|
-
}),
|
|
4527
|
+
}), es = ({
|
|
4277
4528
|
audioReceiverStats: n,
|
|
4278
4529
|
videoReceiverFirstStats: e,
|
|
4279
4530
|
videoReceiverSecondStats: t,
|
|
4280
4531
|
synchronizationSources: s
|
|
4281
4532
|
}) => ({
|
|
4282
|
-
video:
|
|
4533
|
+
video: le({
|
|
4283
4534
|
videoReceiversStats: e,
|
|
4284
4535
|
synchronizationSourcesVideo: s.video
|
|
4285
4536
|
}),
|
|
4286
|
-
secondVideo:
|
|
4537
|
+
secondVideo: le({
|
|
4287
4538
|
videoReceiversStats: t,
|
|
4288
4539
|
synchronizationSourcesVideo: s.video
|
|
4289
4540
|
}),
|
|
4290
|
-
audio:
|
|
4541
|
+
audio: Kn({
|
|
4291
4542
|
audioReceiverStats: n,
|
|
4292
4543
|
synchronizationSourcesAudio: s.audio
|
|
4293
4544
|
}),
|
|
4294
|
-
additional:
|
|
4545
|
+
additional: ke(
|
|
4295
4546
|
n ?? e ?? t
|
|
4296
4547
|
)
|
|
4297
|
-
}),
|
|
4548
|
+
}), ts = ({
|
|
4298
4549
|
audioSenderStats: n,
|
|
4299
4550
|
videoSenderFirstStats: e,
|
|
4300
4551
|
videoSenderSecondStats: t,
|
|
@@ -4303,11 +4554,11 @@ const De = ["collected"], Dn = () => new A(De), yn = "api/v2/rtp2webrtc/offer",
|
|
|
4303
4554
|
videoReceiverSecondStats: r,
|
|
4304
4555
|
synchronizationSources: a
|
|
4305
4556
|
}) => {
|
|
4306
|
-
const o =
|
|
4557
|
+
const o = Zn({
|
|
4307
4558
|
audioSenderStats: n,
|
|
4308
4559
|
videoSenderFirstStats: e,
|
|
4309
4560
|
videoSenderSecondStats: t
|
|
4310
|
-
}), c =
|
|
4561
|
+
}), c = es({
|
|
4311
4562
|
audioReceiverStats: s,
|
|
4312
4563
|
videoReceiverFirstStats: i,
|
|
4313
4564
|
videoReceiverSecondStats: r,
|
|
@@ -4317,16 +4568,16 @@ const De = ["collected"], Dn = () => new A(De), yn = "api/v2/rtp2webrtc/offer",
|
|
|
4317
4568
|
outbound: o,
|
|
4318
4569
|
inbound: c
|
|
4319
4570
|
};
|
|
4320
|
-
},
|
|
4321
|
-
const e = "audio", t = "video", s = n.getSenders(), i = s.find((E) => E.track?.kind === e), r = s.filter((E) => E.track?.kind === t), a = n.getReceivers(), o = a.find((E) => E.track.kind === e), c = a.filter((E) => E.track.kind === t),
|
|
4571
|
+
}, ns = async (n) => {
|
|
4572
|
+
const e = "audio", t = "video", s = n.getSenders(), i = s.find((E) => E.track?.kind === e), r = s.filter((E) => E.track?.kind === t), a = n.getReceivers(), o = a.find((E) => E.track.kind === e), c = a.filter((E) => E.track.kind === t), l = {
|
|
4322
4573
|
trackIdentifier: o?.track.id,
|
|
4323
4574
|
item: o?.getSynchronizationSources()[0]
|
|
4324
|
-
},
|
|
4575
|
+
}, T = {
|
|
4325
4576
|
trackIdentifier: c[0]?.track.id,
|
|
4326
4577
|
item: c[0]?.getSynchronizationSources()[0]
|
|
4327
|
-
},
|
|
4328
|
-
audio:
|
|
4329
|
-
video:
|
|
4578
|
+
}, u = {
|
|
4579
|
+
audio: l,
|
|
4580
|
+
video: T
|
|
4330
4581
|
};
|
|
4331
4582
|
return Promise.all([
|
|
4332
4583
|
i?.getStats() ?? Promise.resolve(void 0),
|
|
@@ -4338,38 +4589,38 @@ const De = ["collected"], Dn = () => new A(De), yn = "api/v2/rtp2webrtc/offer",
|
|
|
4338
4589
|
]).then((E) => {
|
|
4339
4590
|
const [
|
|
4340
4591
|
m,
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4592
|
+
D,
|
|
4593
|
+
A,
|
|
4594
|
+
w,
|
|
4595
|
+
X,
|
|
4596
|
+
xe
|
|
4346
4597
|
] = E;
|
|
4347
4598
|
return {
|
|
4348
|
-
synchronizationSources:
|
|
4599
|
+
synchronizationSources: u,
|
|
4349
4600
|
audioSenderStats: m,
|
|
4350
|
-
videoSenderFirstStats:
|
|
4351
|
-
videoSenderSecondStats:
|
|
4352
|
-
audioReceiverStats:
|
|
4353
|
-
videoReceiverFirstStats:
|
|
4354
|
-
videoReceiverSecondStats:
|
|
4601
|
+
videoSenderFirstStats: D,
|
|
4602
|
+
videoSenderSecondStats: A,
|
|
4603
|
+
audioReceiverStats: w,
|
|
4604
|
+
videoReceiverFirstStats: X,
|
|
4605
|
+
videoReceiverSecondStats: xe
|
|
4355
4606
|
};
|
|
4356
4607
|
});
|
|
4357
|
-
},
|
|
4608
|
+
}, ss = (n) => {
|
|
4358
4609
|
d(String(n));
|
|
4359
4610
|
};
|
|
4360
|
-
class
|
|
4611
|
+
class is {
|
|
4361
4612
|
events;
|
|
4362
4613
|
setTimeoutRequest;
|
|
4363
|
-
requesterAllStatistics = new
|
|
4614
|
+
requesterAllStatistics = new Y(ns);
|
|
4364
4615
|
constructor() {
|
|
4365
|
-
this.events =
|
|
4616
|
+
this.events = Xn(), this.setTimeoutRequest = new ue();
|
|
4366
4617
|
}
|
|
4367
4618
|
get requested() {
|
|
4368
4619
|
return this.setTimeoutRequest.requested;
|
|
4369
4620
|
}
|
|
4370
4621
|
start(e, {
|
|
4371
|
-
interval: t =
|
|
4372
|
-
onError: s =
|
|
4622
|
+
interval: t = B,
|
|
4623
|
+
onError: s = ss
|
|
4373
4624
|
} = {}) {
|
|
4374
4625
|
this.stop(), this.setTimeoutRequest.request(() => {
|
|
4375
4626
|
this.collectStatistics(e, {
|
|
@@ -4398,12 +4649,12 @@ class qn {
|
|
|
4398
4649
|
collectStatistics = (e, {
|
|
4399
4650
|
onError: t
|
|
4400
4651
|
}) => {
|
|
4401
|
-
const s =
|
|
4402
|
-
this.
|
|
4403
|
-
this.events.trigger("collected",
|
|
4404
|
-
const a =
|
|
4405
|
-
let o =
|
|
4406
|
-
a > 48 ? o =
|
|
4652
|
+
const s = de();
|
|
4653
|
+
this.requestAllStatistics(e).then((i) => {
|
|
4654
|
+
this.events.trigger("collected", ts(i));
|
|
4655
|
+
const a = de() - s;
|
|
4656
|
+
let o = B;
|
|
4657
|
+
a > 48 ? o = B * 4 : a > 32 ? o = B * 3 : a > 16 && (o = B * 2), this.start(e, {
|
|
4407
4658
|
onError: t,
|
|
4408
4659
|
interval: o
|
|
4409
4660
|
});
|
|
@@ -4411,9 +4662,15 @@ class qn {
|
|
|
4411
4662
|
t && t(i);
|
|
4412
4663
|
});
|
|
4413
4664
|
};
|
|
4665
|
+
requestAllStatistics = async (e) => {
|
|
4666
|
+
const t = e();
|
|
4667
|
+
if (t === void 0)
|
|
4668
|
+
throw new Error("failed to collect statistics: peerConnection is not defined");
|
|
4669
|
+
return this.requesterAllStatistics.request(t);
|
|
4670
|
+
};
|
|
4414
4671
|
}
|
|
4415
|
-
const
|
|
4416
|
-
class
|
|
4672
|
+
const rs = 500;
|
|
4673
|
+
class as {
|
|
4417
4674
|
statsPeerConnection;
|
|
4418
4675
|
availableStats;
|
|
4419
4676
|
previousAvailableStats;
|
|
@@ -4423,7 +4680,7 @@ class Vn {
|
|
|
4423
4680
|
callManager: e,
|
|
4424
4681
|
apiManager: t
|
|
4425
4682
|
}) {
|
|
4426
|
-
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new
|
|
4683
|
+
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new is(), this.subscribe();
|
|
4427
4684
|
}
|
|
4428
4685
|
get events() {
|
|
4429
4686
|
return this.statsPeerConnection.events;
|
|
@@ -4473,7 +4730,7 @@ class Vn {
|
|
|
4473
4730
|
return this.previousInboundRtp?.packetsReceived;
|
|
4474
4731
|
}
|
|
4475
4732
|
get isReceivingPackets() {
|
|
4476
|
-
const e = this.packetsReceived !== void 0 && this.packetsReceived >=
|
|
4733
|
+
const e = this.packetsReceived !== void 0 && this.packetsReceived >= rs, t = this.packetsReceived !== this.previousPacketsReceived;
|
|
4477
4734
|
return e && t;
|
|
4478
4735
|
}
|
|
4479
4736
|
on(e, t) {
|
|
@@ -4501,8 +4758,8 @@ class Vn {
|
|
|
4501
4758
|
handleStatsCollected = (e) => {
|
|
4502
4759
|
this.previousAvailableStats = this.availableStats, this.availableStats = e, this.maybeSendStats();
|
|
4503
4760
|
};
|
|
4504
|
-
handleStarted = (
|
|
4505
|
-
this.statsPeerConnection.start(
|
|
4761
|
+
handleStarted = () => {
|
|
4762
|
+
this.statsPeerConnection.start(this.callManager.getActivePeerConnection);
|
|
4506
4763
|
};
|
|
4507
4764
|
handleEnded = () => {
|
|
4508
4765
|
this.statsPeerConnection.stop(), this.availableStats = void 0, this.previousAvailableStats = void 0;
|
|
@@ -4513,33 +4770,33 @@ class Vn {
|
|
|
4513
4770
|
});
|
|
4514
4771
|
}
|
|
4515
4772
|
}
|
|
4516
|
-
const
|
|
4773
|
+
const os = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), cs = (n) => {
|
|
4517
4774
|
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
|
|
4518
|
-
return
|
|
4519
|
-
},
|
|
4775
|
+
return os(s, i);
|
|
4776
|
+
}, ds = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
|
|
4520
4777
|
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;
|
|
4521
4778
|
return a - o;
|
|
4522
|
-
}),
|
|
4779
|
+
}), hs = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), ls = (n, {
|
|
4523
4780
|
preferredMimeTypesVideoCodecs: e,
|
|
4524
4781
|
excludeMimeTypesVideoCodecs: t
|
|
4525
4782
|
}) => {
|
|
4526
4783
|
try {
|
|
4527
4784
|
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
4528
|
-
const s =
|
|
4785
|
+
const s = cs("video"), i = hs(s, t), r = ds(i, e);
|
|
4529
4786
|
n.setCodecPreferences(r);
|
|
4530
4787
|
}
|
|
4531
4788
|
} catch (s) {
|
|
4532
4789
|
d("setCodecPreferences error", s);
|
|
4533
4790
|
}
|
|
4534
|
-
},
|
|
4535
|
-
class
|
|
4791
|
+
}, gs = (n) => [...n.keys()].map((e) => n.get(e)), us = (n, e) => gs(n).find((t) => t?.type === e), Ts = async (n) => n.getStats().then((e) => us(e, "codec")?.mimeType);
|
|
4792
|
+
class Es {
|
|
4536
4793
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
4537
4794
|
async getCodecFromSender(e) {
|
|
4538
|
-
return await
|
|
4795
|
+
return await Ts(e) ?? "";
|
|
4539
4796
|
}
|
|
4540
4797
|
}
|
|
4541
|
-
class
|
|
4542
|
-
stackPromises =
|
|
4798
|
+
class Ss {
|
|
4799
|
+
stackPromises = Ee({
|
|
4543
4800
|
noRunIsNotActual: !0
|
|
4544
4801
|
});
|
|
4545
4802
|
/**
|
|
@@ -4563,30 +4820,30 @@ class Zn {
|
|
|
4563
4820
|
});
|
|
4564
4821
|
}
|
|
4565
4822
|
}
|
|
4566
|
-
class
|
|
4823
|
+
class Cs {
|
|
4567
4824
|
taskQueue;
|
|
4568
4825
|
onSetParameters;
|
|
4569
4826
|
constructor(e) {
|
|
4570
|
-
this.onSetParameters = e, this.taskQueue = new
|
|
4827
|
+
this.onSetParameters = e, this.taskQueue = new Ss();
|
|
4571
4828
|
}
|
|
4572
4829
|
async setEncodingsToSender(e, t) {
|
|
4573
|
-
return this.taskQueue.add(async () =>
|
|
4830
|
+
return this.taskQueue.add(async () => fe(e, t, this.onSetParameters));
|
|
4574
4831
|
}
|
|
4575
4832
|
stop() {
|
|
4576
4833
|
this.taskQueue.stop();
|
|
4577
4834
|
}
|
|
4578
4835
|
}
|
|
4579
|
-
const
|
|
4580
|
-
const t =
|
|
4581
|
-
return
|
|
4582
|
-
},
|
|
4836
|
+
const $e = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), ps = 1e6, b = (n) => n * ps, Ge = b(0.06), Ve = b(4), ms = (n) => n <= 64 ? Ge : n <= 128 ? b(0.12) : n <= 256 ? b(0.25) : n <= 384 ? b(0.32) : n <= 426 ? b(0.38) : n <= 640 ? b(0.5) : n <= 848 ? b(0.7) : n <= 1280 ? b(1) : n <= 1920 ? b(2) : Ve, Ns = "av1", As = (n) => $e(n, Ns), Rs = 0.6, ne = (n, e) => As(e) ? n * Rs : n, Is = (n) => ne(Ge, n), vs = (n) => ne(Ve, n), ge = (n, e) => {
|
|
4837
|
+
const t = ms(n);
|
|
4838
|
+
return ne(t, e);
|
|
4839
|
+
}, z = 1, fs = ({
|
|
4583
4840
|
videoTrack: n,
|
|
4584
4841
|
targetSize: e
|
|
4585
4842
|
}) => {
|
|
4586
|
-
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ?
|
|
4587
|
-
return Math.max(r, a,
|
|
4843
|
+
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? z : s / e.width, a = i === void 0 ? z : i / e.height;
|
|
4844
|
+
return Math.max(r, a, z);
|
|
4588
4845
|
};
|
|
4589
|
-
class
|
|
4846
|
+
class Ms {
|
|
4590
4847
|
ignoreForCodec;
|
|
4591
4848
|
senderFinder;
|
|
4592
4849
|
codecProvider;
|
|
@@ -4619,7 +4876,7 @@ class ds {
|
|
|
4619
4876
|
if (!i?.track)
|
|
4620
4877
|
return { ...this.resultNoChanged, sender: i };
|
|
4621
4878
|
const r = await this.codecProvider.getCodecFromSender(i);
|
|
4622
|
-
if (
|
|
4879
|
+
if ($e(r, this.ignoreForCodec))
|
|
4623
4880
|
return { ...this.resultNoChanged, sender: i };
|
|
4624
4881
|
const { mainCam: a, resolutionMainCam: o } = t ?? {};
|
|
4625
4882
|
return this.processSender(
|
|
@@ -4639,14 +4896,14 @@ class ds {
|
|
|
4639
4896
|
async processSender(e, t) {
|
|
4640
4897
|
const { mainCam: s, resolutionMainCam: i } = e;
|
|
4641
4898
|
switch (s) {
|
|
4642
|
-
case
|
|
4899
|
+
case f.PAUSE_MAIN_CAM:
|
|
4643
4900
|
return this.downgradeResolutionSender(t);
|
|
4644
|
-
case
|
|
4901
|
+
case f.RESUME_MAIN_CAM:
|
|
4645
4902
|
return this.setBitrateByTrackResolution(t);
|
|
4646
|
-
case
|
|
4903
|
+
case f.MAX_MAIN_CAM_RESOLUTION:
|
|
4647
4904
|
return i !== void 0 ? this.setResolutionSender(i, t) : this.setBitrateByTrackResolution(t);
|
|
4648
|
-
case
|
|
4649
|
-
case
|
|
4905
|
+
case f.ADMIN_STOP_MAIN_CAM:
|
|
4906
|
+
case f.ADMIN_START_MAIN_CAM:
|
|
4650
4907
|
case void 0:
|
|
4651
4908
|
return this.setBitrateByTrackResolution(t);
|
|
4652
4909
|
default:
|
|
@@ -4661,7 +4918,7 @@ class ds {
|
|
|
4661
4918
|
async downgradeResolutionSender(e) {
|
|
4662
4919
|
const { sender: t, codec: s } = e, i = {
|
|
4663
4920
|
scaleResolutionDownBy: 200,
|
|
4664
|
-
maxBitrate:
|
|
4921
|
+
maxBitrate: Is(s)
|
|
4665
4922
|
};
|
|
4666
4923
|
return this.parametersSetter.setEncodingsToSender(t, i);
|
|
4667
4924
|
}
|
|
@@ -4671,7 +4928,7 @@ class ds {
|
|
|
4671
4928
|
* @returns Promise с результатом
|
|
4672
4929
|
*/
|
|
4673
4930
|
async setBitrateByTrackResolution(e) {
|
|
4674
|
-
const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ?
|
|
4931
|
+
const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? vs(i) : ge(a, i);
|
|
4675
4932
|
return this.parametersSetter.setEncodingsToSender(t, {
|
|
4676
4933
|
scaleResolutionDownBy: 1,
|
|
4677
4934
|
maxBitrate: o
|
|
@@ -4687,24 +4944,24 @@ class ds {
|
|
|
4687
4944
|
const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, c = {
|
|
4688
4945
|
width: Number(s),
|
|
4689
4946
|
height: Number(i)
|
|
4690
|
-
},
|
|
4947
|
+
}, l = fs({
|
|
4691
4948
|
videoTrack: a,
|
|
4692
4949
|
targetSize: c
|
|
4693
|
-
}),
|
|
4694
|
-
scaleResolutionDownBy:
|
|
4695
|
-
maxBitrate:
|
|
4950
|
+
}), T = ge(c.width, o), u = {
|
|
4951
|
+
scaleResolutionDownBy: l,
|
|
4952
|
+
maxBitrate: T
|
|
4696
4953
|
};
|
|
4697
|
-
return this.parametersSetter.setEncodingsToSender(r,
|
|
4954
|
+
return this.parametersSetter.setEncodingsToSender(r, u);
|
|
4698
4955
|
}
|
|
4699
4956
|
}
|
|
4700
|
-
const
|
|
4701
|
-
class
|
|
4957
|
+
const _s = (n) => n.find((e) => e.track?.kind === "video");
|
|
4958
|
+
class bs {
|
|
4702
4959
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
4703
4960
|
findVideoSender(e) {
|
|
4704
|
-
return
|
|
4961
|
+
return _s(e);
|
|
4705
4962
|
}
|
|
4706
4963
|
}
|
|
4707
|
-
class
|
|
4964
|
+
class Os {
|
|
4708
4965
|
currentSender;
|
|
4709
4966
|
originalReplaceTrack;
|
|
4710
4967
|
lastWidth;
|
|
@@ -4717,7 +4974,7 @@ class gs {
|
|
|
4717
4974
|
pollIntervalMs: e = 1e3,
|
|
4718
4975
|
maxPollIntervalMs: t
|
|
4719
4976
|
}) {
|
|
4720
|
-
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new
|
|
4977
|
+
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new ue();
|
|
4721
4978
|
}
|
|
4722
4979
|
/**
|
|
4723
4980
|
* Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
|
|
@@ -4768,7 +5025,7 @@ class gs {
|
|
|
4768
5025
|
this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
|
|
4769
5026
|
}
|
|
4770
5027
|
}
|
|
4771
|
-
class
|
|
5028
|
+
class Ds {
|
|
4772
5029
|
apiManager;
|
|
4773
5030
|
currentHandler;
|
|
4774
5031
|
constructor(e) {
|
|
@@ -4788,7 +5045,7 @@ class us {
|
|
|
4788
5045
|
this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
|
|
4789
5046
|
}
|
|
4790
5047
|
}
|
|
4791
|
-
class
|
|
5048
|
+
class Ps {
|
|
4792
5049
|
eventHandler;
|
|
4793
5050
|
senderBalancer;
|
|
4794
5051
|
parametersSetterWithQueue;
|
|
@@ -4800,16 +5057,16 @@ class Ts {
|
|
|
4800
5057
|
onSetParameters: i,
|
|
4801
5058
|
pollIntervalMs: r
|
|
4802
5059
|
} = {}) {
|
|
4803
|
-
this.getConnection = t, this.eventHandler = new
|
|
5060
|
+
this.getConnection = t, this.eventHandler = new Ds(e), this.parametersSetterWithQueue = new Cs(i), this.senderBalancer = new Ms(
|
|
4804
5061
|
{
|
|
4805
|
-
senderFinder: new
|
|
4806
|
-
codecProvider: new
|
|
5062
|
+
senderFinder: new bs(),
|
|
5063
|
+
codecProvider: new Es(),
|
|
4807
5064
|
parametersSetter: this.parametersSetterWithQueue
|
|
4808
5065
|
},
|
|
4809
5066
|
{
|
|
4810
5067
|
ignoreForCodec: s
|
|
4811
5068
|
}
|
|
4812
|
-
), this.trackMonitor = new
|
|
5069
|
+
), this.trackMonitor = new Os({ pollIntervalMs: r });
|
|
4813
5070
|
}
|
|
4814
5071
|
/**
|
|
4815
5072
|
* Подписывается на события управления главной камерой
|
|
@@ -4854,13 +5111,13 @@ class Ts {
|
|
|
4854
5111
|
});
|
|
4855
5112
|
};
|
|
4856
5113
|
}
|
|
4857
|
-
const
|
|
5114
|
+
const qe = [
|
|
4858
5115
|
"balancing-scheduled",
|
|
4859
5116
|
"balancing-started",
|
|
4860
5117
|
"balancing-stopped",
|
|
4861
5118
|
"parameters-updated"
|
|
4862
|
-
],
|
|
4863
|
-
class
|
|
5119
|
+
], ys = () => new R(qe);
|
|
5120
|
+
class Ls {
|
|
4864
5121
|
isBalancingActive = !1;
|
|
4865
5122
|
events;
|
|
4866
5123
|
callManager;
|
|
@@ -4868,7 +5125,7 @@ class Ss {
|
|
|
4868
5125
|
videoSendingBalancer;
|
|
4869
5126
|
startBalancingTimer;
|
|
4870
5127
|
constructor(e, t, s = {}) {
|
|
4871
|
-
this.events =
|
|
5128
|
+
this.events = ys(), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new Ps(
|
|
4872
5129
|
t,
|
|
4873
5130
|
() => e.connection,
|
|
4874
5131
|
{
|
|
@@ -4938,13 +5195,13 @@ class Ss {
|
|
|
4938
5195
|
this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
|
|
4939
5196
|
}
|
|
4940
5197
|
}
|
|
4941
|
-
const
|
|
4942
|
-
class
|
|
5198
|
+
const He = "no-inbound-frames", We = [He], ws = () => new R(We);
|
|
5199
|
+
class Us {
|
|
4943
5200
|
events;
|
|
4944
5201
|
statsManager;
|
|
4945
5202
|
callManager;
|
|
4946
5203
|
constructor(e, t) {
|
|
4947
|
-
this.statsManager = e, this.callManager = t, this.events =
|
|
5204
|
+
this.statsManager = e, this.callManager = t, this.events = ws(), this.subscribe();
|
|
4948
5205
|
}
|
|
4949
5206
|
get mainVideoTrack() {
|
|
4950
5207
|
return this.callManager.getMainRemoteStream()?.getVideoTracks()[0];
|
|
@@ -4957,20 +5214,20 @@ class Cs {
|
|
|
4957
5214
|
return this.events.on(e, t);
|
|
4958
5215
|
}
|
|
4959
5216
|
handleStatsCollected = () => {
|
|
4960
|
-
this.hasNoIncomingFrames() && this.events.trigger(
|
|
5217
|
+
this.hasNoIncomingFrames() && this.events.trigger(He, {});
|
|
4961
5218
|
};
|
|
4962
5219
|
hasNoIncomingFrames = () => this.statsManager.isInvalidInboundFrames && this.isMutedMainVideoTrack;
|
|
4963
5220
|
subscribe() {
|
|
4964
5221
|
this.statsManager.on("collected", this.handleStatsCollected);
|
|
4965
5222
|
}
|
|
4966
5223
|
}
|
|
4967
|
-
const
|
|
4968
|
-
class
|
|
5224
|
+
const Fs = 3e3;
|
|
5225
|
+
class Bs {
|
|
4969
5226
|
renegotiateRequester;
|
|
4970
5227
|
renegotiateThrottled;
|
|
4971
5228
|
callManager;
|
|
4972
|
-
constructor(e, t =
|
|
4973
|
-
this.callManager = e, this.renegotiateRequester = new
|
|
5229
|
+
constructor(e, t = Fs) {
|
|
5230
|
+
this.callManager = e, this.renegotiateRequester = new Y(e.renegotiate.bind(e)), this.renegotiateThrottled = et.throttle(
|
|
4974
5231
|
this.requestRenegotiate.bind(this),
|
|
4975
5232
|
t
|
|
4976
5233
|
), this.subscribe();
|
|
@@ -4998,29 +5255,30 @@ class Ns {
|
|
|
4998
5255
|
d("cancel recover main stream"), this.renegotiateThrottled.cancel(), this.renegotiateRequester.cancelRequest();
|
|
4999
5256
|
}
|
|
5000
5257
|
}
|
|
5001
|
-
const
|
|
5258
|
+
const ks = 1e6, $s = ye.map((n) => `auto-connect:${n}`), Gs = be.map((n) => `connection:${n}`), Vs = Ne.map((n) => `call:${n}`), qs = Le.map((n) => `conference-state:${n}`), Hs = pe.map((n) => `api:${n}`), Ws = we.map((n) => `incoming-call:${n}`), xs = Me.map((n) => `presentation:${n}`), Qs = Be.map((n) => `stats:${n}`), Ys = qe.map((n) => `video-balancer:${n}`), Xs = We.map((n) => `main-stream-health:${n}`), Js = Fe.map((n) => `session:${n}`), zs = [
|
|
5002
5259
|
"disconnected-from-out-of-call",
|
|
5003
5260
|
"connected-with-configuration-from-out-of-call",
|
|
5004
5261
|
"stopped-presentation-by-server-command"
|
|
5005
|
-
],
|
|
5006
|
-
|
|
5007
|
-
...
|
|
5008
|
-
...
|
|
5009
|
-
...
|
|
5010
|
-
...
|
|
5011
|
-
...
|
|
5012
|
-
...
|
|
5013
|
-
...
|
|
5014
|
-
...
|
|
5015
|
-
...
|
|
5016
|
-
...
|
|
5017
|
-
...
|
|
5018
|
-
],
|
|
5019
|
-
class
|
|
5262
|
+
], js = [
|
|
5263
|
+
...$s,
|
|
5264
|
+
...Gs,
|
|
5265
|
+
...Vs,
|
|
5266
|
+
...qs,
|
|
5267
|
+
...Hs,
|
|
5268
|
+
...Ws,
|
|
5269
|
+
...xs,
|
|
5270
|
+
...Qs,
|
|
5271
|
+
...Ys,
|
|
5272
|
+
...Xs,
|
|
5273
|
+
...Js,
|
|
5274
|
+
...zs
|
|
5275
|
+
], Ks = () => new R(js);
|
|
5276
|
+
class gi {
|
|
5020
5277
|
events;
|
|
5021
5278
|
connectionManager;
|
|
5022
5279
|
connectionQueueManager;
|
|
5023
5280
|
conferenceStateManager;
|
|
5281
|
+
contentedStreamManager;
|
|
5024
5282
|
callManager;
|
|
5025
5283
|
autoConnectorManager;
|
|
5026
5284
|
apiManager;
|
|
@@ -5039,33 +5297,33 @@ class Js {
|
|
|
5039
5297
|
videoBalancerOptions: i,
|
|
5040
5298
|
autoConnectorOptions: r
|
|
5041
5299
|
} = {}) {
|
|
5042
|
-
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events =
|
|
5300
|
+
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = Ks(), this.apiManager = new dt(), this.connectionManager = new En({ JsSIP: e }), this.connectionQueueManager = new Sn({
|
|
5043
5301
|
connectionManager: this.connectionManager
|
|
5044
|
-
}), this.conferenceStateManager = new
|
|
5045
|
-
connectionManager: this.connectionManager,
|
|
5046
|
-
callManager: this.callManager
|
|
5047
|
-
}), this.incomingCallManager = new _n(this.connectionManager), this.presentationManager = new kt({
|
|
5302
|
+
}), this.conferenceStateManager = new yn(), this.contentedStreamManager = new Bn(), this.callManager = new Dt(this.conferenceStateManager, this.contentedStreamManager), this.incomingCallManager = new Wn(this.connectionManager), this.presentationManager = new Jt({
|
|
5048
5303
|
callManager: this.callManager,
|
|
5049
|
-
maxBitrate:
|
|
5050
|
-
}), this.statsManager = new
|
|
5304
|
+
maxBitrate: ks
|
|
5305
|
+
}), this.statsManager = new as({
|
|
5051
5306
|
callManager: this.callManager,
|
|
5052
5307
|
apiManager: this.apiManager
|
|
5053
|
-
}), this.autoConnectorManager = new
|
|
5308
|
+
}), this.autoConnectorManager = new Dn(
|
|
5054
5309
|
{
|
|
5055
5310
|
connectionQueueManager: this.connectionQueueManager,
|
|
5056
5311
|
connectionManager: this.connectionManager,
|
|
5057
5312
|
callManager: this.callManager
|
|
5058
5313
|
},
|
|
5059
5314
|
r
|
|
5060
|
-
), this.videoSendingBalancerManager = new
|
|
5315
|
+
), this.videoSendingBalancerManager = new Ls(
|
|
5061
5316
|
this.callManager,
|
|
5062
5317
|
this.apiManager,
|
|
5063
5318
|
i
|
|
5064
|
-
), this.mainStreamHealthMonitor = new
|
|
5319
|
+
), this.mainStreamHealthMonitor = new Us(this.statsManager, this.callManager), this.mainStreamRecovery = new Bs(this.callManager), this.sessionManager = new Yn({
|
|
5065
5320
|
connectionManager: this.connectionManager,
|
|
5066
5321
|
callManager: this.callManager,
|
|
5067
5322
|
incomingCallManager: this.incomingCallManager,
|
|
5068
5323
|
presentationManager: this.presentationManager
|
|
5324
|
+
}), this.contentedStreamManager.subscribeToApiEvents(this.apiManager), this.apiManager.subscribe({
|
|
5325
|
+
connectionManager: this.connectionManager,
|
|
5326
|
+
callManager: this.callManager
|
|
5069
5327
|
}), this.subscribe();
|
|
5070
5328
|
}
|
|
5071
5329
|
get requestedConnection() {
|
|
@@ -5170,7 +5428,7 @@ class Js {
|
|
|
5170
5428
|
const { isP2P: s, callLimit: i, onAddedTransceiver: r, ...a } = t;
|
|
5171
5429
|
return this.presentationManager.startPresentation(
|
|
5172
5430
|
async () => {
|
|
5173
|
-
s === !0 ?
|
|
5431
|
+
await (s === !0 ? this.apiManager.sendAvailableContentedStream() : this.apiManager.askPermissionToStartPresentation());
|
|
5174
5432
|
},
|
|
5175
5433
|
e,
|
|
5176
5434
|
{
|
|
@@ -5183,14 +5441,14 @@ class Js {
|
|
|
5183
5441
|
async stopPresentation(e = {}) {
|
|
5184
5442
|
const { isP2P: t } = e;
|
|
5185
5443
|
return this.presentationManager.stopPresentation(async () => {
|
|
5186
|
-
await (t === !0 ? this.apiManager.
|
|
5444
|
+
await (t === !0 ? this.apiManager.sendNotAvailableContentedStream() : this.apiManager.sendStoppedPresentation());
|
|
5187
5445
|
});
|
|
5188
5446
|
}
|
|
5189
5447
|
async updatePresentation(e, t = {}) {
|
|
5190
5448
|
const { isP2P: s, onAddedTransceiver: i, ...r } = t;
|
|
5191
5449
|
return this.presentationManager.updatePresentation(
|
|
5192
5450
|
async () => {
|
|
5193
|
-
s === !0 ?
|
|
5451
|
+
await (s === !0 ? this.apiManager.sendAvailableContentedStream() : this.apiManager.askPermissionToStartPresentation());
|
|
5194
5452
|
},
|
|
5195
5453
|
e,
|
|
5196
5454
|
{
|
|
@@ -5223,21 +5481,6 @@ class Js {
|
|
|
5223
5481
|
async sendRefusalToTurnOnCam(...e) {
|
|
5224
5482
|
return this.apiManager.sendRefusalToTurnOnCam(...e);
|
|
5225
5483
|
}
|
|
5226
|
-
async sendMustStopPresentationP2P(...e) {
|
|
5227
|
-
return this.apiManager.sendMustStopPresentationP2P(...e);
|
|
5228
|
-
}
|
|
5229
|
-
async sendStoppedPresentationP2P(...e) {
|
|
5230
|
-
return this.apiManager.sendStoppedPresentationP2P(...e);
|
|
5231
|
-
}
|
|
5232
|
-
async sendStoppedPresentation(...e) {
|
|
5233
|
-
return this.apiManager.sendStoppedPresentation(...e);
|
|
5234
|
-
}
|
|
5235
|
-
async askPermissionToStartPresentationP2P(...e) {
|
|
5236
|
-
return this.apiManager.askPermissionToStartPresentationP2P(...e);
|
|
5237
|
-
}
|
|
5238
|
-
async askPermissionToStartPresentation(...e) {
|
|
5239
|
-
return this.apiManager.askPermissionToStartPresentation(...e);
|
|
5240
|
-
}
|
|
5241
5484
|
async askPermissionToEnableCam(...e) {
|
|
5242
5485
|
return this.apiManager.askPermissionToEnableCam(...e);
|
|
5243
5486
|
}
|
|
@@ -5280,7 +5523,7 @@ class Js {
|
|
|
5280
5523
|
if (i === void 0)
|
|
5281
5524
|
throw new Error("No sipServerUrl for sendOffer");
|
|
5282
5525
|
const r = this.conferenceStateManager.getToken();
|
|
5283
|
-
return
|
|
5526
|
+
return zn({
|
|
5284
5527
|
serverUrl: i,
|
|
5285
5528
|
offer: t,
|
|
5286
5529
|
token: r,
|
|
@@ -5290,7 +5533,7 @@ class Js {
|
|
|
5290
5533
|
});
|
|
5291
5534
|
};
|
|
5292
5535
|
setCodecPreferences(e) {
|
|
5293
|
-
|
|
5536
|
+
ls(e, {
|
|
5294
5537
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
5295
5538
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
5296
5539
|
});
|
|
@@ -5315,24 +5558,24 @@ class Js {
|
|
|
5315
5558
|
};
|
|
5316
5559
|
}
|
|
5317
5560
|
export {
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5561
|
+
Ae as E,
|
|
5562
|
+
ut as O,
|
|
5563
|
+
gi as S,
|
|
5564
|
+
rn as a,
|
|
5565
|
+
ht as b,
|
|
5566
|
+
$n as c,
|
|
5567
|
+
fe as d,
|
|
5568
|
+
Vt as e,
|
|
5569
|
+
Ce as f,
|
|
5570
|
+
hi as g,
|
|
5571
|
+
gn as h,
|
|
5572
|
+
di as i,
|
|
5573
|
+
li as j,
|
|
5574
|
+
p as k,
|
|
5332
5575
|
d as l,
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5576
|
+
is as m,
|
|
5577
|
+
Ts as n,
|
|
5578
|
+
xt as o,
|
|
5579
|
+
H as p,
|
|
5580
|
+
zn as s
|
|
5338
5581
|
};
|