sip-connector 16.2.0 → 17.0.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/README.md +128 -45
- package/dist/{@SipConnector-D1YBDd7g.js → @SipConnector-DADbRZIb.js} +361 -267
- package/dist/@SipConnector-aB66gnC6.cjs +1 -0
- package/dist/ApiManager/index.d.ts +1 -0
- package/dist/CallManager/@CallManager.d.ts +2 -0
- package/dist/CallManager/AbstractCallStrategy.d.ts +9 -1
- package/dist/CallManager/MCUCallStrategy.d.ts +10 -1
- package/dist/CallManager/TransceiverManager.d.ts +51 -0
- package/dist/CallManager/index.d.ts +2 -1
- package/dist/CallManager/types.d.ts +16 -3
- package/dist/PresentationManager/types.d.ts +1 -1
- package/dist/SipConnector/@SipConnector.d.ts +1 -0
- package/dist/__fixtures__/RTCPeerConnectionMock.d.ts +2 -1
- package/dist/__fixtures__/RTCRtpTransceiverMock.d.ts +16 -0
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +166 -143
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/package.json +8 -8
- package/dist/@SipConnector-B5FFHZzJ.cjs +0 -1
|
@@ -2,12 +2,12 @@ import { Events as D, TypedEvents as K } from "events-constructor";
|
|
|
2
2
|
import { CancelableRequest as Re } from "@krivega/cancelable-promise";
|
|
3
3
|
import q from "debug";
|
|
4
4
|
import { hasCanceledError as Ie, repeatedCallsAsync as j } from "repeated-calls";
|
|
5
|
-
import { setup as _e, createActor as
|
|
5
|
+
import { setup as _e, createActor as me } from "xstate";
|
|
6
6
|
import { createStackPromises as Z } from "stack-promises";
|
|
7
7
|
import { SetTimeoutRequest as ee } from "@krivega/timeout-requester";
|
|
8
8
|
import "ua-parser-js";
|
|
9
9
|
import "sequent-promises";
|
|
10
|
-
var
|
|
10
|
+
var N = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n))(N || {}), F = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(F || {});
|
|
11
11
|
const te = [
|
|
12
12
|
"peerconnection",
|
|
13
13
|
"connecting",
|
|
@@ -35,18 +35,18 @@ const te = [
|
|
|
35
35
|
"peerconnection:createanswerfailed",
|
|
36
36
|
"peerconnection:setlocaldescriptionfailed",
|
|
37
37
|
"peerconnection:setremotedescriptionfailed"
|
|
38
|
-
],
|
|
38
|
+
], Me = [
|
|
39
39
|
"peerconnection:confirmed",
|
|
40
40
|
"peerconnection:ontrack",
|
|
41
41
|
"ended:fromserver"
|
|
42
42
|
], ne = [
|
|
43
43
|
...te,
|
|
44
|
-
...
|
|
44
|
+
...Me
|
|
45
45
|
], pe = (n, e) => {
|
|
46
46
|
n.getVideoTracks().forEach((s) => {
|
|
47
47
|
"contentHint" in s && s.contentHint !== e && (s.contentHint = e);
|
|
48
48
|
});
|
|
49
|
-
},
|
|
49
|
+
}, L = (n, {
|
|
50
50
|
directionVideo: e,
|
|
51
51
|
directionAudio: t,
|
|
52
52
|
contentHint: s
|
|
@@ -59,7 +59,7 @@ const te = [
|
|
|
59
59
|
function Pe(n) {
|
|
60
60
|
return (e) => `sip:${e}@${n}`;
|
|
61
61
|
}
|
|
62
|
-
const
|
|
62
|
+
const ve = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, se = (n) => n.trim().replaceAll(" ", "_"), fe = ve(1e5, 99999999), Oe = (n) => n.some((t) => {
|
|
63
63
|
const { kind: s } = t;
|
|
64
64
|
return s === "video";
|
|
65
65
|
});
|
|
@@ -104,11 +104,82 @@ class ye {
|
|
|
104
104
|
return e.map((t) => this.generateAudioStream(t));
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
class be
|
|
107
|
+
class be {
|
|
108
|
+
/**
|
|
109
|
+
* Хранилище основных transceiver'ов
|
|
110
|
+
*/
|
|
111
|
+
transceivers = {};
|
|
112
|
+
/**
|
|
113
|
+
* Сохраняет transceiver в соответствующем хранилище в зависимости от типа трека и mid
|
|
114
|
+
*/
|
|
115
|
+
storeTransceiver(e, t) {
|
|
116
|
+
const { kind: s } = t;
|
|
117
|
+
if (s === "audio")
|
|
118
|
+
this.transceivers.mainAudio ??= e;
|
|
119
|
+
else {
|
|
120
|
+
const { mid: r } = e;
|
|
121
|
+
r === "2" ? this.transceivers.presentationVideo ??= e : this.transceivers.mainVideo ??= e;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Возвращает все сохраненные transceiver'ы
|
|
126
|
+
*/
|
|
127
|
+
getTransceivers() {
|
|
128
|
+
return { ...this.transceivers };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Возвращает основной аудио transceiver
|
|
132
|
+
*/
|
|
133
|
+
getMainAudioTransceiver() {
|
|
134
|
+
return this.transceivers.mainAudio;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Возвращает основной видео transceiver
|
|
138
|
+
*/
|
|
139
|
+
getMainVideoTransceiver() {
|
|
140
|
+
return this.transceivers.mainVideo;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Возвращает презентационный видео transceiver
|
|
144
|
+
*/
|
|
145
|
+
getPresentationVideoTransceiver() {
|
|
146
|
+
return this.transceivers.presentationVideo;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Проверяет, есть ли сохраненный transceiver для указанного типа
|
|
150
|
+
*/
|
|
151
|
+
hasTransceiver(e) {
|
|
152
|
+
return this.transceivers[e] !== void 0;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Очищает все сохраненные transceiver'ы
|
|
156
|
+
*/
|
|
157
|
+
clear() {
|
|
158
|
+
this.transceivers.mainVideo = void 0, this.transceivers.mainAudio = void 0, this.transceivers.presentationVideo = void 0;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Возвращает количество сохраненных transceiver'ов
|
|
162
|
+
*/
|
|
163
|
+
getCount() {
|
|
164
|
+
let e = 0;
|
|
165
|
+
return this.transceivers.mainAudio && (e += 1), this.transceivers.mainVideo && (e += 1), this.transceivers.presentationVideo && (e += 1), e;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Проверяет, пустое ли хранилище
|
|
169
|
+
*/
|
|
170
|
+
isEmpty() {
|
|
171
|
+
return this.getCount() === 0;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
class Ue extends De {
|
|
108
175
|
remoteStreamsManager = new ye();
|
|
109
176
|
disposers = /* @__PURE__ */ new Set();
|
|
177
|
+
/**
|
|
178
|
+
* Менеджер для управления transceiver'ами
|
|
179
|
+
*/
|
|
180
|
+
transceiverManager = new be();
|
|
110
181
|
constructor(e) {
|
|
111
|
-
super(e), e.on(
|
|
182
|
+
super(e), e.on(N.FAILED, this.handleEnded), e.on(N.ENDED, this.handleEnded);
|
|
112
183
|
}
|
|
113
184
|
get requested() {
|
|
114
185
|
return this.isPendingCall || this.isPendingAnswer;
|
|
@@ -134,24 +205,17 @@ class be extends De {
|
|
|
134
205
|
offerToReceiveAudio: T = !0,
|
|
135
206
|
offerToReceiveVideo: g = !0,
|
|
136
207
|
degradationPreference: S,
|
|
137
|
-
sendEncodings:
|
|
138
|
-
onAddedTransceiver:
|
|
208
|
+
sendEncodings: I,
|
|
209
|
+
onAddedTransceiver: _
|
|
139
210
|
}) => (this.isPendingCall = !0, new Promise((R, y) => {
|
|
140
|
-
this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(R).catch((
|
|
141
|
-
y(
|
|
211
|
+
this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(R).catch(($) => {
|
|
212
|
+
y($);
|
|
142
213
|
}), this.rtcSession = e.call(t(s), {
|
|
143
|
-
|
|
144
|
-
mediaStream: B(r, {
|
|
214
|
+
mediaStream: L(r, {
|
|
145
215
|
directionVideo: c,
|
|
146
216
|
directionAudio: d,
|
|
147
217
|
contentHint: u
|
|
148
218
|
}),
|
|
149
|
-
// необходимо передавать в методе call, чтобы подписаться на события peerconnection,
|
|
150
|
-
// так как в методе call создается RTCSession
|
|
151
|
-
// и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
|
|
152
|
-
eventHandlers: this.events.triggers,
|
|
153
|
-
directionVideo: c,
|
|
154
|
-
directionAudio: d,
|
|
155
219
|
pcConfig: {
|
|
156
220
|
iceServers: o
|
|
157
221
|
},
|
|
@@ -159,9 +223,16 @@ class be extends De {
|
|
|
159
223
|
offerToReceiveAudio: T,
|
|
160
224
|
offerToReceiveVideo: g
|
|
161
225
|
},
|
|
226
|
+
// необходимо передавать в методе call, чтобы подписаться на события peerconnection,
|
|
227
|
+
// так как в методе call создается RTCSession
|
|
228
|
+
// и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
|
|
229
|
+
eventHandlers: this.events.triggers,
|
|
230
|
+
extraHeaders: i,
|
|
231
|
+
directionVideo: c,
|
|
232
|
+
directionAudio: d,
|
|
162
233
|
degradationPreference: S,
|
|
163
|
-
sendEncodings:
|
|
164
|
-
onAddedTransceiver:
|
|
234
|
+
sendEncodings: I,
|
|
235
|
+
onAddedTransceiver: _
|
|
165
236
|
});
|
|
166
237
|
}).finally(() => {
|
|
167
238
|
this.isPendingCall = !1;
|
|
@@ -189,22 +260,12 @@ class be extends De {
|
|
|
189
260
|
degradationPreference: T,
|
|
190
261
|
sendEncodings: g,
|
|
191
262
|
onAddedTransceiver: S
|
|
192
|
-
}) => (this.isPendingAnswer = !0, new Promise((
|
|
263
|
+
}) => (this.isPendingAnswer = !0, new Promise((I, _) => {
|
|
193
264
|
try {
|
|
194
265
|
const R = e();
|
|
195
|
-
this.rtcSession = R, this.subscribeToSessionEvents(R), this.callConfiguration.answer = !0, this.callConfiguration.number = R.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(
|
|
196
|
-
|
|
197
|
-
})
|
|
198
|
-
const y = B(t, {
|
|
199
|
-
directionVideo: a,
|
|
200
|
-
directionAudio: o,
|
|
201
|
-
contentHint: u
|
|
202
|
-
});
|
|
203
|
-
R.answer({
|
|
204
|
-
extraHeaders: r,
|
|
205
|
-
directionVideo: a,
|
|
206
|
-
directionAudio: o,
|
|
207
|
-
mediaStream: y,
|
|
266
|
+
this.rtcSession = R, this.subscribeToSessionEvents(R), this.callConfiguration.answer = !0, this.callConfiguration.number = R.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(I).catch((y) => {
|
|
267
|
+
_(y);
|
|
268
|
+
}), R.answer({
|
|
208
269
|
pcConfig: {
|
|
209
270
|
iceServers: i
|
|
210
271
|
},
|
|
@@ -212,12 +273,20 @@ class be extends De {
|
|
|
212
273
|
offerToReceiveAudio: c,
|
|
213
274
|
offerToReceiveVideo: d
|
|
214
275
|
},
|
|
276
|
+
mediaStream: L(t, {
|
|
277
|
+
directionVideo: a,
|
|
278
|
+
directionAudio: o,
|
|
279
|
+
contentHint: u
|
|
280
|
+
}),
|
|
281
|
+
extraHeaders: r,
|
|
282
|
+
directionVideo: a,
|
|
283
|
+
directionAudio: o,
|
|
215
284
|
degradationPreference: T,
|
|
216
285
|
sendEncodings: g,
|
|
217
286
|
onAddedTransceiver: S
|
|
218
287
|
});
|
|
219
288
|
} catch (R) {
|
|
220
|
-
|
|
289
|
+
_(R);
|
|
221
290
|
}
|
|
222
291
|
}).finally(() => {
|
|
223
292
|
this.isPendingAnswer = !1;
|
|
@@ -232,12 +301,12 @@ class be extends De {
|
|
|
232
301
|
if (!this.connection)
|
|
233
302
|
return;
|
|
234
303
|
const t = this.connection.getReceivers().map(({ track: s }) => s);
|
|
235
|
-
return
|
|
304
|
+
return Oe(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
|
|
236
305
|
}
|
|
237
306
|
async replaceMediaStream(e, t) {
|
|
238
307
|
if (!this.rtcSession)
|
|
239
308
|
throw new Error("No rtcSession established");
|
|
240
|
-
const { contentHint: s } = t ?? {}, r =
|
|
309
|
+
const { contentHint: s } = t ?? {}, r = L(e, { contentHint: s });
|
|
241
310
|
if (r === void 0)
|
|
242
311
|
throw new Error("No preparedMediaStream");
|
|
243
312
|
return this.rtcSession.replaceMediaStream(r, t);
|
|
@@ -247,31 +316,42 @@ class be extends De {
|
|
|
247
316
|
throw new Error("No rtcSession established");
|
|
248
317
|
return this.rtcSession.restartIce(e);
|
|
249
318
|
}
|
|
319
|
+
async addTransceiver(e, t) {
|
|
320
|
+
if (!this.rtcSession)
|
|
321
|
+
throw new Error("No rtcSession established");
|
|
322
|
+
return this.rtcSession.addTransceiver(e, t);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Возвращает сохраненные transceiver'ы
|
|
326
|
+
*/
|
|
327
|
+
getTransceivers() {
|
|
328
|
+
return this.transceiverManager.getTransceivers();
|
|
329
|
+
}
|
|
250
330
|
handleCall = async ({
|
|
251
331
|
ontrack: e
|
|
252
332
|
}) => new Promise((t, s) => {
|
|
253
333
|
const r = () => {
|
|
254
|
-
this.events.on(
|
|
334
|
+
this.events.on(N.PEER_CONNECTION, u), this.events.on(N.CONFIRMED, T);
|
|
255
335
|
}, i = () => {
|
|
256
|
-
this.events.off(
|
|
336
|
+
this.events.off(N.PEER_CONNECTION, u), this.events.off(N.CONFIRMED, T);
|
|
257
337
|
}, a = () => {
|
|
258
|
-
this.events.on(
|
|
338
|
+
this.events.on(N.FAILED, c), this.events.on(N.ENDED, c);
|
|
259
339
|
}, o = () => {
|
|
260
|
-
this.events.off(
|
|
340
|
+
this.events.off(N.FAILED, c), this.events.off(N.ENDED, c);
|
|
261
341
|
}, c = (g) => {
|
|
262
342
|
i(), o(), s(g);
|
|
263
343
|
};
|
|
264
344
|
let d;
|
|
265
345
|
const u = ({ peerconnection: g }) => {
|
|
266
346
|
d = g;
|
|
267
|
-
const S = (
|
|
268
|
-
this.events.trigger(
|
|
347
|
+
const S = (I) => {
|
|
348
|
+
this.events.trigger(N.PEER_CONNECTION_ONTRACK, g), this.transceiverManager.storeTransceiver(I.transceiver, I.track), e && e(I);
|
|
269
349
|
};
|
|
270
350
|
g.addEventListener("track", S), this.disposers.add(() => {
|
|
271
351
|
g.removeEventListener("track", S);
|
|
272
352
|
});
|
|
273
353
|
}, T = () => {
|
|
274
|
-
d !== void 0 && this.events.trigger(
|
|
354
|
+
d !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, d), i(), o(), t(d);
|
|
275
355
|
};
|
|
276
356
|
r(), a();
|
|
277
357
|
});
|
|
@@ -290,17 +370,17 @@ class be extends De {
|
|
|
290
370
|
}
|
|
291
371
|
handleEnded = (e) => {
|
|
292
372
|
const { originator: t } = e;
|
|
293
|
-
t ===
|
|
373
|
+
t === F.REMOTE && this.events.trigger(N.ENDED_FROM_SERVER, e), this.reset();
|
|
294
374
|
};
|
|
295
375
|
reset = () => {
|
|
296
|
-
delete this.rtcSession, this.remoteStreamsManager.reset(), this.unsubscribeFromSessionEvents(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1;
|
|
376
|
+
delete this.rtcSession, this.remoteStreamsManager.reset(), this.unsubscribeFromSessionEvents(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1, this.transceiverManager.clear();
|
|
297
377
|
};
|
|
298
378
|
}
|
|
299
|
-
class
|
|
379
|
+
class we {
|
|
300
380
|
events;
|
|
301
381
|
strategy;
|
|
302
382
|
constructor(e) {
|
|
303
|
-
this.events = new D(ne), this.strategy = e ?? new
|
|
383
|
+
this.events = new D(ne), this.strategy = e ?? new Ue(this.events);
|
|
304
384
|
}
|
|
305
385
|
get requested() {
|
|
306
386
|
return this.strategy.requested;
|
|
@@ -342,15 +422,17 @@ class Ue {
|
|
|
342
422
|
getEstablishedRTCSession = () => this.strategy.getEstablishedRTCSession();
|
|
343
423
|
getCallConfiguration = () => this.strategy.getCallConfiguration();
|
|
344
424
|
getRemoteStreams = () => this.strategy.getRemoteStreams();
|
|
425
|
+
getTransceivers = () => this.strategy.getTransceivers();
|
|
426
|
+
addTransceiver = async (...e) => this.strategy.addTransceiver(...e);
|
|
345
427
|
replaceMediaStream = async (...e) => this.strategy.replaceMediaStream(...e);
|
|
346
428
|
restartIce = async (e) => this.strategy.restartIce(e);
|
|
347
429
|
}
|
|
348
|
-
const G = "sip-connector",
|
|
430
|
+
const G = "sip-connector", E = q(G), Sn = () => {
|
|
349
431
|
q.enable(G);
|
|
350
|
-
},
|
|
432
|
+
}, Cn = () => {
|
|
351
433
|
q.enable(`-${G}`);
|
|
352
|
-
},
|
|
353
|
-
var 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.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n))(h || {}),
|
|
434
|
+
}, Le = "Error decline with 603", Be = 1006, ke = (n) => typeof n == "object" && n !== null && "code" in n && n.code === Be, Fe = (n) => n.message === Le;
|
|
435
|
+
var 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.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n))(h || {}), B = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(B || {}), k = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n.SPECTATOR_OVER_SFU = "SPECTATOROVERSFU", n))(k || {}), v = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.RESTART = "application/vinteo.webrtc.restart", n))(v || {}), M = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(M || {}), P = /* @__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))(P || {}), W = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(W || {}), H = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(H || {}), $e = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))($e || {}), l = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_OVER_SFU = "participant:move-request-to-spectators-over-sfu", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n.RESTART = "restart", n))(l || {});
|
|
354
436
|
const ie = [
|
|
355
437
|
"participation:accepting-word-request",
|
|
356
438
|
"participation:cancelling-word-request",
|
|
@@ -382,8 +464,8 @@ const ie = [
|
|
|
382
464
|
"newDTMF",
|
|
383
465
|
"restart"
|
|
384
466
|
];
|
|
385
|
-
var
|
|
386
|
-
class
|
|
467
|
+
var m = /* @__PURE__ */ ((n) => (n.CHANNELS = "channels", n.WEBCAST_STARTED = "WebcastStarted", n.WEBCAST_STOPPED = "WebcastStopped", n.ACCOUNT_CHANGED = "accountChanged", n.ACCOUNT_DELETED = "accountDeleted", n.ADDED_TO_LIST_MODERATORS = "addedToListModerators", n.REMOVED_FROM_LIST_MODERATORS = "removedFromListModerators", n.ACCEPTING_WORD_REQUEST = "ParticipationRequestAccepted", n.CANCELLING_WORD_REQUEST = "ParticipationRequestRejected", n.MOVE_REQUEST_TO_STREAM = "ParticipantMovedToWebcast", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "ConferenceParticipantTokenIssued", n))(m || {});
|
|
468
|
+
class Ve {
|
|
387
469
|
events;
|
|
388
470
|
connectionManager;
|
|
389
471
|
callManager;
|
|
@@ -408,7 +490,7 @@ class $e {
|
|
|
408
490
|
s(i);
|
|
409
491
|
}
|
|
410
492
|
r && (this.callManager.once("newDTMF", ({ originator: i }) => {
|
|
411
|
-
i ===
|
|
493
|
+
i === F.LOCAL && t();
|
|
412
494
|
}), r.sendDTMF(e, {
|
|
413
495
|
duration: 120,
|
|
414
496
|
interToneGap: 600
|
|
@@ -489,7 +571,7 @@ class $e {
|
|
|
489
571
|
...e,
|
|
490
572
|
extraHeaders: s
|
|
491
573
|
}).catch((r) => {
|
|
492
|
-
if (
|
|
574
|
+
if (Fe(r))
|
|
493
575
|
throw r;
|
|
494
576
|
});
|
|
495
577
|
}
|
|
@@ -534,104 +616,104 @@ class $e {
|
|
|
534
616
|
this.handleNotify(s);
|
|
535
617
|
}
|
|
536
618
|
} catch (t) {
|
|
537
|
-
|
|
619
|
+
E("error parse notify", t);
|
|
538
620
|
}
|
|
539
621
|
};
|
|
540
622
|
handleNotify = (e) => {
|
|
541
623
|
switch (e.cmd) {
|
|
542
|
-
case
|
|
624
|
+
case m.CHANNELS: {
|
|
543
625
|
const t = e;
|
|
544
626
|
this.triggerChannelsNotify(t);
|
|
545
627
|
break;
|
|
546
628
|
}
|
|
547
|
-
case
|
|
629
|
+
case m.WEBCAST_STARTED: {
|
|
548
630
|
const t = e;
|
|
549
631
|
this.triggerWebcastStartedNotify(t);
|
|
550
632
|
break;
|
|
551
633
|
}
|
|
552
|
-
case
|
|
634
|
+
case m.WEBCAST_STOPPED: {
|
|
553
635
|
const t = e;
|
|
554
636
|
this.triggerWebcastStoppedNotify(t);
|
|
555
637
|
break;
|
|
556
638
|
}
|
|
557
|
-
case
|
|
639
|
+
case m.ADDED_TO_LIST_MODERATORS: {
|
|
558
640
|
const t = e;
|
|
559
641
|
this.triggerAddedToListModeratorsNotify(t);
|
|
560
642
|
break;
|
|
561
643
|
}
|
|
562
|
-
case
|
|
644
|
+
case m.REMOVED_FROM_LIST_MODERATORS: {
|
|
563
645
|
const t = e;
|
|
564
646
|
this.triggerRemovedFromListModeratorsNotify(t);
|
|
565
647
|
break;
|
|
566
648
|
}
|
|
567
|
-
case
|
|
649
|
+
case m.ACCEPTING_WORD_REQUEST: {
|
|
568
650
|
const t = e;
|
|
569
651
|
this.triggerParticipationAcceptingWordRequest(t);
|
|
570
652
|
break;
|
|
571
653
|
}
|
|
572
|
-
case
|
|
654
|
+
case m.CANCELLING_WORD_REQUEST: {
|
|
573
655
|
const t = e;
|
|
574
656
|
this.triggerParticipationCancellingWordRequest(t);
|
|
575
657
|
break;
|
|
576
658
|
}
|
|
577
|
-
case
|
|
659
|
+
case m.MOVE_REQUEST_TO_STREAM: {
|
|
578
660
|
const t = e;
|
|
579
661
|
this.triggerParticipantMoveRequestToStream(t);
|
|
580
662
|
break;
|
|
581
663
|
}
|
|
582
|
-
case
|
|
664
|
+
case m.ACCOUNT_CHANGED: {
|
|
583
665
|
this.triggerAccountChangedNotify();
|
|
584
666
|
break;
|
|
585
667
|
}
|
|
586
|
-
case
|
|
668
|
+
case m.ACCOUNT_DELETED: {
|
|
587
669
|
this.triggerAccountDeletedNotify();
|
|
588
670
|
break;
|
|
589
671
|
}
|
|
590
|
-
case
|
|
672
|
+
case m.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
|
|
591
673
|
const t = e;
|
|
592
674
|
this.triggerConferenceParticipantTokenIssued(t);
|
|
593
675
|
break;
|
|
594
676
|
}
|
|
595
677
|
default:
|
|
596
|
-
|
|
678
|
+
E("unknown cmd", e);
|
|
597
679
|
}
|
|
598
680
|
};
|
|
599
681
|
handleNewInfo = (e) => {
|
|
600
682
|
const { originator: t } = e;
|
|
601
|
-
if (t !==
|
|
683
|
+
if (t !== F.REMOTE)
|
|
602
684
|
return;
|
|
603
685
|
const { request: s } = e, r = s.getHeader(h.CONTENT_TYPE);
|
|
604
686
|
if (r !== void 0)
|
|
605
687
|
switch (r) {
|
|
606
|
-
case
|
|
688
|
+
case v.ENTER_ROOM: {
|
|
607
689
|
this.triggerEnterRoom(s), this.maybeTriggerChannels(s);
|
|
608
690
|
break;
|
|
609
691
|
}
|
|
610
|
-
case
|
|
692
|
+
case v.NOTIFY: {
|
|
611
693
|
this.maybeHandleNotify(s);
|
|
612
694
|
break;
|
|
613
695
|
}
|
|
614
|
-
case
|
|
696
|
+
case v.SHARE_STATE: {
|
|
615
697
|
this.triggerShareState(s);
|
|
616
698
|
break;
|
|
617
699
|
}
|
|
618
|
-
case
|
|
700
|
+
case v.MAIN_CAM: {
|
|
619
701
|
this.triggerMainCamControl(s);
|
|
620
702
|
break;
|
|
621
703
|
}
|
|
622
|
-
case
|
|
704
|
+
case v.MIC: {
|
|
623
705
|
this.triggerMicControl(s);
|
|
624
706
|
break;
|
|
625
707
|
}
|
|
626
|
-
case
|
|
708
|
+
case v.USE_LICENSE: {
|
|
627
709
|
this.triggerUseLicense(s);
|
|
628
710
|
break;
|
|
629
711
|
}
|
|
630
|
-
case
|
|
712
|
+
case v.PARTICIPANT_STATE: {
|
|
631
713
|
this.maybeTriggerParticipantMoveRequest(s);
|
|
632
714
|
break;
|
|
633
715
|
}
|
|
634
|
-
case
|
|
716
|
+
case v.RESTART: {
|
|
635
717
|
this.triggerRestart(s);
|
|
636
718
|
break;
|
|
637
719
|
}
|
|
@@ -745,15 +827,15 @@ class $e {
|
|
|
745
827
|
const t = e.getHeader(h.CONTENT_SHARE_STATE);
|
|
746
828
|
if (t !== void 0)
|
|
747
829
|
switch (t) {
|
|
748
|
-
case
|
|
830
|
+
case B.AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
749
831
|
this.events.trigger(l.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
|
|
750
832
|
break;
|
|
751
833
|
}
|
|
752
|
-
case
|
|
834
|
+
case B.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
753
835
|
this.events.trigger(l.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
|
|
754
836
|
break;
|
|
755
837
|
}
|
|
756
|
-
case
|
|
838
|
+
case B.MUST_STOP_PRESENTATION: {
|
|
757
839
|
this.events.trigger(l.MUST_STOP_PRESENTATION, void 0);
|
|
758
840
|
break;
|
|
759
841
|
}
|
|
@@ -761,7 +843,7 @@ class $e {
|
|
|
761
843
|
};
|
|
762
844
|
maybeTriggerParticipantMoveRequest = (e) => {
|
|
763
845
|
const t = e.getHeader(h.CONTENT_PARTICIPANT_STATE);
|
|
764
|
-
t ===
|
|
846
|
+
t === k.SPECTATOR && this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === k.PARTICIPANT && this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0), t === k.SPECTATOR_OVER_SFU && this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_OVER_SFU, void 0);
|
|
765
847
|
};
|
|
766
848
|
triggerMainCamControl = (e) => {
|
|
767
849
|
const t = e.getHeader(h.MAIN_CAM), s = e.getHeader(h.MEDIA_SYNC), r = s === H.ADMIN_SYNC_FORCED;
|
|
@@ -799,39 +881,39 @@ class $e {
|
|
|
799
881
|
this.events.trigger(l.RESTART, i);
|
|
800
882
|
};
|
|
801
883
|
}
|
|
802
|
-
const
|
|
884
|
+
const We = (n, e) => (n.degradationPreference = e.degradationPreference, n), He = (n, e) => {
|
|
803
885
|
n.encodings ??= [];
|
|
804
886
|
for (let t = n.encodings.length; t < e; t += 1)
|
|
805
887
|
n.encodings.push({});
|
|
806
888
|
return n;
|
|
807
|
-
}, ae = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n,
|
|
808
|
-
if (
|
|
889
|
+
}, ae = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, xe = ae(), qe = (n, e) => {
|
|
890
|
+
if (xe(n, e))
|
|
809
891
|
return n;
|
|
810
|
-
},
|
|
811
|
-
const t = n.maxBitrate, s =
|
|
892
|
+
}, Ge = (n, e) => {
|
|
893
|
+
const t = n.maxBitrate, s = qe(e, t);
|
|
812
894
|
return s !== void 0 && (n.maxBitrate = s), n;
|
|
813
|
-
}, oe = 1,
|
|
895
|
+
}, oe = 1, Qe = ae(
|
|
814
896
|
oe
|
|
815
|
-
),
|
|
897
|
+
), Ye = (n, e) => {
|
|
816
898
|
const t = n === void 0 ? void 0 : Math.max(n, oe);
|
|
817
|
-
if (t !== void 0 &&
|
|
899
|
+
if (t !== void 0 && Qe(
|
|
818
900
|
t,
|
|
819
901
|
e
|
|
820
902
|
))
|
|
821
903
|
return t;
|
|
822
|
-
},
|
|
823
|
-
const t = n.scaleResolutionDownBy, s =
|
|
904
|
+
}, ze = (n, e) => {
|
|
905
|
+
const t = n.scaleResolutionDownBy, s = Ye(
|
|
824
906
|
e,
|
|
825
907
|
t
|
|
826
908
|
);
|
|
827
909
|
return s !== void 0 && (n.scaleResolutionDownBy = s), n;
|
|
828
|
-
},
|
|
910
|
+
}, Xe = (n, e) => {
|
|
829
911
|
const t = e.encodings?.length ?? 0;
|
|
830
|
-
return
|
|
912
|
+
return He(n, t), n.encodings.forEach((s, r) => {
|
|
831
913
|
const i = (e?.encodings ?? [])[r], a = i?.maxBitrate, o = i?.scaleResolutionDownBy;
|
|
832
|
-
|
|
914
|
+
Ge(s, a), ze(s, o);
|
|
833
915
|
}), n;
|
|
834
|
-
},
|
|
916
|
+
}, Je = (n, e) => {
|
|
835
917
|
if (n.codecs?.length !== e.codecs?.length)
|
|
836
918
|
return !0;
|
|
837
919
|
for (let t = 0; t < (n.codecs?.length ?? 0); t++)
|
|
@@ -848,15 +930,15 @@ const Ve = (n, e) => (n.degradationPreference = e.degradationPreference, n), We
|
|
|
848
930
|
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
849
931
|
return !0;
|
|
850
932
|
return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
|
|
851
|
-
},
|
|
933
|
+
}, Ke = async (n, e) => {
|
|
852
934
|
const t = n.getParameters(), s = JSON.parse(
|
|
853
935
|
JSON.stringify(t)
|
|
854
936
|
);
|
|
855
|
-
|
|
856
|
-
const r =
|
|
937
|
+
Xe(t, e), We(t, e);
|
|
938
|
+
const r = Je(s, t);
|
|
857
939
|
return r && await n.setParameters(t), { parameters: t, isChanged: r };
|
|
858
940
|
}, ce = async (n, e, t) => {
|
|
859
|
-
const { isChanged: s, parameters: r } = await
|
|
941
|
+
const { isChanged: s, parameters: r } = await Ke(n, {
|
|
860
942
|
encodings: [
|
|
861
943
|
{
|
|
862
944
|
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
@@ -865,20 +947,20 @@ const Ve = (n, e) => (n.degradationPreference = e.degradationPreference, n), We
|
|
|
865
947
|
]
|
|
866
948
|
});
|
|
867
949
|
return s && t && t(r), { isChanged: s, parameters: r };
|
|
868
|
-
},
|
|
869
|
-
const s =
|
|
950
|
+
}, je = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), Ze = async (n, e, t) => {
|
|
951
|
+
const s = je(n, e);
|
|
870
952
|
if (s)
|
|
871
953
|
return ce(s, { maxBitrate: t });
|
|
872
954
|
};
|
|
873
|
-
var
|
|
955
|
+
var f = /* @__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))(f || {});
|
|
874
956
|
const de = [
|
|
875
957
|
"presentation:start",
|
|
876
958
|
"presentation:started",
|
|
877
959
|
"presentation:end",
|
|
878
960
|
"presentation:ended",
|
|
879
961
|
"presentation:failed"
|
|
880
|
-
],
|
|
881
|
-
class
|
|
962
|
+
], et = 1, En = (n) => Ie(n);
|
|
963
|
+
class tt {
|
|
882
964
|
events;
|
|
883
965
|
promisePendingStartPresentation;
|
|
884
966
|
promisePendingStopPresentation;
|
|
@@ -925,8 +1007,8 @@ class et {
|
|
|
925
1007
|
});
|
|
926
1008
|
const r = this.callManager.getEstablishedRTCSession();
|
|
927
1009
|
return r && t ? s = e().then(async () => r.stopPresentation(t)).catch((i) => {
|
|
928
|
-
throw this.events.trigger(
|
|
929
|
-
}) : t && this.events.trigger(
|
|
1010
|
+
throw this.events.trigger(f.FAILED_PRESENTATION, i), i;
|
|
1011
|
+
}) : t && this.events.trigger(f.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
|
|
930
1012
|
this.resetPresentation();
|
|
931
1013
|
});
|
|
932
1014
|
}
|
|
@@ -969,15 +1051,15 @@ class et {
|
|
|
969
1051
|
}
|
|
970
1052
|
subscribe() {
|
|
971
1053
|
this.callManager.on("presentation:start", (e) => {
|
|
972
|
-
this.events.trigger(
|
|
1054
|
+
this.events.trigger(f.START_PRESENTATION, e);
|
|
973
1055
|
}), this.callManager.on("presentation:started", (e) => {
|
|
974
|
-
this.events.trigger(
|
|
1056
|
+
this.events.trigger(f.STARTED_PRESENTATION, e);
|
|
975
1057
|
}), this.callManager.on("presentation:end", (e) => {
|
|
976
|
-
this.events.trigger(
|
|
1058
|
+
this.events.trigger(f.END_PRESENTATION, e);
|
|
977
1059
|
}), this.callManager.on("presentation:ended", (e) => {
|
|
978
|
-
this.events.trigger(
|
|
1060
|
+
this.events.trigger(f.ENDED_PRESENTATION, e);
|
|
979
1061
|
}), this.callManager.on("presentation:failed", (e) => {
|
|
980
|
-
this.events.trigger(
|
|
1062
|
+
this.events.trigger(f.FAILED_PRESENTATION, e);
|
|
981
1063
|
}), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
|
|
982
1064
|
}
|
|
983
1065
|
async sendPresentationWithDuplicatedCalls(e, {
|
|
@@ -985,7 +1067,7 @@ class et {
|
|
|
985
1067
|
stream: s,
|
|
986
1068
|
presentationOptions: r,
|
|
987
1069
|
options: i = {
|
|
988
|
-
callLimit:
|
|
1070
|
+
callLimit: et
|
|
989
1071
|
}
|
|
990
1072
|
}) {
|
|
991
1073
|
const a = async () => this.sendPresentation(
|
|
@@ -1009,7 +1091,7 @@ class et {
|
|
|
1009
1091
|
sendEncodings: o,
|
|
1010
1092
|
onAddedTransceiver: c
|
|
1011
1093
|
}) {
|
|
1012
|
-
const d =
|
|
1094
|
+
const d = L(s, { contentHint: i });
|
|
1013
1095
|
if (d === void 0)
|
|
1014
1096
|
throw new Error("No streamPresentationTarget");
|
|
1015
1097
|
this.streamPresentationCurrent = d;
|
|
@@ -1018,7 +1100,7 @@ class et {
|
|
|
1018
1100
|
sendEncodings: o,
|
|
1019
1101
|
onAddedTransceiver: c
|
|
1020
1102
|
})).then(this.setMaxBitrate).then(() => s).catch((T) => {
|
|
1021
|
-
throw this.removeStreamPresentationCurrent(), this.events.trigger(
|
|
1103
|
+
throw this.removeStreamPresentationCurrent(), this.events.trigger(f.FAILED_PRESENTATION, T), T;
|
|
1022
1104
|
});
|
|
1023
1105
|
return this.promisePendingStartPresentation = u, u.finally(() => {
|
|
1024
1106
|
this.promisePendingStartPresentation = void 0;
|
|
@@ -1029,7 +1111,7 @@ class et {
|
|
|
1029
1111
|
if (!e || !t || s === void 0)
|
|
1030
1112
|
return;
|
|
1031
1113
|
const r = e.getSenders();
|
|
1032
|
-
await
|
|
1114
|
+
await Ze(r, t, s);
|
|
1033
1115
|
};
|
|
1034
1116
|
getRtcSessionProtected = () => {
|
|
1035
1117
|
const e = this.callManager.getEstablishedRTCSession();
|
|
@@ -1050,7 +1132,7 @@ class et {
|
|
|
1050
1132
|
delete this.streamPresentationCurrent;
|
|
1051
1133
|
}
|
|
1052
1134
|
}
|
|
1053
|
-
class
|
|
1135
|
+
class nt {
|
|
1054
1136
|
data = {};
|
|
1055
1137
|
getUa;
|
|
1056
1138
|
constructor(e) {
|
|
@@ -1123,7 +1205,7 @@ class tt {
|
|
|
1123
1205
|
return this.data.register === !0;
|
|
1124
1206
|
}
|
|
1125
1207
|
}
|
|
1126
|
-
var
|
|
1208
|
+
var A = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n))(A || {});
|
|
1127
1209
|
const he = [
|
|
1128
1210
|
"connecting",
|
|
1129
1211
|
"connected",
|
|
@@ -1134,8 +1216,8 @@ const he = [
|
|
|
1134
1216
|
"registrationFailed",
|
|
1135
1217
|
"newMessage",
|
|
1136
1218
|
"sipEvent"
|
|
1137
|
-
], ge = [...he],
|
|
1138
|
-
class
|
|
1219
|
+
], ge = [...he], st = 3;
|
|
1220
|
+
class rt {
|
|
1139
1221
|
cancelableConnectWithRepeatedCalls;
|
|
1140
1222
|
JsSIP;
|
|
1141
1223
|
events;
|
|
@@ -1167,20 +1249,20 @@ class st {
|
|
|
1167
1249
|
});
|
|
1168
1250
|
disconnect = async () => {
|
|
1169
1251
|
const e = new Promise((s) => {
|
|
1170
|
-
this.events.once(
|
|
1252
|
+
this.events.once(A.DISCONNECTED, () => {
|
|
1171
1253
|
s();
|
|
1172
1254
|
});
|
|
1173
1255
|
}), t = this.getUa();
|
|
1174
|
-
return t ? t.stop() : this.events.trigger(
|
|
1256
|
+
return t ? t.stop() : this.events.trigger(A.DISCONNECTED, void 0), e.finally(() => {
|
|
1175
1257
|
this.setUa(void 0), this.stateMachine.reset();
|
|
1176
1258
|
});
|
|
1177
1259
|
};
|
|
1178
1260
|
cancelRequests() {
|
|
1179
1261
|
this.cancelConnectWithRepeatedCalls();
|
|
1180
1262
|
}
|
|
1181
|
-
connectWithDuplicatedCalls = async (e, { callLimit: t =
|
|
1263
|
+
connectWithDuplicatedCalls = async (e, { callLimit: t = st } = {}) => {
|
|
1182
1264
|
const s = async () => this.connectInner(e), r = (i) => {
|
|
1183
|
-
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = i != null && !
|
|
1265
|
+
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = i != null && !ke(i);
|
|
1184
1266
|
return c || d;
|
|
1185
1267
|
};
|
|
1186
1268
|
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = j({
|
|
@@ -1222,7 +1304,7 @@ class st {
|
|
|
1222
1304
|
user: e,
|
|
1223
1305
|
password: t
|
|
1224
1306
|
}), this.getUa() && await this.disconnect();
|
|
1225
|
-
const { ua:
|
|
1307
|
+
const { ua: _, helpers: R } = this.uaFactory.createUAWithConfiguration(
|
|
1226
1308
|
{
|
|
1227
1309
|
user: e,
|
|
1228
1310
|
password: t,
|
|
@@ -1240,7 +1322,7 @@ class st {
|
|
|
1240
1322
|
},
|
|
1241
1323
|
this.events
|
|
1242
1324
|
);
|
|
1243
|
-
return this.setUa(
|
|
1325
|
+
return this.setUa(_), this.setSipServerUrl(R.getSipServerUrl), this.setSocket(R.socket), _;
|
|
1244
1326
|
};
|
|
1245
1327
|
start = async () => new Promise((e, t) => {
|
|
1246
1328
|
const s = this.getUa();
|
|
@@ -1252,7 +1334,7 @@ class st {
|
|
|
1252
1334
|
r = ((c, d) => {
|
|
1253
1335
|
if (this.getConnectionConfiguration().register === !0)
|
|
1254
1336
|
return this.registrationManager.subscribeToStartEvents(c, d);
|
|
1255
|
-
const T =
|
|
1337
|
+
const T = A.CONNECTED, g = [A.DISCONNECTED];
|
|
1256
1338
|
return this.events.on(T, c), g.forEach((S) => {
|
|
1257
1339
|
this.events.on(S, d);
|
|
1258
1340
|
}), () => {
|
|
@@ -1271,17 +1353,17 @@ class st {
|
|
|
1271
1353
|
}
|
|
1272
1354
|
}
|
|
1273
1355
|
var le = /* @__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))(le || {});
|
|
1274
|
-
const
|
|
1356
|
+
const it = _e({
|
|
1275
1357
|
types: {
|
|
1276
1358
|
context: {},
|
|
1277
1359
|
events: {}
|
|
1278
1360
|
},
|
|
1279
1361
|
actions: {
|
|
1280
1362
|
logTransition: (n, e) => {
|
|
1281
|
-
|
|
1363
|
+
E(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
1282
1364
|
},
|
|
1283
1365
|
logStateChange: (n, e) => {
|
|
1284
|
-
|
|
1366
|
+
E("ConnectionStateMachine state changed", e.state);
|
|
1285
1367
|
}
|
|
1286
1368
|
}
|
|
1287
1369
|
}).createMachine({
|
|
@@ -1585,14 +1667,14 @@ const rt = _e({
|
|
|
1585
1667
|
}
|
|
1586
1668
|
}
|
|
1587
1669
|
});
|
|
1588
|
-
class
|
|
1670
|
+
class at {
|
|
1589
1671
|
actor;
|
|
1590
1672
|
stateChangeListeners = /* @__PURE__ */ new Set();
|
|
1591
1673
|
events;
|
|
1592
1674
|
unsubscribeFromEvents;
|
|
1593
1675
|
actorSubscription;
|
|
1594
1676
|
constructor(e) {
|
|
1595
|
-
this.events = e, this.actor =
|
|
1677
|
+
this.events = e, this.actor = me(it), this.actorSubscription = this.actor.subscribe((t) => {
|
|
1596
1678
|
const s = t.value;
|
|
1597
1679
|
this.stateChangeListeners.forEach((r) => {
|
|
1598
1680
|
r(s);
|
|
@@ -1686,7 +1768,7 @@ class it {
|
|
|
1686
1768
|
sendEvent(e) {
|
|
1687
1769
|
const t = this.actor.getSnapshot(), s = { type: e };
|
|
1688
1770
|
if (!t.can(s)) {
|
|
1689
|
-
|
|
1771
|
+
E(
|
|
1690
1772
|
`Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
|
|
1691
1773
|
);
|
|
1692
1774
|
return;
|
|
@@ -1747,7 +1829,7 @@ class it {
|
|
|
1747
1829
|
};
|
|
1748
1830
|
}
|
|
1749
1831
|
}
|
|
1750
|
-
class
|
|
1832
|
+
class ot {
|
|
1751
1833
|
events;
|
|
1752
1834
|
getUaProtected;
|
|
1753
1835
|
constructor(e) {
|
|
@@ -1756,25 +1838,25 @@ class at {
|
|
|
1756
1838
|
async register() {
|
|
1757
1839
|
const e = this.getUaProtected();
|
|
1758
1840
|
return new Promise((t, s) => {
|
|
1759
|
-
e.on(
|
|
1841
|
+
e.on(A.REGISTERED, t), e.on(A.REGISTRATION_FAILED, s), e.register();
|
|
1760
1842
|
});
|
|
1761
1843
|
}
|
|
1762
1844
|
async unregister() {
|
|
1763
1845
|
const e = this.getUaProtected();
|
|
1764
1846
|
return new Promise((t) => {
|
|
1765
|
-
e.on(
|
|
1847
|
+
e.on(A.UNREGISTERED, t), e.unregister();
|
|
1766
1848
|
});
|
|
1767
1849
|
}
|
|
1768
1850
|
async tryRegister() {
|
|
1769
1851
|
try {
|
|
1770
1852
|
await this.unregister();
|
|
1771
1853
|
} catch (e) {
|
|
1772
|
-
|
|
1854
|
+
E("tryRegister", e);
|
|
1773
1855
|
}
|
|
1774
1856
|
return this.register();
|
|
1775
1857
|
}
|
|
1776
1858
|
subscribeToStartEvents(e, t) {
|
|
1777
|
-
const s =
|
|
1859
|
+
const s = A.REGISTERED, r = [A.REGISTRATION_FAILED, A.DISCONNECTED];
|
|
1778
1860
|
return this.events.on(s, e), r.forEach((i) => {
|
|
1779
1861
|
this.events.on(i, t);
|
|
1780
1862
|
}), () => {
|
|
@@ -1784,7 +1866,7 @@ class at {
|
|
|
1784
1866
|
};
|
|
1785
1867
|
}
|
|
1786
1868
|
}
|
|
1787
|
-
class
|
|
1869
|
+
class ct {
|
|
1788
1870
|
uaFactory;
|
|
1789
1871
|
getUaProtected;
|
|
1790
1872
|
constructor(e) {
|
|
@@ -1839,21 +1921,21 @@ class ot {
|
|
|
1839
1921
|
const S = new Error("Telephony is not available");
|
|
1840
1922
|
c(S);
|
|
1841
1923
|
};
|
|
1842
|
-
u.once(
|
|
1924
|
+
u.once(A.DISCONNECTED, T);
|
|
1843
1925
|
const g = () => {
|
|
1844
|
-
u.removeAllListeners(), u.once(
|
|
1926
|
+
u.removeAllListeners(), u.once(A.DISCONNECTED, () => {
|
|
1845
1927
|
o();
|
|
1846
1928
|
}), u.stop();
|
|
1847
1929
|
};
|
|
1848
|
-
u.once(
|
|
1930
|
+
u.once(A.CONNECTED, g), u.start();
|
|
1849
1931
|
});
|
|
1850
1932
|
}
|
|
1851
1933
|
}
|
|
1852
|
-
const
|
|
1934
|
+
const dt = (n) => {
|
|
1853
1935
|
const e = [];
|
|
1854
1936
|
return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
|
|
1855
1937
|
};
|
|
1856
|
-
class
|
|
1938
|
+
class O {
|
|
1857
1939
|
JsSIP;
|
|
1858
1940
|
constructor(e) {
|
|
1859
1941
|
this.JsSIP = e;
|
|
@@ -1878,10 +1960,10 @@ class v {
|
|
|
1878
1960
|
throw new Error("user is required for authorized connection");
|
|
1879
1961
|
}
|
|
1880
1962
|
static resolveAuthorizationUser(e, t) {
|
|
1881
|
-
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${
|
|
1963
|
+
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${fe()}`;
|
|
1882
1964
|
}
|
|
1883
1965
|
static buildExtraHeaders(e, t) {
|
|
1884
|
-
const s = e !== void 0 && e !== "" ?
|
|
1966
|
+
const s = e !== void 0 && e !== "" ? dt(e) : [];
|
|
1885
1967
|
return t === void 0 ? s : [...s, ...t];
|
|
1886
1968
|
}
|
|
1887
1969
|
createConfiguration({
|
|
@@ -1898,36 +1980,36 @@ class v {
|
|
|
1898
1980
|
connectionRecoveryMaxInterval: u = 6,
|
|
1899
1981
|
userAgent: T
|
|
1900
1982
|
}) {
|
|
1901
|
-
|
|
1983
|
+
O.validateConfiguration({
|
|
1902
1984
|
register: a,
|
|
1903
1985
|
password: t,
|
|
1904
1986
|
user: e,
|
|
1905
1987
|
sipServerUrl: i,
|
|
1906
1988
|
sipWebSocketServerURL: s
|
|
1907
1989
|
});
|
|
1908
|
-
const g =
|
|
1990
|
+
const g = O.resolveAuthorizationUser(a, e), S = Pe(i), I = S(g), _ = new this.JsSIP.WebSocketInterface(s);
|
|
1909
1991
|
return {
|
|
1910
1992
|
configuration: {
|
|
1911
1993
|
password: t,
|
|
1912
1994
|
register: a,
|
|
1913
|
-
uri:
|
|
1995
|
+
uri: I,
|
|
1914
1996
|
display_name: se(r),
|
|
1915
1997
|
user_agent: T,
|
|
1916
1998
|
sdpSemantics: "unified-plan",
|
|
1917
|
-
sockets: [
|
|
1999
|
+
sockets: [_],
|
|
1918
2000
|
session_timers: o,
|
|
1919
2001
|
register_expires: c,
|
|
1920
2002
|
connection_recovery_min_interval: d,
|
|
1921
2003
|
connection_recovery_max_interval: u
|
|
1922
2004
|
},
|
|
1923
2005
|
helpers: {
|
|
1924
|
-
socket:
|
|
2006
|
+
socket: _,
|
|
1925
2007
|
getSipServerUrl: S
|
|
1926
2008
|
}
|
|
1927
2009
|
};
|
|
1928
2010
|
}
|
|
1929
2011
|
createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
|
|
1930
|
-
const r = new this.JsSIP.UA(s), i =
|
|
2012
|
+
const r = new this.JsSIP.UA(s), i = O.buildExtraHeaders(e, t);
|
|
1931
2013
|
return i.length > 0 && r.registrator().setExtraHeaders(i), r;
|
|
1932
2014
|
}
|
|
1933
2015
|
/**
|
|
@@ -1945,7 +2027,7 @@ class v {
|
|
|
1945
2027
|
}), { ua: i, helpers: r };
|
|
1946
2028
|
}
|
|
1947
2029
|
}
|
|
1948
|
-
class
|
|
2030
|
+
class ht {
|
|
1949
2031
|
events;
|
|
1950
2032
|
ua;
|
|
1951
2033
|
socket;
|
|
@@ -1957,15 +2039,15 @@ class dt {
|
|
|
1957
2039
|
configurationManager;
|
|
1958
2040
|
JsSIP;
|
|
1959
2041
|
constructor({ JsSIP: e }) {
|
|
1960
|
-
this.JsSIP = e, this.events = new D(ge), this.uaFactory = new
|
|
2042
|
+
this.JsSIP = e, this.events = new D(ge), this.uaFactory = new O(e), this.registrationManager = new ot({
|
|
1961
2043
|
events: this.events,
|
|
1962
2044
|
getUaProtected: this.getUaProtected
|
|
1963
|
-
}), this.stateMachine = new
|
|
2045
|
+
}), this.stateMachine = new at(this.events), this.configurationManager = new nt({
|
|
1964
2046
|
getUa: this.getUa
|
|
1965
|
-
}), this.sipOperations = new
|
|
2047
|
+
}), this.sipOperations = new ct({
|
|
1966
2048
|
uaFactory: this.uaFactory,
|
|
1967
2049
|
getUaProtected: this.getUaProtected
|
|
1968
|
-
}), this.connectionFlow = new
|
|
2050
|
+
}), this.connectionFlow = new rt({
|
|
1969
2051
|
JsSIP: this.JsSIP,
|
|
1970
2052
|
events: this.events,
|
|
1971
2053
|
uaFactory: this.uaFactory,
|
|
@@ -2003,7 +2085,7 @@ class dt {
|
|
|
2003
2085
|
return this.stateMachine.state;
|
|
2004
2086
|
}
|
|
2005
2087
|
get isRegistered() {
|
|
2006
|
-
return
|
|
2088
|
+
return O.isRegisteredUA(this.ua);
|
|
2007
2089
|
}
|
|
2008
2090
|
get isRegisterConfig() {
|
|
2009
2091
|
return this.configurationManager.isRegister();
|
|
@@ -2056,7 +2138,7 @@ class dt {
|
|
|
2056
2138
|
};
|
|
2057
2139
|
getUa = () => this.ua;
|
|
2058
2140
|
}
|
|
2059
|
-
class
|
|
2141
|
+
class gt {
|
|
2060
2142
|
connectionManager;
|
|
2061
2143
|
stackPromises = Z({
|
|
2062
2144
|
noRunIsNotActual: !0
|
|
@@ -2074,14 +2156,14 @@ class ht {
|
|
|
2074
2156
|
ping = async (...e) => this.stackPromises.run(async () => this.connectionManager.ping(...e));
|
|
2075
2157
|
set = async (...e) => this.stackPromises.run(async () => this.connectionManager.set(...e));
|
|
2076
2158
|
}
|
|
2077
|
-
var
|
|
2159
|
+
var U = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(U || {}), x = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(x || {});
|
|
2078
2160
|
const ue = [
|
|
2079
2161
|
"incomingCall",
|
|
2080
2162
|
"declinedIncomingCall",
|
|
2081
2163
|
"terminatedIncomingCall",
|
|
2082
2164
|
"failedIncomingCall"
|
|
2083
|
-
],
|
|
2084
|
-
class
|
|
2165
|
+
], lt = 486, ut = 487;
|
|
2166
|
+
class Tt {
|
|
2085
2167
|
events;
|
|
2086
2168
|
incomingRTCSession;
|
|
2087
2169
|
connectionManager;
|
|
@@ -2116,19 +2198,19 @@ class ut {
|
|
|
2116
2198
|
return this.removeIncomingSession(), e;
|
|
2117
2199
|
};
|
|
2118
2200
|
async declineToIncomingCall({
|
|
2119
|
-
statusCode: e =
|
|
2201
|
+
statusCode: e = ut
|
|
2120
2202
|
} = {}) {
|
|
2121
2203
|
return new Promise((t, s) => {
|
|
2122
2204
|
try {
|
|
2123
2205
|
const r = this.getIncomingRTCSession(), i = this.remoteCallerData;
|
|
2124
|
-
this.removeIncomingSession(), this.events.trigger(
|
|
2206
|
+
this.removeIncomingSession(), this.events.trigger(U.DECLINED_INCOMING_CALL, i), r.terminate({ status_code: e }), t();
|
|
2125
2207
|
} catch (r) {
|
|
2126
2208
|
s(r);
|
|
2127
2209
|
}
|
|
2128
2210
|
});
|
|
2129
2211
|
}
|
|
2130
2212
|
async busyIncomingCall() {
|
|
2131
|
-
return this.declineToIncomingCall({ statusCode:
|
|
2213
|
+
return this.declineToIncomingCall({ statusCode: lt });
|
|
2132
2214
|
}
|
|
2133
2215
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
2134
2216
|
on(e, t) {
|
|
@@ -2165,19 +2247,19 @@ class ut {
|
|
|
2165
2247
|
this.incomingRTCSession = e;
|
|
2166
2248
|
const t = this.remoteCallerData;
|
|
2167
2249
|
e.on("failed", (s) => {
|
|
2168
|
-
this.removeIncomingSession(), s.originator === x.LOCAL ? this.events.trigger(
|
|
2169
|
-
}), this.events.trigger(
|
|
2250
|
+
this.removeIncomingSession(), s.originator === x.LOCAL ? this.events.trigger(U.TERMINATED_INCOMING_CALL, t) : this.events.trigger(U.FAILED_INCOMING_CALL, t);
|
|
2251
|
+
}), this.events.trigger(U.INCOMING_CALL, t);
|
|
2170
2252
|
}
|
|
2171
2253
|
removeIncomingSession() {
|
|
2172
2254
|
delete this.incomingRTCSession;
|
|
2173
2255
|
}
|
|
2174
2256
|
}
|
|
2175
|
-
const
|
|
2257
|
+
const b = 1e3;
|
|
2176
2258
|
var C = /* @__PURE__ */ ((n) => (n.INBOUND_RTP = "inbound-rtp", n.REMOTE_OUTBOUND_RTP = "remote-outbound-rtp", n.MEDIA_SOURCE = "media-source", n.OUTBOUND_RTP = "outbound-rtp", n.REMOTE_INBOUND_RTP = "remote-inbound-rtp", n.CODEC = "codec", n.CANDIDATE_PAIR = "candidate-pair", n.CERTIFICATE = "certificate", n.TRANSPORT = "transport", n.LOCAL_CANDIDATE = "local-candidate", n.REMOTE_CANDIDATE = "remote-candidate", n))(C || {});
|
|
2177
|
-
const Te = ["collected"], Y = () => "performance" in window ? performance.now() : Date.now(),
|
|
2259
|
+
const Te = ["collected"], Y = () => "performance" in window ? performance.now() : Date.now(), w = (n) => [...n.keys()].reduce((e, t) => {
|
|
2178
2260
|
const s = n.get(t);
|
|
2179
2261
|
return s === void 0 ? e : { ...e, [s.type]: s };
|
|
2180
|
-
}, {}),
|
|
2262
|
+
}, {}), St = (n) => {
|
|
2181
2263
|
if (!n)
|
|
2182
2264
|
return {
|
|
2183
2265
|
outboundRtp: void 0,
|
|
@@ -2185,7 +2267,7 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2185
2267
|
mediaSource: void 0,
|
|
2186
2268
|
remoteInboundRtp: void 0
|
|
2187
2269
|
};
|
|
2188
|
-
const e =
|
|
2270
|
+
const e = w(n);
|
|
2189
2271
|
return {
|
|
2190
2272
|
outboundRtp: e[C.OUTBOUND_RTP],
|
|
2191
2273
|
codec: e[C.CODEC],
|
|
@@ -2200,7 +2282,7 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2200
2282
|
mediaSource: void 0,
|
|
2201
2283
|
remoteInboundRtp: void 0
|
|
2202
2284
|
};
|
|
2203
|
-
const e =
|
|
2285
|
+
const e = w(n);
|
|
2204
2286
|
return {
|
|
2205
2287
|
outboundRtp: e[C.OUTBOUND_RTP],
|
|
2206
2288
|
codec: e[C.CODEC],
|
|
@@ -2217,13 +2299,13 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2217
2299
|
codec: void 0,
|
|
2218
2300
|
synchronizationSources: e
|
|
2219
2301
|
};
|
|
2220
|
-
const t =
|
|
2302
|
+
const t = w(n);
|
|
2221
2303
|
return {
|
|
2222
2304
|
inboundRtp: t[C.INBOUND_RTP],
|
|
2223
2305
|
codec: t[C.CODEC],
|
|
2224
2306
|
synchronizationSources: e
|
|
2225
2307
|
};
|
|
2226
|
-
},
|
|
2308
|
+
}, Ct = ({
|
|
2227
2309
|
audioReceiverStats: n,
|
|
2228
2310
|
synchronizationSourcesAudio: e
|
|
2229
2311
|
}) => {
|
|
@@ -2234,7 +2316,7 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2234
2316
|
remoteOutboundRtp: void 0,
|
|
2235
2317
|
synchronizationSources: e
|
|
2236
2318
|
};
|
|
2237
|
-
const t =
|
|
2319
|
+
const t = w(n);
|
|
2238
2320
|
return {
|
|
2239
2321
|
inboundRtp: t[C.INBOUND_RTP],
|
|
2240
2322
|
codec: t[C.CODEC],
|
|
@@ -2250,7 +2332,7 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2250
2332
|
remoteCandidate: void 0,
|
|
2251
2333
|
transport: void 0
|
|
2252
2334
|
};
|
|
2253
|
-
const e =
|
|
2335
|
+
const e = w(n);
|
|
2254
2336
|
return {
|
|
2255
2337
|
candidatePair: e[C.CANDIDATE_PAIR],
|
|
2256
2338
|
certificate: e[C.CERTIFICATE],
|
|
@@ -2258,18 +2340,18 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2258
2340
|
remoteCandidate: e[C.REMOTE_CANDIDATE],
|
|
2259
2341
|
transport: e[C.TRANSPORT]
|
|
2260
2342
|
};
|
|
2261
|
-
},
|
|
2343
|
+
}, Et = ({
|
|
2262
2344
|
audioSenderStats: n,
|
|
2263
2345
|
videoSenderFirstStats: e,
|
|
2264
2346
|
videoSenderSecondStats: t
|
|
2265
2347
|
}) => ({
|
|
2266
2348
|
video: z(e),
|
|
2267
2349
|
secondVideo: z(t),
|
|
2268
|
-
audio:
|
|
2350
|
+
audio: St(n),
|
|
2269
2351
|
additional: Se(
|
|
2270
2352
|
n ?? e ?? t
|
|
2271
2353
|
)
|
|
2272
|
-
}),
|
|
2354
|
+
}), Nt = ({
|
|
2273
2355
|
audioReceiverStats: n,
|
|
2274
2356
|
videoReceiverFirstStats: e,
|
|
2275
2357
|
videoReceiverSecondStats: t,
|
|
@@ -2283,14 +2365,14 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2283
2365
|
videoReceiversStats: t,
|
|
2284
2366
|
synchronizationSourcesVideo: s.video
|
|
2285
2367
|
}),
|
|
2286
|
-
audio:
|
|
2368
|
+
audio: Ct({
|
|
2287
2369
|
audioReceiverStats: n,
|
|
2288
2370
|
synchronizationSourcesAudio: s.audio
|
|
2289
2371
|
}),
|
|
2290
2372
|
additional: Se(
|
|
2291
2373
|
n ?? e ?? t
|
|
2292
2374
|
)
|
|
2293
|
-
}),
|
|
2375
|
+
}), At = ({
|
|
2294
2376
|
audioSenderStats: n,
|
|
2295
2377
|
videoSenderFirstStats: e,
|
|
2296
2378
|
videoSenderSecondStats: t,
|
|
@@ -2299,11 +2381,11 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2299
2381
|
videoReceiverSecondStats: i,
|
|
2300
2382
|
synchronizationSources: a
|
|
2301
2383
|
}) => {
|
|
2302
|
-
const o =
|
|
2384
|
+
const o = Et({
|
|
2303
2385
|
audioSenderStats: n,
|
|
2304
2386
|
videoSenderFirstStats: e,
|
|
2305
2387
|
videoSenderSecondStats: t
|
|
2306
|
-
}), c =
|
|
2388
|
+
}), c = Nt({
|
|
2307
2389
|
audioReceiverStats: s,
|
|
2308
2390
|
videoReceiverFirstStats: r,
|
|
2309
2391
|
videoReceiverSecondStats: i,
|
|
@@ -2313,7 +2395,7 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2313
2395
|
outbound: o,
|
|
2314
2396
|
inbound: c
|
|
2315
2397
|
};
|
|
2316
|
-
},
|
|
2398
|
+
}, Rt = async (n) => {
|
|
2317
2399
|
const e = "audio", t = "video", s = n.getSenders(), r = s.find((g) => g.track?.kind === e), i = s.filter((g) => g.track?.kind === t), a = n.getReceivers(), o = a.find((g) => g.track.kind === e), c = a.filter((g) => g.track.kind === t), d = {
|
|
2318
2400
|
trackIdentifier: o?.track.id,
|
|
2319
2401
|
item: o?.getSynchronizationSources()[0]
|
|
@@ -2325,38 +2407,38 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2325
2407
|
video: u
|
|
2326
2408
|
};
|
|
2327
2409
|
return Promise.all([
|
|
2328
|
-
r?.getStats(),
|
|
2329
|
-
i[0]?.getStats(),
|
|
2330
|
-
i[1]?.getStats(),
|
|
2331
|
-
o?.getStats(),
|
|
2332
|
-
c[0]?.getStats(),
|
|
2333
|
-
c[1]?.getStats()
|
|
2410
|
+
r?.getStats() ?? Promise.resolve(void 0),
|
|
2411
|
+
i[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2412
|
+
i[1]?.getStats() ?? Promise.resolve(void 0),
|
|
2413
|
+
o?.getStats() ?? Promise.resolve(void 0),
|
|
2414
|
+
c[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2415
|
+
c[1]?.getStats() ?? Promise.resolve(void 0)
|
|
2334
2416
|
]).then((g) => {
|
|
2335
2417
|
const [
|
|
2336
2418
|
S,
|
|
2337
|
-
m,
|
|
2338
2419
|
I,
|
|
2420
|
+
_,
|
|
2339
2421
|
R,
|
|
2340
2422
|
y,
|
|
2341
|
-
|
|
2423
|
+
$
|
|
2342
2424
|
] = g;
|
|
2343
2425
|
return {
|
|
2344
2426
|
synchronizationSources: T,
|
|
2345
2427
|
audioSenderStats: S,
|
|
2346
|
-
videoSenderFirstStats:
|
|
2347
|
-
videoSenderSecondStats:
|
|
2428
|
+
videoSenderFirstStats: I,
|
|
2429
|
+
videoSenderSecondStats: _,
|
|
2348
2430
|
audioReceiverStats: R,
|
|
2349
2431
|
videoReceiverFirstStats: y,
|
|
2350
|
-
videoReceiverSecondStats:
|
|
2432
|
+
videoReceiverSecondStats: $
|
|
2351
2433
|
};
|
|
2352
2434
|
});
|
|
2353
|
-
},
|
|
2354
|
-
|
|
2435
|
+
}, It = (n) => {
|
|
2436
|
+
E(String(n));
|
|
2355
2437
|
};
|
|
2356
|
-
class
|
|
2438
|
+
class _t {
|
|
2357
2439
|
events;
|
|
2358
2440
|
setTimeoutRequest;
|
|
2359
|
-
requesterAllStatistics = new Re(
|
|
2441
|
+
requesterAllStatistics = new Re(Rt);
|
|
2360
2442
|
constructor() {
|
|
2361
2443
|
this.events = new K(Te), this.setTimeoutRequest = new ee();
|
|
2362
2444
|
}
|
|
@@ -2364,8 +2446,8 @@ class It {
|
|
|
2364
2446
|
return this.setTimeoutRequest.requested;
|
|
2365
2447
|
}
|
|
2366
2448
|
start(e, {
|
|
2367
|
-
interval: t =
|
|
2368
|
-
onError: s =
|
|
2449
|
+
interval: t = b,
|
|
2450
|
+
onError: s = It
|
|
2369
2451
|
} = {}) {
|
|
2370
2452
|
this.stop(), this.setTimeoutRequest.request(() => {
|
|
2371
2453
|
this.collectStatistics(e, {
|
|
@@ -2396,10 +2478,10 @@ class It {
|
|
|
2396
2478
|
}) => {
|
|
2397
2479
|
const s = Y();
|
|
2398
2480
|
this.requesterAllStatistics.request(e).then((r) => {
|
|
2399
|
-
this.events.trigger("collected",
|
|
2481
|
+
this.events.trigger("collected", At(r));
|
|
2400
2482
|
const a = Y() - s;
|
|
2401
|
-
let o =
|
|
2402
|
-
a > 48 ? o =
|
|
2483
|
+
let o = b;
|
|
2484
|
+
a > 48 ? o = b * 4 : a > 32 ? o = b * 3 : a > 16 && (o = b * 2), this.start(e, {
|
|
2403
2485
|
onError: t,
|
|
2404
2486
|
interval: o
|
|
2405
2487
|
});
|
|
@@ -2408,7 +2490,7 @@ class It {
|
|
|
2408
2490
|
});
|
|
2409
2491
|
};
|
|
2410
2492
|
}
|
|
2411
|
-
class
|
|
2493
|
+
class mt {
|
|
2412
2494
|
availableIncomingBitrate;
|
|
2413
2495
|
statsPeerConnection;
|
|
2414
2496
|
callManager;
|
|
@@ -2418,7 +2500,7 @@ class _t {
|
|
|
2418
2500
|
callManager: e,
|
|
2419
2501
|
apiManager: t
|
|
2420
2502
|
}) {
|
|
2421
|
-
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new
|
|
2503
|
+
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new _t(), this.subscribe();
|
|
2422
2504
|
}
|
|
2423
2505
|
get events() {
|
|
2424
2506
|
return this.statsPeerConnection.events;
|
|
@@ -2456,36 +2538,36 @@ class _t {
|
|
|
2456
2538
|
};
|
|
2457
2539
|
maybeSendStats() {
|
|
2458
2540
|
this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
|
|
2459
|
-
|
|
2541
|
+
E("Failed to send stats", e);
|
|
2460
2542
|
});
|
|
2461
2543
|
}
|
|
2462
2544
|
}
|
|
2463
|
-
const Mt = (n, e) => n.filter((s) => e.some((r) => r.clockRate === s.clockRate && r.mimeType === s.mimeType && r.channels === s.channels && r.sdpFmtpLine === s.sdpFmtpLine)),
|
|
2545
|
+
const Mt = (n, e) => n.filter((s) => e.some((r) => r.clockRate === s.clockRate && r.mimeType === s.mimeType && r.channels === s.channels && r.sdpFmtpLine === s.sdpFmtpLine)), pt = (n) => {
|
|
2464
2546
|
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, r = t === null ? [] : t.codecs;
|
|
2465
2547
|
return Mt(s, r);
|
|
2466
|
-
},
|
|
2548
|
+
}, Pt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
|
|
2467
2549
|
const r = e.indexOf(t.mimeType), i = e.indexOf(s.mimeType), a = r === -1 ? Number.MAX_VALUE : r, o = i === -1 ? Number.MAX_VALUE : i;
|
|
2468
2550
|
return a - o;
|
|
2469
|
-
}),
|
|
2551
|
+
}), vt = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), ft = (n, {
|
|
2470
2552
|
preferredMimeTypesVideoCodecs: e,
|
|
2471
2553
|
excludeMimeTypesVideoCodecs: t
|
|
2472
2554
|
}) => {
|
|
2473
2555
|
try {
|
|
2474
2556
|
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
2475
|
-
const s =
|
|
2557
|
+
const s = pt("video"), r = vt(s, t), i = Pt(r, e);
|
|
2476
2558
|
n.setCodecPreferences(i);
|
|
2477
2559
|
}
|
|
2478
2560
|
} catch (s) {
|
|
2479
|
-
|
|
2561
|
+
E("setCodecPreferences error", s);
|
|
2480
2562
|
}
|
|
2481
|
-
}, Ot = (n) => [...n.keys()].map((e) => n.get(e)),
|
|
2482
|
-
class
|
|
2563
|
+
}, Ot = (n) => [...n.keys()].map((e) => n.get(e)), Dt = (n, e) => Ot(n).find((t) => t?.type === e), yt = async (n) => n.getStats().then((e) => Dt(e, "codec")?.mimeType);
|
|
2564
|
+
class bt {
|
|
2483
2565
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
2484
2566
|
async getCodecFromSender(e) {
|
|
2485
|
-
return await
|
|
2567
|
+
return await yt(e) ?? "";
|
|
2486
2568
|
}
|
|
2487
2569
|
}
|
|
2488
|
-
class
|
|
2570
|
+
class Ut {
|
|
2489
2571
|
stackPromises = Z({
|
|
2490
2572
|
noRunIsNotActual: !0
|
|
2491
2573
|
});
|
|
@@ -2506,15 +2588,15 @@ class bt {
|
|
|
2506
2588
|
*/
|
|
2507
2589
|
async run() {
|
|
2508
2590
|
return this.stackPromises().catch((e) => {
|
|
2509
|
-
|
|
2591
|
+
E("TaskQueue: error", e);
|
|
2510
2592
|
});
|
|
2511
2593
|
}
|
|
2512
2594
|
}
|
|
2513
|
-
class
|
|
2595
|
+
class wt {
|
|
2514
2596
|
taskQueue;
|
|
2515
2597
|
onSetParameters;
|
|
2516
2598
|
constructor(e) {
|
|
2517
|
-
this.onSetParameters = e, this.taskQueue = new
|
|
2599
|
+
this.onSetParameters = e, this.taskQueue = new Ut();
|
|
2518
2600
|
}
|
|
2519
2601
|
async setEncodingsToSender(e, t) {
|
|
2520
2602
|
return this.taskQueue.add(async () => ce(e, t, this.onSetParameters));
|
|
@@ -2523,17 +2605,17 @@ class Ut {
|
|
|
2523
2605
|
this.taskQueue.stop();
|
|
2524
2606
|
}
|
|
2525
2607
|
}
|
|
2526
|
-
const Ce = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()),
|
|
2527
|
-
const t =
|
|
2608
|
+
const Ce = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Lt = 1e6, p = (n) => n * Lt, Ee = p(0.06), Ne = p(4), Bt = (n) => n <= 64 ? Ee : n <= 128 ? p(0.12) : n <= 256 ? p(0.25) : n <= 384 ? p(0.32) : n <= 426 ? p(0.38) : n <= 640 ? p(0.5) : n <= 848 ? p(0.7) : n <= 1280 ? p(1) : n <= 1920 ? p(2) : Ne, kt = "av1", Ft = (n) => Ce(n, kt), $t = 0.6, Q = (n, e) => Ft(e) ? n * $t : n, Vt = (n) => Q(Ee, n), Wt = (n) => Q(Ne, n), J = (n, e) => {
|
|
2609
|
+
const t = Bt(n);
|
|
2528
2610
|
return Q(t, e);
|
|
2529
|
-
}, V = 1,
|
|
2611
|
+
}, V = 1, Ht = ({
|
|
2530
2612
|
videoTrack: n,
|
|
2531
2613
|
targetSize: e
|
|
2532
2614
|
}) => {
|
|
2533
2615
|
const t = n.getSettings(), s = t.width, r = t.height, i = s === void 0 ? V : s / e.width, a = r === void 0 ? V : r / e.height;
|
|
2534
2616
|
return Math.max(i, a, V);
|
|
2535
2617
|
};
|
|
2536
|
-
class
|
|
2618
|
+
class xt {
|
|
2537
2619
|
ignoreForCodec;
|
|
2538
2620
|
senderFinder;
|
|
2539
2621
|
codecProvider;
|
|
@@ -2608,7 +2690,7 @@ class Ht {
|
|
|
2608
2690
|
async downgradeResolutionSender(e) {
|
|
2609
2691
|
const { sender: t, codec: s } = e, r = {
|
|
2610
2692
|
scaleResolutionDownBy: 200,
|
|
2611
|
-
maxBitrate:
|
|
2693
|
+
maxBitrate: Vt(s)
|
|
2612
2694
|
};
|
|
2613
2695
|
return this.parametersSetter.setEncodingsToSender(t, r);
|
|
2614
2696
|
}
|
|
@@ -2618,7 +2700,7 @@ class Ht {
|
|
|
2618
2700
|
* @returns Promise с результатом
|
|
2619
2701
|
*/
|
|
2620
2702
|
async setBitrateByTrackResolution(e) {
|
|
2621
|
-
const { sender: t, videoTrack: s, codec: r } = e, a = s.getSettings().width, o = a === void 0 ?
|
|
2703
|
+
const { sender: t, videoTrack: s, codec: r } = e, a = s.getSettings().width, o = a === void 0 ? Wt(r) : J(a, r);
|
|
2622
2704
|
return this.parametersSetter.setEncodingsToSender(t, {
|
|
2623
2705
|
scaleResolutionDownBy: 1,
|
|
2624
2706
|
maxBitrate: o
|
|
@@ -2634,7 +2716,7 @@ class Ht {
|
|
|
2634
2716
|
const [s, r] = e.split("x"), { sender: i, videoTrack: a, codec: o } = t, c = {
|
|
2635
2717
|
width: Number(s),
|
|
2636
2718
|
height: Number(r)
|
|
2637
|
-
}, d =
|
|
2719
|
+
}, d = Ht({
|
|
2638
2720
|
videoTrack: a,
|
|
2639
2721
|
targetSize: c
|
|
2640
2722
|
}), u = J(c.width, o), T = {
|
|
@@ -2644,14 +2726,14 @@ class Ht {
|
|
|
2644
2726
|
return this.parametersSetter.setEncodingsToSender(i, T);
|
|
2645
2727
|
}
|
|
2646
2728
|
}
|
|
2647
|
-
const
|
|
2648
|
-
class
|
|
2729
|
+
const qt = (n) => n.find((e) => e.track?.kind === "video");
|
|
2730
|
+
class Gt {
|
|
2649
2731
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
2650
2732
|
findVideoSender(e) {
|
|
2651
|
-
return
|
|
2733
|
+
return qt(e);
|
|
2652
2734
|
}
|
|
2653
2735
|
}
|
|
2654
|
-
class
|
|
2736
|
+
class Qt {
|
|
2655
2737
|
currentSender;
|
|
2656
2738
|
originalReplaceTrack;
|
|
2657
2739
|
lastWidth;
|
|
@@ -2715,7 +2797,7 @@ class Gt {
|
|
|
2715
2797
|
this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
|
|
2716
2798
|
}
|
|
2717
2799
|
}
|
|
2718
|
-
class
|
|
2800
|
+
class Yt {
|
|
2719
2801
|
apiManager;
|
|
2720
2802
|
currentHandler;
|
|
2721
2803
|
constructor(e) {
|
|
@@ -2735,7 +2817,7 @@ class Qt {
|
|
|
2735
2817
|
this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
|
|
2736
2818
|
}
|
|
2737
2819
|
}
|
|
2738
|
-
class
|
|
2820
|
+
class zt {
|
|
2739
2821
|
eventHandler;
|
|
2740
2822
|
senderBalancer;
|
|
2741
2823
|
parametersSetterWithQueue;
|
|
@@ -2747,16 +2829,16 @@ class Yt {
|
|
|
2747
2829
|
onSetParameters: r,
|
|
2748
2830
|
pollIntervalMs: i
|
|
2749
2831
|
} = {}) {
|
|
2750
|
-
this.getConnection = t, this.eventHandler = new
|
|
2832
|
+
this.getConnection = t, this.eventHandler = new Yt(e), this.parametersSetterWithQueue = new wt(r), this.senderBalancer = new xt(
|
|
2751
2833
|
{
|
|
2752
|
-
senderFinder: new
|
|
2753
|
-
codecProvider: new
|
|
2834
|
+
senderFinder: new Gt(),
|
|
2835
|
+
codecProvider: new bt(),
|
|
2754
2836
|
parametersSetter: this.parametersSetterWithQueue
|
|
2755
2837
|
},
|
|
2756
2838
|
{
|
|
2757
2839
|
ignoreForCodec: s
|
|
2758
2840
|
}
|
|
2759
|
-
), this.trackMonitor = new
|
|
2841
|
+
), this.trackMonitor = new Qt({ pollIntervalMs: i });
|
|
2760
2842
|
}
|
|
2761
2843
|
/**
|
|
2762
2844
|
* Подписывается на события управления главной камерой
|
|
@@ -2787,7 +2869,7 @@ class Yt {
|
|
|
2787
2869
|
const t = await this.senderBalancer.balance(e, this.serverHeaders);
|
|
2788
2870
|
return this.trackMonitor.subscribe(t.sender, () => {
|
|
2789
2871
|
this.balance().catch((s) => {
|
|
2790
|
-
|
|
2872
|
+
E("balance on track change: error", s);
|
|
2791
2873
|
});
|
|
2792
2874
|
}), t;
|
|
2793
2875
|
}
|
|
@@ -2797,7 +2879,7 @@ class Yt {
|
|
|
2797
2879
|
*/
|
|
2798
2880
|
handleMainCamControl = (e) => {
|
|
2799
2881
|
this.serverHeaders = e, this.balance().catch((t) => {
|
|
2800
|
-
|
|
2882
|
+
E("handleMainCamControl: error", t);
|
|
2801
2883
|
});
|
|
2802
2884
|
};
|
|
2803
2885
|
}
|
|
@@ -2807,7 +2889,7 @@ const Ae = [
|
|
|
2807
2889
|
"balancing-stopped",
|
|
2808
2890
|
"parameters-updated"
|
|
2809
2891
|
];
|
|
2810
|
-
class
|
|
2892
|
+
class Xt {
|
|
2811
2893
|
isBalancingActive = !1;
|
|
2812
2894
|
events;
|
|
2813
2895
|
callManager;
|
|
@@ -2815,7 +2897,7 @@ class zt {
|
|
|
2815
2897
|
videoSendingBalancer;
|
|
2816
2898
|
startBalancingTimer;
|
|
2817
2899
|
constructor(e, t, s = {}) {
|
|
2818
|
-
this.events = new K(Ae), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new
|
|
2900
|
+
this.events = new K(Ae), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new zt(
|
|
2819
2901
|
t,
|
|
2820
2902
|
() => e.connection,
|
|
2821
2903
|
{
|
|
@@ -2877,7 +2959,7 @@ class zt {
|
|
|
2877
2959
|
scheduleBalancingStart() {
|
|
2878
2960
|
this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
|
|
2879
2961
|
this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
|
|
2880
|
-
|
|
2962
|
+
E("startBalancing: error", e);
|
|
2881
2963
|
});
|
|
2882
2964
|
}, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
|
|
2883
2965
|
}
|
|
@@ -2885,16 +2967,16 @@ class zt {
|
|
|
2885
2967
|
this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
|
|
2886
2968
|
}
|
|
2887
2969
|
}
|
|
2888
|
-
const
|
|
2889
|
-
...Jt,
|
|
2970
|
+
const Jt = 1e6, Kt = ge.map((n) => `connection:${n}`), jt = ne.map((n) => `call:${n}`), Zt = ie.map((n) => `api:${n}`), en = ue.map((n) => `incoming-call:${n}`), tn = de.map((n) => `presentation:${n}`), nn = Te.map((n) => `stats:${n}`), sn = Ae.map((n) => `video-balancer:${n}`), rn = [
|
|
2890
2971
|
...Kt,
|
|
2891
2972
|
...jt,
|
|
2892
2973
|
...Zt,
|
|
2893
2974
|
...en,
|
|
2894
2975
|
...tn,
|
|
2895
|
-
...nn
|
|
2976
|
+
...nn,
|
|
2977
|
+
...sn
|
|
2896
2978
|
];
|
|
2897
|
-
class
|
|
2979
|
+
class Nn {
|
|
2898
2980
|
events;
|
|
2899
2981
|
connectionManager;
|
|
2900
2982
|
connectionQueueManager;
|
|
@@ -2911,18 +2993,18 @@ class En {
|
|
|
2911
2993
|
excludeMimeTypesVideoCodecs: s,
|
|
2912
2994
|
videoBalancerOptions: r
|
|
2913
2995
|
} = {}) {
|
|
2914
|
-
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new D(
|
|
2996
|
+
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new D(rn), this.connectionManager = new ht({ JsSIP: e }), this.connectionQueueManager = new gt({
|
|
2915
2997
|
connectionManager: this.connectionManager
|
|
2916
|
-
}), this.callManager = new
|
|
2998
|
+
}), this.callManager = new we(), this.apiManager = new Ve({
|
|
2917
2999
|
connectionManager: this.connectionManager,
|
|
2918
3000
|
callManager: this.callManager
|
|
2919
|
-
}), this.incomingCallManager = new
|
|
3001
|
+
}), this.incomingCallManager = new Tt(this.connectionManager), this.presentationManager = new tt({
|
|
2920
3002
|
callManager: this.callManager,
|
|
2921
|
-
maxBitrate:
|
|
2922
|
-
}), this.statsManager = new
|
|
3003
|
+
maxBitrate: Jt
|
|
3004
|
+
}), this.statsManager = new mt({
|
|
2923
3005
|
callManager: this.callManager,
|
|
2924
3006
|
apiManager: this.apiManager
|
|
2925
|
-
}), this.videoSendingBalancerManager = new
|
|
3007
|
+
}), this.videoSendingBalancerManager = new Xt(
|
|
2926
3008
|
this.callManager,
|
|
2927
3009
|
this.apiManager,
|
|
2928
3010
|
r
|
|
@@ -3145,25 +3227,37 @@ class En {
|
|
|
3145
3227
|
});
|
|
3146
3228
|
}), this.apiManager.on("restart", this.handleRestart);
|
|
3147
3229
|
}
|
|
3148
|
-
handleRestart = () => {
|
|
3149
|
-
this.
|
|
3150
|
-
|
|
3230
|
+
handleRestart = (e) => {
|
|
3231
|
+
this.updateTransceivers(e).catch((t) => {
|
|
3232
|
+
E("Failed to update transceivers", t);
|
|
3233
|
+
}).finally(() => {
|
|
3234
|
+
this.callManager.restartIce().catch((t) => {
|
|
3235
|
+
E("Failed to restart ICE", t);
|
|
3236
|
+
});
|
|
3151
3237
|
});
|
|
3152
3238
|
};
|
|
3239
|
+
updateTransceivers = async (e) => {
|
|
3240
|
+
const { videoTrackCount: t } = e;
|
|
3241
|
+
t === 2 && (this.callManager.getTransceivers().presentationVideo !== void 0 || await this.callManager.addTransceiver("video", {
|
|
3242
|
+
direction: "recvonly"
|
|
3243
|
+
}).catch((i) => {
|
|
3244
|
+
E("Failed to add presentation video transceiver", i);
|
|
3245
|
+
}));
|
|
3246
|
+
};
|
|
3153
3247
|
}
|
|
3154
3248
|
export {
|
|
3155
3249
|
re as E,
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3250
|
+
F as O,
|
|
3251
|
+
Nn as S,
|
|
3252
|
+
Ke as a,
|
|
3253
|
+
$e as b,
|
|
3160
3254
|
C as c,
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3255
|
+
Cn as d,
|
|
3256
|
+
Sn as e,
|
|
3257
|
+
_t as f,
|
|
3258
|
+
yt as g,
|
|
3259
|
+
En as h,
|
|
3260
|
+
E as l,
|
|
3261
|
+
L as p,
|
|
3168
3262
|
ce as s
|
|
3169
3263
|
};
|