sip-connector 14.1.2-7 → 15.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-BBhQzo-W.cjs +1 -0
- package/dist/@SipConnector-G96OmJEP.js +2248 -0
- package/dist/ApiManager/@ApiManager.d.ts +59 -0
- package/dist/ApiManager/__tests-utils__/helpers.d.ts +9 -0
- package/dist/ApiManager/constants.d.ts +72 -0
- package/dist/ApiManager/eventNames.d.ts +34 -0
- package/dist/ApiManager/index.d.ts +3 -0
- package/dist/ApiManager/types.d.ts +99 -0
- package/dist/CallManager/@CallManager.d.ts +26 -0
- package/dist/CallManager/AbstractCallStrategy.d.ts +47 -0
- package/dist/CallManager/MCUCallStrategy.d.ts +30 -0
- package/dist/CallManager/RemoteStreamsManager.d.ts +8 -0
- package/dist/CallManager/causes.d.ts +13 -0
- package/dist/CallManager/eventNames.d.ts +45 -0
- package/dist/CallManager/hasCanceledCallError.d.ts +2 -0
- package/dist/CallManager/index.d.ts +7 -0
- package/dist/CallManager/types.d.ts +59 -0
- package/dist/ConnectionManager/@ConnectionManager.d.ts +48 -0
- package/dist/ConnectionManager/ConfigurationManager.d.ts +60 -0
- package/dist/ConnectionManager/ConnectionFlow.d.ts +84 -0
- package/dist/ConnectionManager/ConnectionStateMachine.d.ts +61 -0
- package/dist/ConnectionManager/RegistrationManager.d.ts +17 -0
- package/dist/ConnectionManager/SipOperations.d.ts +32 -0
- package/dist/ConnectionManager/UAFactory.d.ts +50 -0
- package/dist/ConnectionManager/eventNames.d.ts +16 -0
- package/dist/ConnectionManager/getExtraHeadersRemoteAddress.d.ts +2 -0
- package/dist/ConnectionManager/index.d.ts +3 -0
- package/dist/IncomingCallManager/@IncomingCallManager.d.ts +37 -0
- package/dist/IncomingCallManager/eventNames.d.ts +13 -0
- package/dist/IncomingCallManager/index.d.ts +2 -0
- package/dist/PresentationManager/@PresentationManager.d.ts +47 -0
- package/dist/PresentationManager/constants.d.ts +1 -0
- package/dist/PresentationManager/eventNames.d.ts +11 -0
- package/dist/PresentationManager/index.d.ts +2 -0
- package/dist/PresentationManager/types.d.ts +2 -0
- package/dist/SipConnector/@SipConnector.d.ts +96 -0
- package/dist/SipConnector/eventNames.d.ts +4 -0
- package/dist/SipConnector/index.d.ts +2 -0
- package/dist/{src/SipConnectorFacade → SipConnectorFacade}/SipConnectorFacade.d.ts +19 -17
- package/dist/{src/__fixtures__ → __fixtures__}/BaseSession.mock.d.ts +9 -9
- package/dist/{src/__fixtures__ → __fixtures__}/RTCPeerConnectionMock.d.ts +7 -1
- package/dist/{src/__fixtures__ → __fixtures__}/RTCRtpSenderMock.d.ts +1 -0
- package/dist/{src/__fixtures__ → __fixtures__}/RTCSessionMock.d.ts +14 -9
- package/dist/{src/__fixtures__ → __fixtures__}/UA.mock.d.ts +15 -17
- package/dist/{src → __fixtures__}/eventNames.d.ts +1 -1
- package/dist/{src/__fixtures__ → __fixtures__}/index.d.ts +4 -4
- package/dist/{src/__fixtures__ → __fixtures__}/jssip.mock.d.ts +4 -4
- package/dist/doMock.cjs +1 -1
- package/dist/{src/doMock.d.ts → doMock.d.ts} +2 -1
- package/dist/doMock.js +444 -344
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +14 -0
- package/dist/index.js +870 -703
- package/dist/setParametersToSender/index.d.ts +3 -0
- package/dist/{src/setParametersToSender → setParametersToSender}/resolveHasNeedToUpdateItemEncoding.d.ts +1 -1
- package/dist/{src/videoSendingBalancer → setParametersToSender}/setEncodingsToSender.d.ts +1 -5
- package/dist/setParametersToSender/setMaxBitrateToSender.d.ts +2 -0
- package/dist/{src/setParametersToSender → setParametersToSender}/setParametersToSender.d.ts +1 -4
- package/dist/setParametersToSender/types.d.ts +5 -0
- package/dist/{src/tools → tools}/__fixtures__/connectToServer.d.ts +2 -2
- package/dist/{src/tools → tools}/__fixtures__/processRequest.d.ts +1 -1
- package/dist/{src/tools → tools}/error/getLinkError.d.ts +1 -1
- package/dist/{src/tools → tools}/error/getTypeFromError.d.ts +1 -1
- package/dist/{src/tools → tools}/error/getValuesFromError.d.ts +1 -1
- package/dist/{src/tools → tools}/error/index.d.ts +1 -1
- package/dist/{src/tools → tools}/index.d.ts +2 -2
- package/dist/{src/tools → tools}/prepareMediaStream.d.ts +1 -1
- package/dist/{src/tools → tools}/setVideoTrackContentHints.d.ts +1 -1
- package/dist/{src/tools/syncMediaState/index.d.ts → tools/syncMediaState/createSyncMediaState.d.ts} +1 -1
- package/dist/tools/syncMediaState/index.d.ts +1 -0
- package/dist/{src/tools → tools}/syncMediaState/resolveOnStartMainCam.d.ts +1 -1
- package/dist/{src/tools → tools}/syncMediaState/resolveOnStartMic.d.ts +1 -1
- package/dist/{src/tools → tools}/syncMediaState/resolveOnStopMainCam.d.ts +1 -1
- package/dist/{src/tools → tools}/syncMediaState/resolveOnStopMic.d.ts +1 -1
- package/dist/types.d.ts +23 -0
- package/dist/utils/utils.d.ts +4 -0
- package/dist/videoSendingBalancer/CodecProvider.d.ts +7 -0
- package/dist/videoSendingBalancer/ParametersSetterWithQueue.d.ts +12 -0
- package/dist/videoSendingBalancer/SenderBalancer.d.ts +52 -0
- package/dist/videoSendingBalancer/SenderFinder.d.ts +7 -0
- package/dist/videoSendingBalancer/TaskQueue.d.ts +20 -0
- package/dist/videoSendingBalancer/VideoSendingBalancer.d.ts +44 -0
- package/dist/videoSendingBalancer/VideoSendingEventHandler.d.ts +25 -0
- package/dist/videoSendingBalancer/calcBitrate/calcMaxBitrateByWidth.d.ts +4 -0
- package/dist/videoSendingBalancer/calcBitrate/calcMaxBitrateByWidthAndCodec.d.ts +4 -0
- package/dist/videoSendingBalancer/calcBitrate/index.d.ts +1 -0
- package/dist/videoSendingBalancer/calcResolution/calcScaleResolutionDownBy.d.ts +6 -0
- package/dist/videoSendingBalancer/calcResolution/index.d.ts +1 -0
- package/dist/videoSendingBalancer/index.d.ts +3 -0
- package/dist/videoSendingBalancer/types.d.ts +36 -0
- package/package.json +36 -43
- package/dist/SipConnector-BHvTGgmw.js +0 -1352
- package/dist/SipConnector-ChW25Tx9.cjs +0 -1
- package/dist/src/SipConnector.d.ts +0 -235
- package/dist/src/causes.d.ts +0 -23
- package/dist/src/getExtraHeadersRemoteAddress.d.ts +0 -2
- package/dist/src/headers.d.ts +0 -37
- package/dist/src/index.d.ts +0 -11
- package/dist/src/setParametersToSender/index.d.ts +0 -1
- package/dist/src/types.d.ts +0 -69
- package/dist/src/videoSendingBalancer/balance.d.ts +0 -10
- package/dist/src/videoSendingBalancer/getMaxBitrateByWidth.d.ts +0 -3
- package/dist/src/videoSendingBalancer/getMaxBitrateByWidthAndCodec.d.ts +0 -3
- package/dist/src/videoSendingBalancer/index.d.ts +0 -13
- package/dist/src/videoSendingBalancer/processSender.d.ts +0 -10
- package/dist/src/videoSendingBalancer/scaleBitrate.d.ts +0 -2
- /package/dist/{src/SipConnectorFacade → SipConnectorFacade}/index.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/Registrator.mock.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/Request.mock.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/WebSocketInterface.mock.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/accountNotify.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/channels.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/channelsNotify.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/conferenceParticipantTokenIssuedNotify.d.ts +0 -0
- /package/dist/{src → __fixtures__}/constants.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/delayPromise.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/enterRoom.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/mediaState.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/participantMoveRequests.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/participantNotify.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/remoteCallerData.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/utils.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/webcastNotify.d.ts +0 -0
- /package/dist/{src/logger.d.ts → logger.d.ts} +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/configureDegradationPreference.d.ts +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/configureEmptyEncodings.d.ts +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/configureEncodings.d.ts +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/configureMaxBitrate.d.ts +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/configureScaleResolutionDownBy.d.ts +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/hasChangedRTCRtpSendParameters.d.ts +0 -0
- /package/dist/{src/tools → tools}/__fixtures__/call.d.ts +0 -0
- /package/dist/{src/tools → tools}/__fixtures__/hasValidUri.d.ts +0 -0
- /package/dist/{src/tools → tools}/__fixtures__/permissions.d.ts +0 -0
- /package/dist/{src/tools → tools}/__tests-utils__/parseObject.d.ts +0 -0
- /package/dist/{src/tools → tools}/__tests-utils__/resolveParseArray.d.ts +0 -0
- /package/dist/{src/tools → tools}/error/stringifyMessage.d.ts +0 -0
- /package/dist/{src/tools → tools}/generateSimulcastEncodings.d.ts +0 -0
- /package/dist/{src/tools → tools}/getExtraHeaders.d.ts +0 -0
- /package/dist/{src/tools → tools}/getUserAgent.d.ts +0 -0
- /package/dist/{src/tools → tools}/hasPurgatory.d.ts +0 -0
- /package/dist/{src/tools → tools}/resolveUpdateTransceiver.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → tools}/scaleResolutionAndBitrate.d.ts +0 -0
- /package/dist/{src/tools/sendDTMFAccumulated.d.ts → tools/sendDtmfFAccumulated.d.ts} +0 -0
- /package/dist/{src/utils → utils}/errors.d.ts +0 -0
- /package/dist/{src/utils → utils}/findSenderByStream.d.ts +0 -0
- /package/dist/{src/utils → utils}/findVideoSender.d.ts +0 -0
- /package/dist/{src/utils → utils}/findVideoTrack.d.ts +0 -0
- /package/dist/{src/utils → utils}/getCodecFromSender.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → utils}/hasIncludesString.d.ts +0 -0
- /package/dist/{src/utils → utils}/replaceForbiddenSymbolsWithUnderscore.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → videoSendingBalancer/calcBitrate}/hasAv1Codec.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → videoSendingBalancer/calcBitrate}/scaleBitrateByCodec.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,369 +1,420 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { createStackPromises as
|
|
8
|
-
import
|
|
9
|
-
import { default as
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
import "events-constructor";
|
|
2
|
+
import { E as R, O as ie, l as i, a as w } from "./@SipConnector-G96OmJEP.js";
|
|
3
|
+
import { b as wn, S as Pn, d as Dn, e as kn, h as In } from "./@SipConnector-G96OmJEP.js";
|
|
4
|
+
import { isCanceledError as K } from "@krivega/cancelable-promise";
|
|
5
|
+
import { hasCanceledError as ce } from "repeated-calls";
|
|
6
|
+
import { debounce as ae } from "ts-debounce";
|
|
7
|
+
import { createStackPromises as de } from "stack-promises";
|
|
8
|
+
import k from "debug";
|
|
9
|
+
import { default as xn } from "debug";
|
|
10
|
+
import { sequentPromises as ue } from "sequent-promises";
|
|
11
|
+
const le = (n) => n instanceof Object && ("originator" in n || "cause" in n), bn = (n) => {
|
|
12
|
+
if (K(n))
|
|
13
|
+
return !0;
|
|
14
|
+
if (!le(n))
|
|
15
|
+
return !1;
|
|
16
|
+
const { originator: e, cause: t } = n;
|
|
17
|
+
return typeof t == "string" ? t === R.REQUEST_TIMEOUT || t === R.REJECTED || e === ie.LOCAL && (t === R.CANCELED || t === R.BYE) : !1;
|
|
18
|
+
}, he = (n, e) => (n.degradationPreference = e.degradationPreference, n), fe = (n, e) => {
|
|
19
|
+
n.encodings ??= [];
|
|
20
|
+
for (let t = n.encodings.length; t < e; t += 1)
|
|
21
|
+
n.encodings.push({});
|
|
22
|
+
return n;
|
|
23
|
+
}, Y = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, Se = Y(), Ce = (n, e) => {
|
|
24
|
+
if (Se(n, e))
|
|
25
|
+
return n;
|
|
26
|
+
}, ge = (n, e) => {
|
|
27
|
+
const t = n.maxBitrate, r = Ce(e, t);
|
|
28
|
+
return r !== void 0 && (n.maxBitrate = r), n;
|
|
29
|
+
}, q = 1, me = Y(
|
|
30
|
+
q
|
|
31
|
+
), pe = (n, e) => {
|
|
32
|
+
const t = n === void 0 ? void 0 : Math.max(n, q);
|
|
33
|
+
if (t !== void 0 && me(
|
|
34
|
+
t,
|
|
35
|
+
e
|
|
36
|
+
))
|
|
37
|
+
return t;
|
|
38
|
+
}, Re = (n, e) => {
|
|
39
|
+
const t = n.scaleResolutionDownBy, r = pe(
|
|
40
|
+
e,
|
|
41
|
+
t
|
|
42
|
+
);
|
|
43
|
+
return r !== void 0 && (n.scaleResolutionDownBy = r), n;
|
|
44
|
+
}, ye = (n, e) => {
|
|
45
|
+
const t = e.encodings?.length ?? 0;
|
|
46
|
+
return fe(n, t), n.encodings.forEach((r, s) => {
|
|
47
|
+
const o = (e?.encodings ?? [])[s], c = o?.maxBitrate, a = o?.scaleResolutionDownBy;
|
|
48
|
+
ge(r, c), Re(r, a);
|
|
49
|
+
}), n;
|
|
50
|
+
}, ve = (n, e) => {
|
|
51
|
+
if (n.codecs?.length !== e.codecs?.length)
|
|
52
|
+
return !0;
|
|
53
|
+
for (let t = 0; t < (n.codecs?.length ?? 0); t++)
|
|
54
|
+
if (JSON.stringify(n.codecs[t]) !== JSON.stringify(e.codecs[t]))
|
|
55
|
+
return !0;
|
|
56
|
+
if (n.headerExtensions?.length !== e.headerExtensions?.length)
|
|
57
|
+
return !0;
|
|
58
|
+
for (let t = 0; t < (n.headerExtensions?.length ?? 0); t++)
|
|
59
|
+
if (JSON.stringify(n.headerExtensions[t]) !== JSON.stringify(e.headerExtensions[t]))
|
|
60
|
+
return !0;
|
|
61
|
+
if (n.encodings?.length !== e.encodings?.length)
|
|
62
|
+
return !0;
|
|
63
|
+
for (let t = 0; t < (n.encodings?.length ?? 0); t++)
|
|
64
|
+
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
65
|
+
return !0;
|
|
66
|
+
return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
|
|
67
|
+
}, z = async (n, e) => {
|
|
68
|
+
const t = n.getParameters(), r = JSON.parse(
|
|
69
|
+
JSON.stringify(t)
|
|
70
|
+
);
|
|
71
|
+
ye(t, e), he(t, e);
|
|
72
|
+
const s = ve(r, t);
|
|
73
|
+
return s && await n.setParameters(t), { parameters: t, isChanged: s };
|
|
74
|
+
}, Te = async (n, e, t) => {
|
|
75
|
+
const { isChanged: r, parameters: s } = await z(n, {
|
|
76
|
+
encodings: [
|
|
77
|
+
{
|
|
78
|
+
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
79
|
+
maxBitrate: e.maxBitrate
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
return r && t && t(s), { isChanged: r, parameters: s };
|
|
84
|
+
}, Ee = (n) => n.getVideoTracks()[0], Me = 1e6, C = (n) => n * Me, Z = C(0.06), ee = C(4), be = (n) => n <= 64 ? Z : n <= 128 ? C(0.12) : n <= 256 ? C(0.25) : n <= 384 ? C(0.32) : n <= 426 ? C(0.38) : n <= 640 ? C(0.5) : n <= 848 ? C(0.7) : n <= 1280 ? C(1) : n <= 1920 ? C(2) : ee, ne = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Be = "av1", _e = (n) => ne(n, Be), Ae = 0.6, J = (n, e) => _e(e) ? n * Ae : n, Ne = (n) => J(Z, n), Oe = (n) => J(ee, n), Q = (n, e) => {
|
|
85
|
+
const t = be(n);
|
|
86
|
+
return J(t, e);
|
|
87
|
+
}, $ = 1, te = ({
|
|
88
|
+
videoTrack: n,
|
|
89
|
+
targetSize: e
|
|
90
|
+
}) => {
|
|
91
|
+
const t = n.getSettings(), r = t.width, s = t.height, o = r === void 0 ? $ : r / e.width, c = s === void 0 ? $ : s / e.height;
|
|
92
|
+
return Math.max(o, c, $);
|
|
93
|
+
}, we = (n) => [...n.keys()].map((e) => n.get(e)), Pe = (n, e) => we(n).find((t) => t?.type === e), De = async (n) => n.getStats().then((e) => Pe(e, "codec")?.mimeType);
|
|
94
|
+
class ke {
|
|
95
|
+
// eslint-disable-next-line class-methods-use-this
|
|
96
|
+
async getCodecFromSender(e) {
|
|
97
|
+
return await De(e) ?? "";
|
|
38
98
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
99
|
+
}
|
|
100
|
+
class Ie {
|
|
101
|
+
stackPromises = de({
|
|
102
|
+
noRunIsNotActual: !0
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* Добавляет задачу в очередь и возвращает Promise с результатом
|
|
106
|
+
* @param task - Функция для выполнения
|
|
107
|
+
* @returns Promise с результатом выполнения задачи
|
|
108
|
+
*/
|
|
109
|
+
async add(e) {
|
|
110
|
+
return this.stackPromises.add(e), this.run();
|
|
46
111
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
sendKey: e,
|
|
87
|
-
canRunTask: t
|
|
88
|
-
}) => {
|
|
89
|
-
const o = Oe(e)(n);
|
|
90
|
-
return le(o, t);
|
|
91
|
-
}, we = (n) => (t) => (c("onStartMainCam"), n.onSession("admin-start-main-cam", t)), Be = (n) => (t) => (c("onStartMic"), n.onSession("admin-start-mic", t)), Pe = (n) => (t) => (c("onStopMainCam"), n.onSession("admin-stop-main-cam", t)), Ie = (n) => (t) => (c("onStopMic"), n.onSession("admin-stop-mic", t)), De = ({ sipConnector: n }) => {
|
|
92
|
-
const e = (m, g) => ({ isSyncForced: h = !1 }) => {
|
|
93
|
-
if (h) {
|
|
94
|
-
m();
|
|
95
|
-
return;
|
|
112
|
+
stop() {
|
|
113
|
+
this.stackPromises.stop();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Выполняет задачи из очереди с обработкой ошибок
|
|
117
|
+
* @returns Promise с результатом выполнения
|
|
118
|
+
*/
|
|
119
|
+
async run() {
|
|
120
|
+
return this.stackPromises().catch((e) => {
|
|
121
|
+
i("TaskQueue: error", e);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
class Fe {
|
|
126
|
+
taskQueue;
|
|
127
|
+
onSetParameters;
|
|
128
|
+
constructor(e) {
|
|
129
|
+
this.onSetParameters = e, this.taskQueue = new Ie();
|
|
130
|
+
}
|
|
131
|
+
async setEncodingsToSender(e, t) {
|
|
132
|
+
return this.taskQueue.add(async () => Te(e, t, this.onSetParameters));
|
|
133
|
+
}
|
|
134
|
+
stop() {
|
|
135
|
+
this.taskQueue.stop();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
class xe {
|
|
139
|
+
ignoreForCodec;
|
|
140
|
+
senderFinder;
|
|
141
|
+
codecProvider;
|
|
142
|
+
parametersSetter;
|
|
143
|
+
resultNoChanged = {
|
|
144
|
+
isChanged: !1,
|
|
145
|
+
parameters: {
|
|
146
|
+
encodings: [{}],
|
|
147
|
+
transactionId: "0",
|
|
148
|
+
codecs: [],
|
|
149
|
+
headerExtensions: [],
|
|
150
|
+
rtcp: {}
|
|
96
151
|
}
|
|
97
|
-
g();
|
|
98
|
-
}, t = we(n), s = Pe(n), o = Be(n), r = Ie(n);
|
|
99
|
-
let i = () => {
|
|
100
|
-
}, u = () => {
|
|
101
|
-
}, d = () => {
|
|
102
|
-
}, C = () => {
|
|
103
152
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
153
|
+
constructor({
|
|
154
|
+
senderFinder: e,
|
|
155
|
+
codecProvider: t,
|
|
156
|
+
parametersSetter: r
|
|
157
|
+
}, s) {
|
|
158
|
+
this.senderFinder = e, this.codecProvider = t, this.parametersSetter = r, this.ignoreForCodec = s.ignoreForCodec;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Выполняет балансировку на основе заголовков от сервера
|
|
162
|
+
* @param connection - RTCPeerConnection для получения отправителей
|
|
163
|
+
* @param headers - Заголовки от сервера с командами управления
|
|
164
|
+
* @returns Promise с результатом балансировки
|
|
165
|
+
*/
|
|
166
|
+
async balance(e, t) {
|
|
167
|
+
const r = e.getSenders(), s = this.senderFinder.findVideoSender(r);
|
|
168
|
+
if (!s?.track)
|
|
169
|
+
return this.resultNoChanged;
|
|
170
|
+
const o = await this.codecProvider.getCodecFromSender(s);
|
|
171
|
+
if (ne(o, this.ignoreForCodec))
|
|
172
|
+
return this.resultNoChanged;
|
|
173
|
+
const { mainCam: c, resolutionMainCam: a } = t ?? {};
|
|
174
|
+
return this.processSender(
|
|
175
|
+
{ mainCam: c, resolutionMainCam: a },
|
|
176
|
+
{
|
|
177
|
+
sender: s,
|
|
178
|
+
codec: o,
|
|
179
|
+
videoTrack: s.track
|
|
180
|
+
}
|
|
122
181
|
);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Обрабатывает отправитель в зависимости от команды управления
|
|
185
|
+
* @param context - Контекст балансировки
|
|
186
|
+
* @returns Promise с результатом обработки
|
|
187
|
+
*/
|
|
188
|
+
async processSender(e, t) {
|
|
189
|
+
const { mainCam: r, resolutionMainCam: s } = e;
|
|
190
|
+
switch (r) {
|
|
191
|
+
case w.PAUSE_MAIN_CAM:
|
|
192
|
+
return this.downgradeResolutionSender(t);
|
|
193
|
+
case w.RESUME_MAIN_CAM:
|
|
194
|
+
return this.setBitrateByTrackResolution(t);
|
|
195
|
+
case w.MAX_MAIN_CAM_RESOLUTION:
|
|
196
|
+
return s !== void 0 ? this.setResolutionSender(s, t) : this.setBitrateByTrackResolution(t);
|
|
197
|
+
case w.ADMIN_STOP_MAIN_CAM:
|
|
198
|
+
case w.ADMIN_START_MAIN_CAM:
|
|
199
|
+
case void 0:
|
|
200
|
+
return this.setBitrateByTrackResolution(t);
|
|
201
|
+
default:
|
|
202
|
+
return this.setBitrateByTrackResolution(t);
|
|
137
203
|
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}) => Ke(async () => ce(n, { scaleResolutionDownBy: e, maxBitrate: t }, s)), Ye = async ({ sender: n, codec: e }, t) => {
|
|
172
|
-
const o = We(e);
|
|
173
|
-
return W({
|
|
174
|
-
sender: n,
|
|
175
|
-
maxBitrate: o,
|
|
176
|
-
onSetParameters: t,
|
|
177
|
-
scaleResolutionDownBy: 200
|
|
178
|
-
});
|
|
179
|
-
}, U = async ({
|
|
180
|
-
sender: n,
|
|
181
|
-
videoTrack: e,
|
|
182
|
-
codec: t
|
|
183
|
-
}, s) => {
|
|
184
|
-
const i = e.getSettings().width, u = ne(i, t);
|
|
185
|
-
return W({
|
|
186
|
-
sender: n,
|
|
187
|
-
maxBitrate: u,
|
|
188
|
-
onSetParameters: s,
|
|
189
|
-
scaleResolutionDownBy: 1
|
|
190
|
-
});
|
|
191
|
-
}, qe = async ({
|
|
192
|
-
sender: n,
|
|
193
|
-
videoTrack: e,
|
|
194
|
-
resolution: t,
|
|
195
|
-
codec: s
|
|
196
|
-
}, o) => {
|
|
197
|
-
const [r, i] = t.split("x"), { maxBitrate: u, scaleResolutionDownBy: d } = te({
|
|
198
|
-
videoTrack: e,
|
|
199
|
-
codec: s,
|
|
200
|
-
targetSize: {
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Понижает разрешение отправителя (пауза камеры)
|
|
207
|
+
* @param context - Контекст балансировки
|
|
208
|
+
* @returns Promise с результатом
|
|
209
|
+
*/
|
|
210
|
+
async downgradeResolutionSender(e) {
|
|
211
|
+
const { sender: t, codec: r } = e, s = {
|
|
212
|
+
scaleResolutionDownBy: 200,
|
|
213
|
+
maxBitrate: Ne(r)
|
|
214
|
+
};
|
|
215
|
+
return this.parametersSetter.setEncodingsToSender(t, s);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Устанавливает битрейт на основе разрешения трека
|
|
219
|
+
* @param context - Контекст балансировки
|
|
220
|
+
* @returns Promise с результатом
|
|
221
|
+
*/
|
|
222
|
+
async setBitrateByTrackResolution(e) {
|
|
223
|
+
const { sender: t, videoTrack: r, codec: s } = e, c = r.getSettings().width, a = c === void 0 ? Oe(s) : Q(c, s);
|
|
224
|
+
return this.parametersSetter.setEncodingsToSender(t, {
|
|
225
|
+
scaleResolutionDownBy: 1,
|
|
226
|
+
maxBitrate: a
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Устанавливает разрешение отправителя на основе заголовка
|
|
231
|
+
* @param resolutionMainCam - Разрешение главной камеры
|
|
232
|
+
* @param context - Контекст балансировки
|
|
233
|
+
* @returns Promise с результатом
|
|
234
|
+
*/
|
|
235
|
+
async setResolutionSender(e, t) {
|
|
236
|
+
const [r, s] = e.split("x"), { sender: o, videoTrack: c, codec: a } = t, d = {
|
|
201
237
|
width: Number(r),
|
|
202
|
-
height: Number(
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}, ze = async ({
|
|
212
|
-
mainCam: n,
|
|
213
|
-
resolutionMainCam: e,
|
|
214
|
-
sender: t,
|
|
215
|
-
videoTrack: s,
|
|
216
|
-
codec: o
|
|
217
|
-
}, r) => {
|
|
218
|
-
switch (n) {
|
|
219
|
-
case B.PAUSE_MAIN_CAM:
|
|
220
|
-
return Ye({ sender: t, codec: o }, r);
|
|
221
|
-
case B.RESUME_MAIN_CAM:
|
|
222
|
-
return U({ sender: t, videoTrack: s, codec: o }, r);
|
|
223
|
-
case B.MAX_MAIN_CAM_RESOLUTION:
|
|
224
|
-
return e !== void 0 ? qe(
|
|
225
|
-
{ sender: t, videoTrack: s, codec: o, resolution: e },
|
|
226
|
-
r
|
|
227
|
-
) : U({ sender: t, videoTrack: s, codec: o }, r);
|
|
228
|
-
case B.ADMIN_STOP_MAIN_CAM:
|
|
229
|
-
case B.ADMIN_START_MAIN_CAM:
|
|
230
|
-
case void 0:
|
|
231
|
-
return U({ sender: t, videoTrack: s, codec: o }, r);
|
|
232
|
-
default:
|
|
233
|
-
return U({ sender: t, videoTrack: s, codec: o }, r);
|
|
238
|
+
height: Number(s)
|
|
239
|
+
}, l = te({
|
|
240
|
+
videoTrack: c,
|
|
241
|
+
targetSize: d
|
|
242
|
+
}), f = Q(d.width, a), h = {
|
|
243
|
+
scaleResolutionDownBy: l,
|
|
244
|
+
maxBitrate: f
|
|
245
|
+
};
|
|
246
|
+
return this.parametersSetter.setEncodingsToSender(o, h);
|
|
234
247
|
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
headerExtensions: [],
|
|
242
|
-
rtcp: {}
|
|
248
|
+
}
|
|
249
|
+
const Ue = (n) => n.find((e) => e.track?.kind === "video");
|
|
250
|
+
class Ve {
|
|
251
|
+
// eslint-disable-next-line class-methods-use-this
|
|
252
|
+
findVideoSender(e) {
|
|
253
|
+
return Ue(e);
|
|
243
254
|
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
255
|
+
}
|
|
256
|
+
class Le {
|
|
257
|
+
sipConnector;
|
|
258
|
+
currentHandler;
|
|
259
|
+
constructor(e) {
|
|
260
|
+
this.sipConnector = e;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Подписывается на события управления главной камерой
|
|
264
|
+
* @param handler - Обработчик события
|
|
265
|
+
*/
|
|
266
|
+
subscribe(e) {
|
|
267
|
+
this.currentHandler = e, this.sipConnector.on("api:main-cam-control", e);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Отписывается от событий управления главной камерой
|
|
271
|
+
*/
|
|
272
|
+
unsubscribe() {
|
|
273
|
+
this.currentHandler && (this.sipConnector.off("api:main-cam-control", this.currentHandler), this.currentHandler = void 0);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Получает соединение из SipConnector
|
|
277
|
+
* @returns RTCPeerConnection или undefined
|
|
278
|
+
*/
|
|
279
|
+
getConnection() {
|
|
280
|
+
return this.sipConnector.connection;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
class He {
|
|
284
|
+
eventHandler;
|
|
285
|
+
senderBalancer;
|
|
286
|
+
parametersSetterWithQueue;
|
|
287
|
+
serverHeaders;
|
|
288
|
+
constructor(e, { ignoreForCodec: t, onSetParameters: r } = {}) {
|
|
289
|
+
this.eventHandler = new Le(e), this.parametersSetterWithQueue = new Fe(r), this.senderBalancer = new xe(
|
|
290
|
+
{
|
|
291
|
+
senderFinder: new Ve(),
|
|
292
|
+
codecProvider: new ke(),
|
|
293
|
+
parametersSetter: this.parametersSetterWithQueue
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
ignoreForCodec: t
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Подписывается на события управления главной камерой
|
|
302
|
+
*/
|
|
303
|
+
subscribe() {
|
|
304
|
+
this.eventHandler.subscribe(this.handleMainCamControl);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Отписывается от событий и сбрасывает состояние
|
|
308
|
+
*/
|
|
309
|
+
unsubscribe() {
|
|
310
|
+
this.eventHandler.unsubscribe(), this.parametersSetterWithQueue.stop(), this.reset();
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Сбрасывает состояние балансировщика
|
|
314
|
+
*/
|
|
315
|
+
reset() {
|
|
316
|
+
delete this.serverHeaders;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Перебалансирует текущее состояние
|
|
320
|
+
* @returns Promise с результатом балансировки
|
|
321
|
+
*/
|
|
322
|
+
async reBalance() {
|
|
323
|
+
return this.balanceByTrack();
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Выполняет балансировку на основе текущего состояния
|
|
327
|
+
* @returns Promise с результатом балансировки
|
|
328
|
+
*/
|
|
329
|
+
async balanceByTrack() {
|
|
330
|
+
const e = this.eventHandler.getConnection();
|
|
331
|
+
if (!e)
|
|
272
332
|
throw new Error("connection is not exist");
|
|
273
|
-
return
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
o = async () => {
|
|
282
|
-
const { mainCam: C, resolutionMainCam: f } = d, { connection: S } = n;
|
|
283
|
-
if (!S)
|
|
284
|
-
throw new Error("connection is not exist");
|
|
285
|
-
return K({
|
|
286
|
-
mainCam: C,
|
|
287
|
-
resolutionMainCam: f,
|
|
288
|
-
connection: S,
|
|
289
|
-
onSetParameters: t,
|
|
290
|
-
ignoreForCodec: e
|
|
291
|
-
});
|
|
292
|
-
}, o().catch(D);
|
|
293
|
-
};
|
|
294
|
-
return {
|
|
295
|
-
subscribe: () => {
|
|
296
|
-
n.onSession("main-cam-control", r);
|
|
297
|
-
},
|
|
298
|
-
unsubscribe: () => {
|
|
299
|
-
n.offSession("main-cam-control", r);
|
|
300
|
-
},
|
|
301
|
-
balanceByTrack: s,
|
|
302
|
-
resetMainCamControl() {
|
|
303
|
-
o = s;
|
|
304
|
-
},
|
|
305
|
-
async reBalance() {
|
|
306
|
-
return o();
|
|
307
|
-
}
|
|
333
|
+
return this.senderBalancer.balance(e, this.serverHeaders);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Обработчик событий управления главной камерой
|
|
337
|
+
* @param headers - Заголовки от сервера
|
|
338
|
+
*/
|
|
339
|
+
handleMainCamControl = (e) => {
|
|
340
|
+
this.serverHeaders = e, this.balanceByTrack().catch(k);
|
|
308
341
|
};
|
|
309
|
-
}
|
|
342
|
+
}
|
|
343
|
+
const Bn = (n, e = {}) => new He(n, e), $e = ({
|
|
344
|
+
videoTrack: n,
|
|
345
|
+
targetSize: e,
|
|
346
|
+
codec: t
|
|
347
|
+
}) => {
|
|
348
|
+
const r = te({
|
|
349
|
+
videoTrack: n,
|
|
350
|
+
targetSize: e
|
|
351
|
+
}), s = Q(e.width, t);
|
|
352
|
+
return { scaleResolutionDownBy: r, maxBitrate: s };
|
|
353
|
+
}, P = ({
|
|
310
354
|
mediaStream: n,
|
|
311
355
|
simulcastEncodings: e,
|
|
312
356
|
sendEncodings: t
|
|
313
357
|
}) => {
|
|
314
358
|
if (e && e.length > 0) {
|
|
315
|
-
const
|
|
316
|
-
if (
|
|
359
|
+
const r = t ?? [], s = Ee(n);
|
|
360
|
+
if (s === void 0)
|
|
317
361
|
throw new Error("No video track");
|
|
318
|
-
return e.forEach((
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
const { maxBitrate: d, scaleResolutionDownBy:
|
|
322
|
-
videoTrack:
|
|
362
|
+
return e.forEach((o, c) => {
|
|
363
|
+
const a = r[c] ?? {};
|
|
364
|
+
a.active = !0, o.rid !== void 0 && (a.rid = o.rid), o.scalabilityMode !== void 0 && (a.scalabilityMode = o.scalabilityMode);
|
|
365
|
+
const { maxBitrate: d, scaleResolutionDownBy: l } = $e({
|
|
366
|
+
videoTrack: s,
|
|
323
367
|
targetSize: {
|
|
324
|
-
width:
|
|
325
|
-
height:
|
|
368
|
+
width: o.width,
|
|
369
|
+
height: o.height
|
|
326
370
|
}
|
|
327
371
|
});
|
|
328
|
-
|
|
329
|
-
}),
|
|
372
|
+
a.maxBitrate = d, a.scaleResolutionDownBy = l, r[c] = a;
|
|
373
|
+
}), r;
|
|
330
374
|
}
|
|
331
375
|
return t;
|
|
332
|
-
},
|
|
333
|
-
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n),
|
|
334
|
-
return
|
|
335
|
-
},
|
|
336
|
-
const
|
|
337
|
-
return
|
|
338
|
-
}),
|
|
376
|
+
}, re = "purgatory", x = (n) => n === re, We = (n, e) => n.filter((r) => e.some((s) => s.clockRate === r.clockRate && s.mimeType === r.mimeType && s.channels === r.channels && s.sdpFmtpLine === r.sdpFmtpLine)), Qe = (n) => {
|
|
377
|
+
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), r = e === null ? [] : e.codecs, s = t === null ? [] : t.codecs;
|
|
378
|
+
return We(r, s);
|
|
379
|
+
}, Je = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, r) => {
|
|
380
|
+
const s = e.indexOf(t.mimeType), o = e.indexOf(r.mimeType), c = s === -1 ? Number.MAX_VALUE : s, a = o === -1 ? Number.MAX_VALUE : o;
|
|
381
|
+
return c - a;
|
|
382
|
+
}), Xe = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), je = (n, {
|
|
383
|
+
preferredMimeTypesVideoCodecs: e,
|
|
384
|
+
excludeMimeTypesVideoCodecs: t
|
|
385
|
+
}) => {
|
|
386
|
+
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
387
|
+
const r = Qe("video"), s = Xe(r, t), o = Je(s, e);
|
|
388
|
+
n.setCodecPreferences(o);
|
|
389
|
+
}
|
|
390
|
+
}, D = (n, {
|
|
339
391
|
preferredMimeTypesVideoCodecs: e,
|
|
340
392
|
excludeMimeTypesVideoCodecs: t
|
|
341
|
-
}) => async (
|
|
342
|
-
var o;
|
|
393
|
+
}) => async (r) => {
|
|
343
394
|
try {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
c("updateTransceiver error", r);
|
|
395
|
+
je(r, {
|
|
396
|
+
preferredMimeTypesVideoCodecs: e,
|
|
397
|
+
excludeMimeTypesVideoCodecs: t
|
|
398
|
+
}), Object.values(n).filter((o) => o != null).length > 0 && (i("updateTransceiver setParametersToSender", n), await z(r.sender, n));
|
|
399
|
+
} catch (s) {
|
|
400
|
+
i("updateTransceiver error", s);
|
|
351
401
|
}
|
|
352
|
-
},
|
|
353
|
-
if (!
|
|
402
|
+
}, W = (n) => {
|
|
403
|
+
if (!K(n) && !ce(n))
|
|
354
404
|
throw n;
|
|
355
405
|
return { isSuccessful: !1 };
|
|
356
|
-
},
|
|
406
|
+
}, Ge = ({ kind: n, readyState: e }) => n === "video" && e === "live", X = (n, e, { onEnterPurgatory: t, onEnterConference: r }) => {
|
|
407
|
+
x(n) ? t && t() : r && r({ isSuccessProgressCall: e });
|
|
408
|
+
}, j = (n, e) => {
|
|
409
|
+
n(), e && e();
|
|
410
|
+
}, G = (n, e, t) => {
|
|
411
|
+
throw n && n(), e(), t;
|
|
412
|
+
}, Ke = /* @__PURE__ */ new Set([
|
|
357
413
|
"on",
|
|
358
414
|
"once",
|
|
359
415
|
"onceRace",
|
|
360
416
|
"wait",
|
|
361
417
|
"off",
|
|
362
|
-
"onSession",
|
|
363
|
-
"onceSession",
|
|
364
|
-
"onceRaceSession",
|
|
365
|
-
"waitSession",
|
|
366
|
-
"offSession",
|
|
367
418
|
"sendDTMF",
|
|
368
419
|
"hangUp",
|
|
369
420
|
"declineToIncomingCall",
|
|
@@ -375,391 +426,507 @@ const he = new Error("Unknown error"), pe = (n = he) => {
|
|
|
375
426
|
"isConfigured",
|
|
376
427
|
"isRegistered"
|
|
377
428
|
]);
|
|
378
|
-
class
|
|
429
|
+
class _n {
|
|
430
|
+
// @ts-expect-error: proxy method
|
|
431
|
+
on;
|
|
432
|
+
// @ts-expect-error: proxy method
|
|
433
|
+
once;
|
|
434
|
+
// @ts-expect-error: proxy method
|
|
435
|
+
onceRace;
|
|
436
|
+
// @ts-expect-error: proxy method
|
|
437
|
+
wait;
|
|
438
|
+
// @ts-expect-error: proxy method
|
|
439
|
+
off;
|
|
440
|
+
// @ts-expect-error: proxy method
|
|
441
|
+
sendDTMF;
|
|
442
|
+
// @ts-expect-error: proxy method
|
|
443
|
+
hangUp;
|
|
444
|
+
// @ts-expect-error: proxy method
|
|
445
|
+
declineToIncomingCall;
|
|
446
|
+
// @ts-expect-error: proxy method
|
|
447
|
+
sendChannels;
|
|
448
|
+
// @ts-expect-error: proxy method
|
|
449
|
+
checkTelephony;
|
|
450
|
+
// @ts-expect-error: proxy method
|
|
451
|
+
waitChannels;
|
|
452
|
+
// @ts-expect-error: proxy method
|
|
453
|
+
ping;
|
|
454
|
+
// proxy method
|
|
455
|
+
connection;
|
|
456
|
+
// @ts-expect-error: proxy method
|
|
457
|
+
isConfigured;
|
|
458
|
+
// @ts-expect-error: proxy method
|
|
459
|
+
isRegistered;
|
|
460
|
+
sipConnector;
|
|
461
|
+
preferredMimeTypesVideoCodecs;
|
|
462
|
+
excludeMimeTypesVideoCodecs;
|
|
379
463
|
constructor(e, {
|
|
380
464
|
preferredMimeTypesVideoCodecs: t,
|
|
381
|
-
excludeMimeTypesVideoCodecs:
|
|
465
|
+
excludeMimeTypesVideoCodecs: r
|
|
382
466
|
} = {}) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
a(this, "onceRace");
|
|
389
|
-
// @ts-expect-error: proxy method
|
|
390
|
-
a(this, "wait");
|
|
391
|
-
// @ts-expect-error: proxy method
|
|
392
|
-
a(this, "off");
|
|
393
|
-
// @ts-expect-error: proxy method
|
|
394
|
-
a(this, "onSession");
|
|
395
|
-
// @ts-expect-error: proxy method
|
|
396
|
-
a(this, "onceSession");
|
|
397
|
-
// @ts-expect-error: proxy method
|
|
398
|
-
a(this, "onceRaceSession");
|
|
399
|
-
// @ts-expect-error: proxy method
|
|
400
|
-
a(this, "waitSession");
|
|
401
|
-
// @ts-expect-error: proxy method
|
|
402
|
-
a(this, "offSession");
|
|
403
|
-
// @ts-expect-error: proxy method
|
|
404
|
-
a(this, "sendDTMF");
|
|
405
|
-
// @ts-expect-error: proxy method
|
|
406
|
-
a(this, "hangUp");
|
|
407
|
-
// @ts-expect-error: proxy method
|
|
408
|
-
a(this, "declineToIncomingCall");
|
|
409
|
-
// @ts-expect-error: proxy method
|
|
410
|
-
a(this, "sendChannels");
|
|
411
|
-
// @ts-expect-error: proxy method
|
|
412
|
-
a(this, "checkTelephony");
|
|
413
|
-
// @ts-expect-error: proxy method
|
|
414
|
-
a(this, "waitChannels");
|
|
415
|
-
// @ts-expect-error: proxy method
|
|
416
|
-
a(this, "ping");
|
|
417
|
-
// proxy method
|
|
418
|
-
a(this, "connection");
|
|
419
|
-
// @ts-expect-error: proxy method
|
|
420
|
-
a(this, "isConfigured");
|
|
421
|
-
// @ts-expect-error: proxy method
|
|
422
|
-
a(this, "isRegistered");
|
|
423
|
-
a(this, "sipConnector");
|
|
424
|
-
a(this, "preferredMimeTypesVideoCodecs");
|
|
425
|
-
a(this, "excludeMimeTypesVideoCodecs");
|
|
426
|
-
a(this, "connectToServer", async (e) => {
|
|
427
|
-
const {
|
|
428
|
-
userAgent: t,
|
|
429
|
-
sipWebSocketServerURL: s,
|
|
430
|
-
sipServerUrl: o,
|
|
431
|
-
remoteAddress: r,
|
|
432
|
-
displayName: i,
|
|
433
|
-
name: u,
|
|
434
|
-
password: d,
|
|
435
|
-
isRegisteredUser: C,
|
|
436
|
-
isDisconnectOnFail: f
|
|
437
|
-
} = e;
|
|
438
|
-
return c("connectToServer", e), this.sipConnector.connect({
|
|
439
|
-
userAgent: t,
|
|
440
|
-
sipWebSocketServerURL: s,
|
|
441
|
-
sipServerUrl: o,
|
|
442
|
-
remoteAddress: r,
|
|
443
|
-
displayName: i,
|
|
444
|
-
password: d,
|
|
445
|
-
user: u,
|
|
446
|
-
register: C
|
|
447
|
-
}).then((S) => (c("connectToServer then"), { ua: S, isSuccessful: !0 })).catch(async (S) => (c("connectToServer catch: error", S), f === !0 ? this.sipConnector.disconnect().then(() => j(S)).catch(() => j(S)) : j(S)));
|
|
448
|
-
});
|
|
449
|
-
a(this, "callToServer", async (e) => {
|
|
450
|
-
const {
|
|
451
|
-
conference: t,
|
|
452
|
-
mediaStream: s,
|
|
453
|
-
extraHeaders: o,
|
|
454
|
-
iceServers: r,
|
|
455
|
-
contentHint: i,
|
|
456
|
-
simulcastEncodings: u,
|
|
457
|
-
degradationPreference: d,
|
|
458
|
-
sendEncodings: C,
|
|
459
|
-
offerToReceiveAudio: f,
|
|
460
|
-
offerToReceiveVideo: S,
|
|
461
|
-
directionVideo: F,
|
|
462
|
-
directionAudio: V,
|
|
463
|
-
setRemoteStreams: m,
|
|
464
|
-
onBeforeProgressCall: g,
|
|
465
|
-
onSuccessProgressCall: h,
|
|
466
|
-
onEnterPurgatory: p,
|
|
467
|
-
onEnterConference: y,
|
|
468
|
-
onFailProgressCall: T,
|
|
469
|
-
onFinishProgressCall: E,
|
|
470
|
-
onEndedCall: M
|
|
471
|
-
} = e, A = this.resolveHandleReadyRemoteStreamsDebounced({
|
|
472
|
-
onReadyRemoteStreams: m
|
|
473
|
-
}), v = this.resolveHandleReadyRemoteStreams({
|
|
474
|
-
onReadyRemoteStreams: () => {
|
|
475
|
-
A().catch(D);
|
|
476
|
-
}
|
|
477
|
-
}), O = I(
|
|
478
|
-
{
|
|
479
|
-
degradationPreference: d
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
483
|
-
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
484
|
-
}
|
|
485
|
-
);
|
|
486
|
-
c("callToServer", e);
|
|
487
|
-
const N = async () => (c("startCall"), this.sipConnector.call({
|
|
488
|
-
mediaStream: s,
|
|
489
|
-
extraHeaders: o,
|
|
490
|
-
iceServers: r,
|
|
491
|
-
contentHint: i,
|
|
492
|
-
offerToReceiveAudio: f,
|
|
493
|
-
offerToReceiveVideo: S,
|
|
494
|
-
directionVideo: F,
|
|
495
|
-
directionAudio: V,
|
|
496
|
-
sendEncodings: P({
|
|
497
|
-
mediaStream: s,
|
|
498
|
-
simulcastEncodings: u,
|
|
499
|
-
sendEncodings: C
|
|
500
|
-
}),
|
|
501
|
-
number: t,
|
|
502
|
-
onAddedTransceiver: O,
|
|
503
|
-
ontrack: v
|
|
504
|
-
}));
|
|
505
|
-
let b = !1, _;
|
|
506
|
-
const w = (c("subscribeEnterConference: onEnterConference", y), p ?? y ? this.sipConnector.onSession("enterRoom", ({ room: l }) => {
|
|
507
|
-
c("enterRoom", { _room: l, isSuccessProgressCall: b }), _ = l, k(_) ? p && p() : y && y({ isSuccessProgressCall: b });
|
|
508
|
-
}) : () => {
|
|
509
|
-
}), L = (l) => (c("onSuccess"), b = !0, A().catch(D), h && h({ isPurgatory: k(_) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
|
|
510
|
-
w(), M && M();
|
|
511
|
-
}), l), $ = (l) => {
|
|
512
|
-
throw c("onFail"), T && T(), w(), l;
|
|
513
|
-
}, H = () => {
|
|
514
|
-
c("onFinish"), E && E();
|
|
515
|
-
};
|
|
516
|
-
return c("onBeforeProgressCall"), g && g(t), N().then(L).catch((l) => $(l)).finally(H);
|
|
517
|
-
});
|
|
518
|
-
a(this, "disconnectFromServer", async () => this.sipConnector.disconnect().then(() => (c("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (c("disconnectFromServer: catch", e), { isSuccessful: !1 })));
|
|
519
|
-
a(this, "answerIncomingCall", async (e) => {
|
|
520
|
-
const {
|
|
521
|
-
mediaStream: t,
|
|
522
|
-
extraHeaders: s,
|
|
523
|
-
iceServers: o,
|
|
524
|
-
contentHint: r,
|
|
525
|
-
simulcastEncodings: i,
|
|
526
|
-
degradationPreference: u,
|
|
527
|
-
sendEncodings: d,
|
|
528
|
-
offerToReceiveAudio: C,
|
|
529
|
-
offerToReceiveVideo: f,
|
|
530
|
-
directionVideo: S,
|
|
531
|
-
directionAudio: F,
|
|
532
|
-
setRemoteStreams: V,
|
|
533
|
-
onBeforeProgressCall: m,
|
|
534
|
-
onSuccessProgressCall: g,
|
|
535
|
-
onEnterPurgatory: h,
|
|
536
|
-
onEnterConference: p,
|
|
537
|
-
onFailProgressCall: y,
|
|
538
|
-
onFinishProgressCall: T,
|
|
539
|
-
onEndedCall: E
|
|
540
|
-
} = e, M = this.resolveHandleReadyRemoteStreamsDebounced({
|
|
541
|
-
onReadyRemoteStreams: V
|
|
542
|
-
}), A = this.resolveHandleReadyRemoteStreams({
|
|
543
|
-
onReadyRemoteStreams: () => {
|
|
544
|
-
M().catch(D);
|
|
545
|
-
}
|
|
546
|
-
}), v = I(
|
|
547
|
-
{
|
|
548
|
-
degradationPreference: u
|
|
549
|
-
},
|
|
550
|
-
{
|
|
551
|
-
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
552
|
-
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
467
|
+
return this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = r, this.sipConnector = e, new Proxy(this, {
|
|
468
|
+
get: (s, o, c) => {
|
|
469
|
+
if (typeof o == "string" && Ke.has(o) && o in this.sipConnector) {
|
|
470
|
+
const d = Reflect.get(this.sipConnector, o, this.sipConnector);
|
|
471
|
+
return typeof d == "function" ? d.bind(this.sipConnector) : d;
|
|
553
472
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
const O = async () => this.sipConnector.answerToIncomingCall({
|
|
557
|
-
mediaStream: t,
|
|
558
|
-
extraHeaders: s,
|
|
559
|
-
iceServers: o,
|
|
560
|
-
contentHint: r,
|
|
561
|
-
offerToReceiveAudio: C,
|
|
562
|
-
offerToReceiveVideo: f,
|
|
563
|
-
directionVideo: S,
|
|
564
|
-
directionAudio: F,
|
|
565
|
-
sendEncodings: P({
|
|
566
|
-
mediaStream: t,
|
|
567
|
-
simulcastEncodings: i,
|
|
568
|
-
sendEncodings: d
|
|
569
|
-
}),
|
|
570
|
-
onAddedTransceiver: v,
|
|
571
|
-
ontrack: A
|
|
572
|
-
}), N = () => {
|
|
573
|
-
const { remoteCallerData: l } = this.sipConnector;
|
|
574
|
-
return l.incomingNumber;
|
|
575
|
-
};
|
|
576
|
-
let b = !1, _;
|
|
577
|
-
const w = (c("subscribeEnterConference: onEnterConference", p), h ?? p ? this.sipConnector.onSession("enterRoom", (l) => {
|
|
578
|
-
c("enterRoom", { _room: l, isSuccessProgressCall: b }), _ = l, k(_) ? h && h() : p && p({ isSuccessProgressCall: b });
|
|
579
|
-
}) : () => {
|
|
580
|
-
}), L = (l) => (c("onSuccess"), b = !0, M().catch(D), g && g({ isPurgatory: k(_) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
|
|
581
|
-
w(), E && E();
|
|
582
|
-
}), l), $ = (l) => {
|
|
583
|
-
throw c("onFail"), y && y(), w(), l;
|
|
584
|
-
}, H = () => {
|
|
585
|
-
c("onFinish"), T && T();
|
|
586
|
-
};
|
|
587
|
-
if (c("onBeforeProgressCall"), m) {
|
|
588
|
-
const l = N();
|
|
589
|
-
m(l);
|
|
473
|
+
const a = Reflect.get(s, o, c);
|
|
474
|
+
return typeof a == "function" ? a.bind(s) : a;
|
|
590
475
|
}
|
|
591
|
-
return O().then(L).catch((l) => $(l)).finally(H);
|
|
592
476
|
});
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
477
|
+
}
|
|
478
|
+
connectToServer = async (e) => {
|
|
479
|
+
const {
|
|
480
|
+
userAgent: t,
|
|
481
|
+
sipWebSocketServerURL: r,
|
|
482
|
+
sipServerUrl: s,
|
|
483
|
+
remoteAddress: o,
|
|
484
|
+
displayName: c,
|
|
485
|
+
name: a,
|
|
486
|
+
password: d,
|
|
487
|
+
isRegisteredUser: l,
|
|
488
|
+
isDisconnectOnFail: f
|
|
489
|
+
} = e;
|
|
490
|
+
return i("connectToServer", e), this.sipConnector.connect({
|
|
491
|
+
userAgent: t,
|
|
492
|
+
sipWebSocketServerURL: r,
|
|
493
|
+
sipServerUrl: s,
|
|
494
|
+
remoteAddress: o,
|
|
495
|
+
displayName: c,
|
|
496
|
+
password: d,
|
|
497
|
+
user: a,
|
|
498
|
+
register: l
|
|
499
|
+
}).then((h) => (i("connectToServer then"), { ua: h, isSuccessful: !0 })).catch(async (h) => (i("connectToServer catch: error", h), f === !0 ? this.sipConnector.disconnect().then(() => W(h)).catch(() => W(h)) : W(h)));
|
|
500
|
+
};
|
|
501
|
+
callToServer = async (e) => {
|
|
502
|
+
const {
|
|
503
|
+
conference: t,
|
|
504
|
+
mediaStream: r,
|
|
505
|
+
extraHeaders: s,
|
|
506
|
+
iceServers: o,
|
|
507
|
+
contentHint: c,
|
|
508
|
+
simulcastEncodings: a,
|
|
509
|
+
degradationPreference: d,
|
|
510
|
+
sendEncodings: l,
|
|
511
|
+
offerToReceiveAudio: f,
|
|
512
|
+
offerToReceiveVideo: h,
|
|
513
|
+
directionVideo: I,
|
|
514
|
+
directionAudio: F,
|
|
515
|
+
setRemoteStreams: S,
|
|
516
|
+
onBeforeProgressCall: g,
|
|
517
|
+
onSuccessProgressCall: m,
|
|
518
|
+
onEnterPurgatory: p,
|
|
519
|
+
onEnterConference: y,
|
|
520
|
+
onFailProgressCall: E,
|
|
521
|
+
onFinishProgressCall: M,
|
|
522
|
+
onEndedCall: b
|
|
523
|
+
} = e, B = this.resolveHandleReadyRemoteStreamsDebounced({
|
|
524
|
+
onReadyRemoteStreams: S
|
|
525
|
+
}), _ = this.resolveHandleReadyRemoteStreams({
|
|
526
|
+
onReadyRemoteStreams: () => {
|
|
527
|
+
B().catch(k);
|
|
528
|
+
}
|
|
529
|
+
}), A = D(
|
|
530
|
+
{
|
|
531
|
+
degradationPreference: d
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
535
|
+
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
536
|
+
}
|
|
537
|
+
);
|
|
538
|
+
i("callToServer", e);
|
|
539
|
+
const N = async () => (i("startCall"), this.sipConnector.call({
|
|
540
|
+
mediaStream: r,
|
|
541
|
+
extraHeaders: s,
|
|
542
|
+
iceServers: o,
|
|
543
|
+
contentHint: c,
|
|
544
|
+
offerToReceiveAudio: f,
|
|
545
|
+
offerToReceiveVideo: h,
|
|
546
|
+
directionVideo: I,
|
|
547
|
+
directionAudio: F,
|
|
548
|
+
sendEncodings: P({
|
|
549
|
+
mediaStream: r,
|
|
550
|
+
simulcastEncodings: a,
|
|
551
|
+
sendEncodings: l
|
|
552
|
+
}),
|
|
553
|
+
number: t,
|
|
554
|
+
onAddedTransceiver: A,
|
|
555
|
+
ontrack: _
|
|
556
|
+
}));
|
|
557
|
+
let v = !1, T;
|
|
558
|
+
const O = (i("subscribeEnterConference: onEnterConference", y), this.sipConnector.on("api:enterRoom", ({ room: u }) => {
|
|
559
|
+
i("enterRoom", { _room: u, isSuccessProgressCall: v }), T = u, (p ?? y) && X(T, v, {
|
|
560
|
+
onEnterPurgatory: p,
|
|
561
|
+
onEnterConference: y
|
|
562
|
+
});
|
|
563
|
+
})), V = (u) => (i("onSuccess"), v = !0, B().catch(k), m && m({ isPurgatory: x(T) }), this.sipConnector.onceRace(["call:ended", "call:failed"], () => {
|
|
564
|
+
j(O, b);
|
|
565
|
+
}), u), L = (u) => (i("onFail"), G(E, O, u)), H = () => {
|
|
566
|
+
i("onFinish"), M && M();
|
|
567
|
+
};
|
|
568
|
+
return i("onBeforeProgressCall"), g && g(t), N().then(V).catch((u) => L(u)).finally(H);
|
|
569
|
+
};
|
|
570
|
+
disconnectFromServer = async () => this.sipConnector.disconnect().then(() => (i("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (i("disconnectFromServer: catch", e), { isSuccessful: !1 }));
|
|
571
|
+
answerToIncomingCall = async (e) => {
|
|
572
|
+
const {
|
|
573
|
+
mediaStream: t,
|
|
574
|
+
extraHeaders: r,
|
|
575
|
+
iceServers: s,
|
|
597
576
|
contentHint: o,
|
|
598
|
-
simulcastEncodings:
|
|
599
|
-
degradationPreference:
|
|
600
|
-
sendEncodings:
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
577
|
+
simulcastEncodings: c,
|
|
578
|
+
degradationPreference: a,
|
|
579
|
+
sendEncodings: d,
|
|
580
|
+
offerToReceiveAudio: l,
|
|
581
|
+
offerToReceiveVideo: f,
|
|
582
|
+
directionVideo: h,
|
|
583
|
+
directionAudio: I,
|
|
584
|
+
setRemoteStreams: F,
|
|
585
|
+
onBeforeProgressCall: S,
|
|
586
|
+
onSuccessProgressCall: g,
|
|
587
|
+
onEnterPurgatory: m,
|
|
588
|
+
onEnterConference: p,
|
|
589
|
+
onFailProgressCall: y,
|
|
590
|
+
onFinishProgressCall: E,
|
|
591
|
+
onEndedCall: M
|
|
592
|
+
} = e, b = this.resolveHandleReadyRemoteStreamsDebounced({
|
|
593
|
+
onReadyRemoteStreams: F
|
|
594
|
+
}), B = this.resolveHandleReadyRemoteStreams({
|
|
595
|
+
onReadyRemoteStreams: () => {
|
|
596
|
+
b().catch(k);
|
|
597
|
+
}
|
|
598
|
+
}), _ = D(
|
|
599
|
+
{
|
|
600
|
+
degradationPreference: a
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
604
|
+
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
605
|
+
}
|
|
606
|
+
);
|
|
607
|
+
i("answerToIncomingCall", e);
|
|
608
|
+
const A = async () => this.sipConnector.answerToIncomingCall({
|
|
609
|
+
mediaStream: t,
|
|
610
|
+
extraHeaders: r,
|
|
611
|
+
iceServers: s,
|
|
612
|
+
contentHint: o,
|
|
613
|
+
offerToReceiveAudio: l,
|
|
614
|
+
offerToReceiveVideo: f,
|
|
615
|
+
directionVideo: h,
|
|
616
|
+
directionAudio: I,
|
|
617
|
+
sendEncodings: P({
|
|
618
|
+
mediaStream: t,
|
|
619
|
+
simulcastEncodings: c,
|
|
620
|
+
sendEncodings: d
|
|
621
|
+
}),
|
|
622
|
+
onAddedTransceiver: _,
|
|
623
|
+
ontrack: B
|
|
624
|
+
}), N = () => {
|
|
625
|
+
const { remoteCallerData: u } = this.sipConnector;
|
|
626
|
+
return u.incomingNumber;
|
|
627
|
+
};
|
|
628
|
+
let v = !1, T;
|
|
629
|
+
const O = (i("subscribeEnterConference: onEnterConference", p), this.sipConnector.on("api:enterRoom", (u) => {
|
|
630
|
+
i("enterRoom", { _room: u, isSuccessProgressCall: v }), T = u, (m ?? p) && X(T, v, {
|
|
631
|
+
onEnterPurgatory: m,
|
|
632
|
+
onEnterConference: p
|
|
623
633
|
});
|
|
624
|
-
})
|
|
625
|
-
|
|
626
|
-
|
|
634
|
+
})), V = (u) => (i("onSuccess"), v = !0, b().catch(k), g && g({ isPurgatory: x(T) }), this.sipConnector.onceRace(["call:ended", "call:failed"], () => {
|
|
635
|
+
j(O, M);
|
|
636
|
+
}), u), L = (u) => (i("onFail"), G(y, O, u)), H = () => {
|
|
637
|
+
i("onFinish"), E && E();
|
|
638
|
+
};
|
|
639
|
+
if (i("onBeforeProgressCall"), S) {
|
|
640
|
+
const u = N();
|
|
641
|
+
S(u);
|
|
642
|
+
}
|
|
643
|
+
return A().then(V).catch((u) => L(u)).finally(H);
|
|
644
|
+
};
|
|
645
|
+
updatePresentation = async ({
|
|
646
|
+
mediaStream: e,
|
|
647
|
+
isP2P: t,
|
|
648
|
+
maxBitrate: r,
|
|
649
|
+
contentHint: s,
|
|
650
|
+
simulcastEncodings: o,
|
|
651
|
+
degradationPreference: c,
|
|
652
|
+
sendEncodings: a,
|
|
653
|
+
preferredMimeTypesVideoCodecs: d,
|
|
654
|
+
excludeMimeTypesVideoCodecs: l
|
|
655
|
+
}) => {
|
|
656
|
+
const f = D(
|
|
657
|
+
{
|
|
658
|
+
degradationPreference: c
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
preferredMimeTypesVideoCodecs: d,
|
|
662
|
+
excludeMimeTypesVideoCodecs: l
|
|
663
|
+
}
|
|
664
|
+
);
|
|
665
|
+
return i("updatePresentation"), this.sipConnector.updatePresentation(e, {
|
|
627
666
|
isP2P: t,
|
|
628
|
-
maxBitrate:
|
|
629
|
-
contentHint:
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
const S = I(
|
|
637
|
-
{
|
|
638
|
-
degradationPreference: i
|
|
639
|
-
},
|
|
640
|
-
{
|
|
641
|
-
preferredMimeTypesVideoCodecs: d,
|
|
642
|
-
excludeMimeTypesVideoCodecs: C
|
|
643
|
-
}
|
|
644
|
-
);
|
|
645
|
-
return c("startPresentation"), this.sipConnector.startPresentation(
|
|
646
|
-
e,
|
|
647
|
-
{
|
|
648
|
-
isP2P: t,
|
|
649
|
-
maxBitrate: s,
|
|
650
|
-
contentHint: o,
|
|
651
|
-
sendEncodings: P({
|
|
652
|
-
mediaStream: e,
|
|
653
|
-
simulcastEncodings: r,
|
|
654
|
-
sendEncodings: u
|
|
655
|
-
}),
|
|
656
|
-
onAddedTransceiver: S
|
|
657
|
-
},
|
|
658
|
-
f
|
|
659
|
-
);
|
|
660
|
-
});
|
|
661
|
-
a(this, "stopShareSipConnector", async ({ isP2P: e = !1 } = {}) => (c("stopShareSipConnector"), this.sipConnector.stopPresentation({
|
|
662
|
-
isP2P: e
|
|
663
|
-
}).catch((t) => {
|
|
664
|
-
c(t);
|
|
665
|
-
})));
|
|
666
|
-
a(this, "sendRefusalToTurnOnMic", async () => {
|
|
667
|
-
this.sipConnector.isCallActive && (c("sendRefusalToTurnOnMic"), await this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
|
|
668
|
-
c("sendRefusalToTurnOnMic: error", e);
|
|
669
|
-
}));
|
|
670
|
-
});
|
|
671
|
-
a(this, "sendRefusalToTurnOnCam", async () => {
|
|
672
|
-
this.sipConnector.isCallActive && (c("sendRefusalToTurnOnCam"), await this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
|
|
673
|
-
c("sendRefusalToTurnOnCam: error", e);
|
|
674
|
-
}));
|
|
667
|
+
maxBitrate: r,
|
|
668
|
+
contentHint: s,
|
|
669
|
+
sendEncodings: P({
|
|
670
|
+
mediaStream: e,
|
|
671
|
+
simulcastEncodings: o,
|
|
672
|
+
sendEncodings: a
|
|
673
|
+
}),
|
|
674
|
+
onAddedTransceiver: f
|
|
675
675
|
});
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
}),
|
|
710
|
-
onAddedTransceiver: C
|
|
711
|
-
});
|
|
676
|
+
};
|
|
677
|
+
startPresentation = async ({
|
|
678
|
+
mediaStream: e,
|
|
679
|
+
isP2P: t,
|
|
680
|
+
maxBitrate: r,
|
|
681
|
+
contentHint: s,
|
|
682
|
+
simulcastEncodings: o,
|
|
683
|
+
degradationPreference: c,
|
|
684
|
+
sendEncodings: a,
|
|
685
|
+
preferredMimeTypesVideoCodecs: d,
|
|
686
|
+
excludeMimeTypesVideoCodecs: l,
|
|
687
|
+
callLimit: f
|
|
688
|
+
}) => {
|
|
689
|
+
const h = D(
|
|
690
|
+
{
|
|
691
|
+
degradationPreference: c
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
preferredMimeTypesVideoCodecs: d,
|
|
695
|
+
excludeMimeTypesVideoCodecs: l
|
|
696
|
+
}
|
|
697
|
+
);
|
|
698
|
+
return i("startPresentation"), this.sipConnector.startPresentation(e, {
|
|
699
|
+
isP2P: t,
|
|
700
|
+
maxBitrate: r,
|
|
701
|
+
contentHint: s,
|
|
702
|
+
callLimit: f,
|
|
703
|
+
sendEncodings: P({
|
|
704
|
+
mediaStream: e,
|
|
705
|
+
simulcastEncodings: o,
|
|
706
|
+
sendEncodings: a
|
|
707
|
+
}),
|
|
708
|
+
onAddedTransceiver: h
|
|
712
709
|
});
|
|
713
|
-
|
|
714
|
-
|
|
710
|
+
};
|
|
711
|
+
stopShareSipConnector = async ({ isP2P: e = !1 } = {}) => (i("stopShareSipConnector"), this.sipConnector.stopPresentation({
|
|
712
|
+
isP2P: e
|
|
713
|
+
}).catch((t) => {
|
|
714
|
+
i(t);
|
|
715
|
+
}));
|
|
716
|
+
sendRefusalToTurnOnMic = async () => {
|
|
717
|
+
i("sendRefusalToTurnOnMic"), await this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
|
|
718
|
+
i("sendRefusalToTurnOnMic: error", e);
|
|
715
719
|
});
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
c("remoteStreams", t), t && e(t);
|
|
721
|
-
}, 200));
|
|
722
|
-
// eslint-disable-next-line class-methods-use-this
|
|
723
|
-
a(this, "resolveHandleReadyRemoteStreams", ({
|
|
724
|
-
onReadyRemoteStreams: e
|
|
725
|
-
}) => ({ track: t }) => {
|
|
726
|
-
tn(t) && e();
|
|
720
|
+
};
|
|
721
|
+
sendRefusalToTurnOnCam = async () => {
|
|
722
|
+
i("sendRefusalToTurnOnCam"), await this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
|
|
723
|
+
i("sendRefusalToTurnOnCam: error", e);
|
|
727
724
|
});
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
725
|
+
};
|
|
726
|
+
sendMediaState = async ({
|
|
727
|
+
isEnabledCam: e,
|
|
728
|
+
isEnabledMic: t
|
|
729
|
+
}) => {
|
|
730
|
+
i("sendMediaState"), await this.sipConnector.sendMediaState({ cam: e, mic: t });
|
|
731
|
+
};
|
|
732
|
+
replaceMediaStream = async (e, {
|
|
733
|
+
deleteExisting: t,
|
|
734
|
+
addMissing: r,
|
|
735
|
+
forceRenegotiation: s,
|
|
736
|
+
contentHint: o,
|
|
737
|
+
simulcastEncodings: c,
|
|
738
|
+
degradationPreference: a,
|
|
739
|
+
sendEncodings: d
|
|
740
|
+
}) => {
|
|
741
|
+
const l = D(
|
|
742
|
+
{
|
|
743
|
+
degradationPreference: a
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
747
|
+
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
741
748
|
}
|
|
749
|
+
);
|
|
750
|
+
return i("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
|
|
751
|
+
deleteExisting: t,
|
|
752
|
+
addMissing: r,
|
|
753
|
+
forceRenegotiation: s,
|
|
754
|
+
contentHint: o,
|
|
755
|
+
sendEncodings: P({
|
|
756
|
+
mediaStream: e,
|
|
757
|
+
simulcastEncodings: c,
|
|
758
|
+
sendEncodings: d
|
|
759
|
+
}),
|
|
760
|
+
onAddedTransceiver: l
|
|
742
761
|
});
|
|
743
|
-
}
|
|
762
|
+
};
|
|
763
|
+
askPermissionToEnableCam = async () => {
|
|
764
|
+
i("askPermissionToEnableCam"), await this.sipConnector.askPermissionToEnableCam();
|
|
765
|
+
};
|
|
766
|
+
resolveHandleReadyRemoteStreamsDebounced = ({
|
|
767
|
+
onReadyRemoteStreams: e
|
|
768
|
+
}) => ae(() => {
|
|
769
|
+
const t = this.sipConnector.getRemoteStreams();
|
|
770
|
+
i("remoteStreams", t), t && e(t);
|
|
771
|
+
}, 200);
|
|
772
|
+
// eslint-disable-next-line class-methods-use-this
|
|
773
|
+
resolveHandleReadyRemoteStreams = ({
|
|
774
|
+
onReadyRemoteStreams: e
|
|
775
|
+
}) => ({ track: t }) => {
|
|
776
|
+
Ge(t) && e();
|
|
777
|
+
};
|
|
778
|
+
getRemoteStreams = () => (i("getRemoteStreams"), this.sipConnector.getRemoteStreams());
|
|
779
|
+
onUseLicense = (e) => (i("onUseLicense"), this.sipConnector.on("api:useLicense", e));
|
|
780
|
+
onMustStopPresentation = (e) => (i("onMustStopPresentation"), this.sipConnector.on("api:mustStopPresentation", e));
|
|
781
|
+
onMoveToSpectators = (e) => (i("onMoveToSpectators"), this.sipConnector.on("api:participant:move-request-to-spectators", e));
|
|
782
|
+
onMoveToParticipants = (e) => (i("onMoveToParticipants"), this.sipConnector.on("api:participant:move-request-to-participants", e));
|
|
744
783
|
}
|
|
784
|
+
const U = (n) => {
|
|
785
|
+
const { url: e, cause: t } = n;
|
|
786
|
+
let r = e;
|
|
787
|
+
return (t === R.BAD_MEDIA_DESCRIPTION || t === R.NOT_FOUND) && (r = `${n.message.to.uri.user}@${n.message.to.uri.host}`), r;
|
|
788
|
+
};
|
|
789
|
+
var se = /* @__PURE__ */ ((n) => (n.CONNECT_SERVER_FAILED = "CONNECT_SERVER_FAILED", n.WRONG_USER_OR_PASSWORD = "WRONG_USER_OR_PASSWORD", n.BAD_MEDIA_ERROR = "BAD_MEDIA_ERROR", n.NOT_FOUND_ERROR = "NOT_FOUND_ERROR", n.WS_CONNECTION_FAILED = "WS_CONNECTION_FAILED", n.CONNECT_SERVER_FAILED_BY_LINK = "CONNECT_SERVER_FAILED_BY_LINK", n))(se || {});
|
|
790
|
+
const Ye = new Error("Unknown error"), qe = (n = Ye) => {
|
|
791
|
+
const { cause: e, socket: t } = n;
|
|
792
|
+
let r = "CONNECT_SERVER_FAILED";
|
|
793
|
+
switch (e) {
|
|
794
|
+
case "Forbidden": {
|
|
795
|
+
r = "WRONG_USER_OR_PASSWORD";
|
|
796
|
+
break;
|
|
797
|
+
}
|
|
798
|
+
case R.BAD_MEDIA_DESCRIPTION: {
|
|
799
|
+
r = "BAD_MEDIA_ERROR";
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
case R.NOT_FOUND: {
|
|
803
|
+
r = "NOT_FOUND_ERROR";
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
default:
|
|
807
|
+
t !== void 0 && t._ws?.readyState === 3 ? r = "WS_CONNECTION_FAILED" : U(n) !== void 0 && U(n) !== "" && (r = "CONNECT_SERVER_FAILED_BY_LINK");
|
|
808
|
+
}
|
|
809
|
+
return r;
|
|
810
|
+
}, ze = (n) => {
|
|
811
|
+
let e = "";
|
|
812
|
+
try {
|
|
813
|
+
e = JSON.stringify(n);
|
|
814
|
+
} catch (t) {
|
|
815
|
+
i("failed to stringify message", t);
|
|
816
|
+
}
|
|
817
|
+
return e;
|
|
818
|
+
}, Ze = new Error("Unknown error"), en = (n = Ze) => {
|
|
819
|
+
const { code: e, cause: t, message: r } = n, s = U(n), o = { code: "", cause: "", message: "" };
|
|
820
|
+
return typeof r == "object" && r !== null ? o.message = ze(r) : r && (o.message = String(r)), s !== void 0 && s !== "" && (o.link = s), e !== void 0 && e !== "" && (o.code = e), t !== void 0 && t !== "" && (o.cause = t), o;
|
|
821
|
+
}, nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
822
|
+
__proto__: null,
|
|
823
|
+
EErrorTypes: se,
|
|
824
|
+
getLinkError: U,
|
|
825
|
+
getTypeFromError: qe,
|
|
826
|
+
getValuesFromError: en
|
|
827
|
+
}, Symbol.toStringTag, { value: "Module" })), tn = ({
|
|
828
|
+
sessionId: n,
|
|
829
|
+
remoteAddress: e,
|
|
830
|
+
isMutedAudio: t,
|
|
831
|
+
isMutedVideo: r,
|
|
832
|
+
isRegistered: s,
|
|
833
|
+
isPresentationCall: o
|
|
834
|
+
}) => {
|
|
835
|
+
const c = [], a = t ? "0" : "1", d = r ? "0" : "1";
|
|
836
|
+
return c.push(`X-Vinteo-Mic-State: ${a}`, `X-Vinteo-MainCam-State: ${d}`), (s === !1 || s === void 0) && c.push("X-Vinteo-Purgatory-Call: yes"), n !== void 0 && n !== "" && c.push(`X-Vinteo-Session: ${n}`), o === !0 && c.push("X-Vinteo-Presentation-Call: yes"), e !== void 0 && e !== "" && c.push(`X-Vinteo-Remote: ${e}`), c;
|
|
837
|
+
}, rn = "[@*!|]", sn = "_", on = (n) => {
|
|
838
|
+
let e = n;
|
|
839
|
+
return e = e.replaceAll(new RegExp(rn, "g"), sn), e;
|
|
840
|
+
}, cn = ({
|
|
841
|
+
appName: n,
|
|
842
|
+
appVersion: e,
|
|
843
|
+
browserName: t,
|
|
844
|
+
browserVersion: r
|
|
845
|
+
}) => {
|
|
846
|
+
const o = `${on(n)} ${e}`;
|
|
847
|
+
return `ChromeNew - ${t === void 0 ? o : `${t} ${r}, ${o}`}`;
|
|
848
|
+
}, an = ({
|
|
849
|
+
isUnifiedSdpSemantic: n,
|
|
850
|
+
appVersion: e,
|
|
851
|
+
browserName: t,
|
|
852
|
+
browserVersion: r,
|
|
853
|
+
appName: s
|
|
854
|
+
}) => n ? cn({ appVersion: e, browserName: t, browserVersion: r, appName: s }) : "Chrome", dn = (n) => (e) => [...e].map((r) => async () => n(r)), un = async ({
|
|
855
|
+
accumulatedKeys: n,
|
|
856
|
+
sendKey: e,
|
|
857
|
+
canRunTask: t
|
|
858
|
+
}) => {
|
|
859
|
+
const s = dn(e)(n);
|
|
860
|
+
return ue(s, t);
|
|
861
|
+
}, ln = (n) => (t) => (i("onStartMainCam"), n.on("api:admin-start-main-cam", t)), hn = (n) => (t) => (i("onStartMic"), n.on("api:admin-start-mic", t)), fn = (n) => (t) => (i("onStopMainCam"), n.on("api:admin-stop-main-cam", t)), Sn = (n) => (t) => (i("onStopMic"), n.on("api:admin-stop-mic", t)), Cn = ({ sipConnector: n }) => {
|
|
862
|
+
const e = (S, g) => ({ isSyncForced: m }) => {
|
|
863
|
+
if (m === !0) {
|
|
864
|
+
S();
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
g();
|
|
868
|
+
}, t = ln(n), r = fn(n), s = hn(n), o = Sn(n);
|
|
869
|
+
let c, a, d, l;
|
|
870
|
+
const f = ({
|
|
871
|
+
onStartMainCamForced: S,
|
|
872
|
+
onStartMainCamNotForced: g,
|
|
873
|
+
onStopMainCamForced: m,
|
|
874
|
+
onStopMainCamNotForced: p,
|
|
875
|
+
onStartMicForced: y,
|
|
876
|
+
onStartMicNotForced: E,
|
|
877
|
+
onStopMicForced: M,
|
|
878
|
+
onStopMicNotForced: b
|
|
879
|
+
}) => {
|
|
880
|
+
const B = e(
|
|
881
|
+
S,
|
|
882
|
+
g
|
|
883
|
+
);
|
|
884
|
+
c = t(B);
|
|
885
|
+
const _ = e(
|
|
886
|
+
m,
|
|
887
|
+
p
|
|
888
|
+
);
|
|
889
|
+
a = r(_);
|
|
890
|
+
const A = e(y, E);
|
|
891
|
+
d = s(A);
|
|
892
|
+
const N = e(M, b);
|
|
893
|
+
l = o(N);
|
|
894
|
+
}, h = () => {
|
|
895
|
+
c?.(), a?.(), d?.(), l?.();
|
|
896
|
+
};
|
|
897
|
+
return {
|
|
898
|
+
start: (S) => {
|
|
899
|
+
f(S);
|
|
900
|
+
},
|
|
901
|
+
stop: () => {
|
|
902
|
+
h();
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
}, An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
906
|
+
__proto__: null,
|
|
907
|
+
PURGATORY_CONFERENCE_NUMBER: re,
|
|
908
|
+
createSyncMediaState: Cn,
|
|
909
|
+
error: nn,
|
|
910
|
+
getExtraHeaders: tn,
|
|
911
|
+
getUserAgent: an,
|
|
912
|
+
hasPurgatory: x,
|
|
913
|
+
sendDtmfAccumulated: un
|
|
914
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
915
|
+
var gn = /* @__PURE__ */ ((n) => (n.VP8 = "video/VP8", n.VP9 = "video/VP9", n.H264 = "video/H264", n.AV1 = "video/AV1", n.rtx = "video/rtx", n.red = "video/red", n.flexfec03 = "video/flexfec-03", n))(gn || {});
|
|
745
916
|
export {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
Nn as hasCanceledStartPresentationError,
|
|
762
|
-
fn as resolveVideoSendingBalancer,
|
|
763
|
-
ae as setParametersToSender,
|
|
764
|
-
Sn as tools
|
|
917
|
+
R as ECallCause,
|
|
918
|
+
gn as EMimeTypesVideoCodecs,
|
|
919
|
+
wn as EUseLicense,
|
|
920
|
+
Pn as SipConnector,
|
|
921
|
+
_n as SipConnectorFacade,
|
|
922
|
+
He as VideoSendingBalancer,
|
|
923
|
+
xn as debug,
|
|
924
|
+
Dn as disableDebug,
|
|
925
|
+
kn as enableDebug,
|
|
926
|
+
De as getCodecFromSender,
|
|
927
|
+
bn as hasCanceledCallError,
|
|
928
|
+
In as hasCanceledStartPresentationError,
|
|
929
|
+
Bn as resolveVideoSendingBalancer,
|
|
930
|
+
z as setParametersToSender,
|
|
931
|
+
An as tools
|
|
765
932
|
};
|