sip-connector 15.0.0 → 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-DbvV1Leg.js → @SipConnector-G96OmJEP.js} +97 -96
- package/dist/ApiManager/__tests-utils__/helpers.d.ts +9 -0
- package/dist/ApiManager/constants.d.ts +2 -1
- package/dist/ApiManager/eventNames.d.ts +2 -1
- package/dist/CallManager/MCUCallStrategy.d.ts +1 -1
- package/dist/ConnectionManager/@ConnectionManager.d.ts +3 -3
- package/dist/ConnectionManager/getExtraHeadersRemoteAddress.d.ts +2 -2
- package/dist/IncomingCallManager/@IncomingCallManager.d.ts +2 -2
- package/dist/SipConnector/@SipConnector.d.ts +2 -2
- package/dist/SipConnector/eventNames.d.ts +1 -1
- package/dist/SipConnectorFacade/SipConnectorFacade.d.ts +12 -1
- package/dist/__fixtures__/BaseSession.mock.d.ts +1 -1
- package/dist/__fixtures__/RTCPeerConnectionMock.d.ts +2 -2
- package/dist/__fixtures__/RTCRtpSenderMock.d.ts +1 -0
- package/dist/__fixtures__/RTCSessionMock.d.ts +2 -2
- package/dist/__fixtures__/UA.mock.d.ts +2 -2
- package/dist/__fixtures__/eventNames.d.ts +1 -1
- package/dist/__fixtures__/jssip.mock.d.ts +1 -1
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +18 -19
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +645 -525
- package/dist/setParametersToSender/index.d.ts +3 -1
- package/dist/{videoSendingBalancer → setParametersToSender}/setEncodingsToSender.d.ts +1 -5
- package/dist/setParametersToSender/setMaxBitrateToSender.d.ts +2 -0
- package/dist/setParametersToSender/setParametersToSender.d.ts +1 -4
- package/dist/setParametersToSender/types.d.ts +5 -0
- package/dist/tools/error/index.d.ts +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/syncMediaState/createSyncMediaState.d.ts +18 -0
- package/dist/tools/syncMediaState/index.d.ts +1 -18
- 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 -13
- package/dist/videoSendingBalancer/types.d.ts +36 -0
- package/package.json +11 -11
- package/dist/@SipConnector-CZo7A8_q.cjs +0 -1
- package/dist/videoSendingBalancer/balance.d.ts +0 -10
- package/dist/videoSendingBalancer/getMaxBitrateByWidth.d.ts +0 -4
- package/dist/videoSendingBalancer/getMaxBitrateByWidthAndCodec.d.ts +0 -4
- package/dist/videoSendingBalancer/processSender.d.ts +0 -10
- package/dist/videoSendingBalancer/scaleBitrate.d.ts +0 -2
- /package/dist/{videoSendingBalancer → tools}/scaleResolutionAndBitrate.d.ts +0 -0
- /package/dist/{videoSendingBalancer → utils}/hasIncludesString.d.ts +0 -0
- /package/dist/videoSendingBalancer/{hasAv1Codec.d.ts → calcBitrate/hasAv1Codec.d.ts} +0 -0
- /package/dist/videoSendingBalancer/{scaleBitrateByCodec.d.ts → calcBitrate/scaleBitrateByCodec.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,140 +1,415 @@
|
|
|
1
1
|
import "events-constructor";
|
|
2
|
-
import { E as
|
|
3
|
-
import { b as
|
|
4
|
-
import { isCanceledError as
|
|
5
|
-
import { hasCanceledError as
|
|
6
|
-
import { debounce as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
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
13
|
return !0;
|
|
14
|
-
if (!
|
|
14
|
+
if (!le(n))
|
|
15
15
|
return !1;
|
|
16
|
-
const { originator:
|
|
17
|
-
return typeof t == "string" ? t ===
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
for (let t =
|
|
21
|
-
|
|
22
|
-
return
|
|
23
|
-
},
|
|
24
|
-
if (Se(
|
|
25
|
-
return
|
|
26
|
-
},
|
|
27
|
-
const t =
|
|
28
|
-
return
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
),
|
|
32
|
-
const t =
|
|
33
|
-
if (t !== void 0 &&
|
|
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
34
|
t,
|
|
35
|
-
|
|
35
|
+
e
|
|
36
36
|
))
|
|
37
37
|
return t;
|
|
38
|
-
},
|
|
39
|
-
const t =
|
|
40
|
-
|
|
38
|
+
}, Re = (n, e) => {
|
|
39
|
+
const t = n.scaleResolutionDownBy, r = pe(
|
|
40
|
+
e,
|
|
41
41
|
t
|
|
42
42
|
);
|
|
43
|
-
return
|
|
44
|
-
},
|
|
45
|
-
const t =
|
|
46
|
-
return
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
}),
|
|
50
|
-
}, ve = (
|
|
51
|
-
if (
|
|
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
52
|
return !0;
|
|
53
|
-
for (let t = 0; t < (
|
|
54
|
-
if (JSON.stringify(
|
|
53
|
+
for (let t = 0; t < (n.codecs?.length ?? 0); t++)
|
|
54
|
+
if (JSON.stringify(n.codecs[t]) !== JSON.stringify(e.codecs[t]))
|
|
55
55
|
return !0;
|
|
56
|
-
if (
|
|
56
|
+
if (n.headerExtensions?.length !== e.headerExtensions?.length)
|
|
57
57
|
return !0;
|
|
58
|
-
for (let t = 0; t < (
|
|
59
|
-
if (JSON.stringify(
|
|
58
|
+
for (let t = 0; t < (n.headerExtensions?.length ?? 0); t++)
|
|
59
|
+
if (JSON.stringify(n.headerExtensions[t]) !== JSON.stringify(e.headerExtensions[t]))
|
|
60
60
|
return !0;
|
|
61
|
-
if (
|
|
61
|
+
if (n.encodings?.length !== e.encodings?.length)
|
|
62
62
|
return !0;
|
|
63
|
-
for (let t = 0; t < (
|
|
64
|
-
if (JSON.stringify(
|
|
63
|
+
for (let t = 0; t < (n.encodings?.length ?? 0); t++)
|
|
64
|
+
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
65
65
|
return !0;
|
|
66
|
-
return
|
|
67
|
-
},
|
|
68
|
-
const t =
|
|
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
69
|
JSON.stringify(t)
|
|
70
70
|
);
|
|
71
|
-
|
|
72
|
-
const s = ve(
|
|
73
|
-
return s && await
|
|
74
|
-
},
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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) ?? "";
|
|
98
|
+
}
|
|
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();
|
|
111
|
+
}
|
|
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: {}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
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
|
+
}
|
|
181
|
+
);
|
|
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);
|
|
203
|
+
}
|
|
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 = {
|
|
237
|
+
width: Number(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);
|
|
247
|
+
}
|
|
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);
|
|
254
|
+
}
|
|
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)
|
|
332
|
+
throw new Error("connection is not exist");
|
|
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);
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
const Bn = (n, e = {}) => new He(n, e), $e = ({
|
|
344
|
+
videoTrack: n,
|
|
345
|
+
targetSize: e,
|
|
80
346
|
codec: t
|
|
81
347
|
}) => {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
348
|
+
const r = te({
|
|
349
|
+
videoTrack: n,
|
|
350
|
+
targetSize: e
|
|
351
|
+
}), s = Q(e.width, t);
|
|
352
|
+
return { scaleResolutionDownBy: r, maxBitrate: s };
|
|
353
|
+
}, P = ({
|
|
354
|
+
mediaStream: n,
|
|
355
|
+
simulcastEncodings: e,
|
|
87
356
|
sendEncodings: t
|
|
88
357
|
}) => {
|
|
89
|
-
if (
|
|
90
|
-
const
|
|
358
|
+
if (e && e.length > 0) {
|
|
359
|
+
const r = t ?? [], s = Ee(n);
|
|
91
360
|
if (s === void 0)
|
|
92
361
|
throw new Error("No video track");
|
|
93
|
-
return
|
|
94
|
-
const a =
|
|
95
|
-
a.active = !0,
|
|
96
|
-
const { maxBitrate:
|
|
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({
|
|
97
366
|
videoTrack: s,
|
|
98
367
|
targetSize: {
|
|
99
|
-
width:
|
|
100
|
-
height:
|
|
368
|
+
width: o.width,
|
|
369
|
+
height: o.height
|
|
101
370
|
}
|
|
102
371
|
});
|
|
103
|
-
a.maxBitrate =
|
|
104
|
-
}),
|
|
372
|
+
a.maxBitrate = d, a.scaleResolutionDownBy = l, r[c] = a;
|
|
373
|
+
}), r;
|
|
105
374
|
}
|
|
106
375
|
return t;
|
|
107
|
-
},
|
|
108
|
-
const
|
|
109
|
-
return
|
|
110
|
-
},
|
|
111
|
-
const s =
|
|
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;
|
|
112
381
|
return c - a;
|
|
113
|
-
}),
|
|
114
|
-
preferredMimeTypesVideoCodecs:
|
|
382
|
+
}), Xe = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), je = (n, {
|
|
383
|
+
preferredMimeTypesVideoCodecs: e,
|
|
115
384
|
excludeMimeTypesVideoCodecs: t
|
|
116
385
|
}) => {
|
|
117
|
-
if (typeof
|
|
118
|
-
const
|
|
119
|
-
|
|
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);
|
|
120
389
|
}
|
|
121
|
-
},
|
|
122
|
-
preferredMimeTypesVideoCodecs:
|
|
390
|
+
}, D = (n, {
|
|
391
|
+
preferredMimeTypesVideoCodecs: e,
|
|
123
392
|
excludeMimeTypesVideoCodecs: t
|
|
124
|
-
}) => async (
|
|
393
|
+
}) => async (r) => {
|
|
125
394
|
try {
|
|
126
|
-
|
|
127
|
-
preferredMimeTypesVideoCodecs:
|
|
395
|
+
je(r, {
|
|
396
|
+
preferredMimeTypesVideoCodecs: e,
|
|
128
397
|
excludeMimeTypesVideoCodecs: t
|
|
129
|
-
}), Object.values(
|
|
398
|
+
}), Object.values(n).filter((o) => o != null).length > 0 && (i("updateTransceiver setParametersToSender", n), await z(r.sender, n));
|
|
130
399
|
} catch (s) {
|
|
131
400
|
i("updateTransceiver error", s);
|
|
132
401
|
}
|
|
133
|
-
},
|
|
134
|
-
if (!
|
|
135
|
-
throw
|
|
402
|
+
}, W = (n) => {
|
|
403
|
+
if (!K(n) && !ce(n))
|
|
404
|
+
throw n;
|
|
136
405
|
return { isSuccessful: !1 };
|
|
137
|
-
},
|
|
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([
|
|
138
413
|
"on",
|
|
139
414
|
"once",
|
|
140
415
|
"onceRace",
|
|
@@ -151,7 +426,7 @@ const he = (e) => e instanceof Object && ("originator" in e || "cause" in e), Mn
|
|
|
151
426
|
"isConfigured",
|
|
152
427
|
"isRegistered"
|
|
153
428
|
]);
|
|
154
|
-
class
|
|
429
|
+
class _n {
|
|
155
430
|
// @ts-expect-error: proxy method
|
|
156
431
|
on;
|
|
157
432
|
// @ts-expect-error: proxy method
|
|
@@ -185,142 +460,142 @@ class bn {
|
|
|
185
460
|
sipConnector;
|
|
186
461
|
preferredMimeTypesVideoCodecs;
|
|
187
462
|
excludeMimeTypesVideoCodecs;
|
|
188
|
-
constructor(
|
|
463
|
+
constructor(e, {
|
|
189
464
|
preferredMimeTypesVideoCodecs: t,
|
|
190
|
-
excludeMimeTypesVideoCodecs:
|
|
465
|
+
excludeMimeTypesVideoCodecs: r
|
|
191
466
|
} = {}) {
|
|
192
|
-
return this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs =
|
|
193
|
-
get: (s,
|
|
194
|
-
if (typeof
|
|
195
|
-
const
|
|
196
|
-
return typeof
|
|
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;
|
|
197
472
|
}
|
|
198
|
-
const a = Reflect.get(s,
|
|
473
|
+
const a = Reflect.get(s, o, c);
|
|
199
474
|
return typeof a == "function" ? a.bind(s) : a;
|
|
200
475
|
}
|
|
201
476
|
});
|
|
202
477
|
}
|
|
203
|
-
connectToServer = async (
|
|
478
|
+
connectToServer = async (e) => {
|
|
204
479
|
const {
|
|
205
480
|
userAgent: t,
|
|
206
|
-
sipWebSocketServerURL:
|
|
481
|
+
sipWebSocketServerURL: r,
|
|
207
482
|
sipServerUrl: s,
|
|
208
|
-
remoteAddress:
|
|
483
|
+
remoteAddress: o,
|
|
209
484
|
displayName: c,
|
|
210
485
|
name: a,
|
|
211
|
-
password:
|
|
486
|
+
password: d,
|
|
212
487
|
isRegisteredUser: l,
|
|
213
|
-
isDisconnectOnFail:
|
|
214
|
-
} =
|
|
215
|
-
return i("connectToServer",
|
|
488
|
+
isDisconnectOnFail: f
|
|
489
|
+
} = e;
|
|
490
|
+
return i("connectToServer", e), this.sipConnector.connect({
|
|
216
491
|
userAgent: t,
|
|
217
|
-
sipWebSocketServerURL:
|
|
492
|
+
sipWebSocketServerURL: r,
|
|
218
493
|
sipServerUrl: s,
|
|
219
|
-
remoteAddress:
|
|
494
|
+
remoteAddress: o,
|
|
220
495
|
displayName: c,
|
|
221
|
-
password:
|
|
496
|
+
password: d,
|
|
222
497
|
user: a,
|
|
223
498
|
register: l
|
|
224
|
-
}).then((
|
|
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)));
|
|
225
500
|
};
|
|
226
|
-
callToServer = async (
|
|
501
|
+
callToServer = async (e) => {
|
|
227
502
|
const {
|
|
228
503
|
conference: t,
|
|
229
|
-
mediaStream:
|
|
504
|
+
mediaStream: r,
|
|
230
505
|
extraHeaders: s,
|
|
231
|
-
iceServers:
|
|
506
|
+
iceServers: o,
|
|
232
507
|
contentHint: c,
|
|
233
508
|
simulcastEncodings: a,
|
|
234
|
-
degradationPreference:
|
|
509
|
+
degradationPreference: d,
|
|
235
510
|
sendEncodings: l,
|
|
236
|
-
offerToReceiveAudio:
|
|
237
|
-
offerToReceiveVideo:
|
|
238
|
-
directionVideo:
|
|
239
|
-
directionAudio:
|
|
240
|
-
setRemoteStreams:
|
|
241
|
-
onBeforeProgressCall:
|
|
242
|
-
onSuccessProgressCall:
|
|
243
|
-
onEnterPurgatory:
|
|
244
|
-
onEnterConference:
|
|
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,
|
|
245
520
|
onFailProgressCall: E,
|
|
246
|
-
onFinishProgressCall:
|
|
247
|
-
onEndedCall:
|
|
248
|
-
} =
|
|
249
|
-
onReadyRemoteStreams:
|
|
250
|
-
}),
|
|
521
|
+
onFinishProgressCall: M,
|
|
522
|
+
onEndedCall: b
|
|
523
|
+
} = e, B = this.resolveHandleReadyRemoteStreamsDebounced({
|
|
524
|
+
onReadyRemoteStreams: S
|
|
525
|
+
}), _ = this.resolveHandleReadyRemoteStreams({
|
|
251
526
|
onReadyRemoteStreams: () => {
|
|
252
|
-
|
|
527
|
+
B().catch(k);
|
|
253
528
|
}
|
|
254
|
-
}),
|
|
529
|
+
}), A = D(
|
|
255
530
|
{
|
|
256
|
-
degradationPreference:
|
|
531
|
+
degradationPreference: d
|
|
257
532
|
},
|
|
258
533
|
{
|
|
259
534
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
260
535
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
261
536
|
}
|
|
262
537
|
);
|
|
263
|
-
i("callToServer",
|
|
538
|
+
i("callToServer", e);
|
|
264
539
|
const N = async () => (i("startCall"), this.sipConnector.call({
|
|
265
|
-
mediaStream:
|
|
540
|
+
mediaStream: r,
|
|
266
541
|
extraHeaders: s,
|
|
267
|
-
iceServers:
|
|
542
|
+
iceServers: o,
|
|
268
543
|
contentHint: c,
|
|
269
|
-
offerToReceiveAudio:
|
|
270
|
-
offerToReceiveVideo:
|
|
271
|
-
directionVideo:
|
|
272
|
-
directionAudio:
|
|
273
|
-
sendEncodings:
|
|
274
|
-
mediaStream:
|
|
544
|
+
offerToReceiveAudio: f,
|
|
545
|
+
offerToReceiveVideo: h,
|
|
546
|
+
directionVideo: I,
|
|
547
|
+
directionAudio: F,
|
|
548
|
+
sendEncodings: P({
|
|
549
|
+
mediaStream: r,
|
|
275
550
|
simulcastEncodings: a,
|
|
276
551
|
sendEncodings: l
|
|
277
552
|
}),
|
|
278
553
|
number: t,
|
|
279
|
-
onAddedTransceiver:
|
|
280
|
-
ontrack:
|
|
554
|
+
onAddedTransceiver: A,
|
|
555
|
+
ontrack: _
|
|
281
556
|
}));
|
|
282
|
-
let
|
|
283
|
-
const
|
|
284
|
-
i("enterRoom", { _room:
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}),
|
|
289
|
-
|
|
290
|
-
},
|
|
291
|
-
i("onFinish"),
|
|
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();
|
|
292
567
|
};
|
|
293
|
-
return i("onBeforeProgressCall"),
|
|
568
|
+
return i("onBeforeProgressCall"), g && g(t), N().then(V).catch((u) => L(u)).finally(H);
|
|
294
569
|
};
|
|
295
|
-
disconnectFromServer = async () => this.sipConnector.disconnect().then(() => (i("disconnectFromServer: then"), { isSuccessful: !0 })).catch((
|
|
296
|
-
answerToIncomingCall = async (
|
|
570
|
+
disconnectFromServer = async () => this.sipConnector.disconnect().then(() => (i("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (i("disconnectFromServer: catch", e), { isSuccessful: !1 }));
|
|
571
|
+
answerToIncomingCall = async (e) => {
|
|
297
572
|
const {
|
|
298
573
|
mediaStream: t,
|
|
299
|
-
extraHeaders:
|
|
574
|
+
extraHeaders: r,
|
|
300
575
|
iceServers: s,
|
|
301
|
-
contentHint:
|
|
576
|
+
contentHint: o,
|
|
302
577
|
simulcastEncodings: c,
|
|
303
578
|
degradationPreference: a,
|
|
304
|
-
sendEncodings:
|
|
579
|
+
sendEncodings: d,
|
|
305
580
|
offerToReceiveAudio: l,
|
|
306
|
-
offerToReceiveVideo:
|
|
307
|
-
directionVideo:
|
|
308
|
-
directionAudio:
|
|
309
|
-
setRemoteStreams:
|
|
310
|
-
onBeforeProgressCall:
|
|
311
|
-
onSuccessProgressCall:
|
|
312
|
-
onEnterPurgatory:
|
|
313
|
-
onEnterConference:
|
|
314
|
-
onFailProgressCall:
|
|
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,
|
|
315
590
|
onFinishProgressCall: E,
|
|
316
|
-
onEndedCall:
|
|
317
|
-
} =
|
|
318
|
-
onReadyRemoteStreams:
|
|
319
|
-
}),
|
|
591
|
+
onEndedCall: M
|
|
592
|
+
} = e, b = this.resolveHandleReadyRemoteStreamsDebounced({
|
|
593
|
+
onReadyRemoteStreams: F
|
|
594
|
+
}), B = this.resolveHandleReadyRemoteStreams({
|
|
320
595
|
onReadyRemoteStreams: () => {
|
|
321
|
-
|
|
596
|
+
b().catch(k);
|
|
322
597
|
}
|
|
323
|
-
}),
|
|
598
|
+
}), _ = D(
|
|
324
599
|
{
|
|
325
600
|
degradationPreference: a
|
|
326
601
|
},
|
|
@@ -329,141 +604,141 @@ class bn {
|
|
|
329
604
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
330
605
|
}
|
|
331
606
|
);
|
|
332
|
-
i("answerToIncomingCall",
|
|
333
|
-
const
|
|
607
|
+
i("answerToIncomingCall", e);
|
|
608
|
+
const A = async () => this.sipConnector.answerToIncomingCall({
|
|
334
609
|
mediaStream: t,
|
|
335
|
-
extraHeaders:
|
|
610
|
+
extraHeaders: r,
|
|
336
611
|
iceServers: s,
|
|
337
|
-
contentHint:
|
|
612
|
+
contentHint: o,
|
|
338
613
|
offerToReceiveAudio: l,
|
|
339
|
-
offerToReceiveVideo:
|
|
340
|
-
directionVideo:
|
|
341
|
-
directionAudio:
|
|
342
|
-
sendEncodings:
|
|
614
|
+
offerToReceiveVideo: f,
|
|
615
|
+
directionVideo: h,
|
|
616
|
+
directionAudio: I,
|
|
617
|
+
sendEncodings: P({
|
|
343
618
|
mediaStream: t,
|
|
344
619
|
simulcastEncodings: c,
|
|
345
|
-
sendEncodings:
|
|
620
|
+
sendEncodings: d
|
|
346
621
|
}),
|
|
347
|
-
onAddedTransceiver:
|
|
348
|
-
ontrack:
|
|
622
|
+
onAddedTransceiver: _,
|
|
623
|
+
ontrack: B
|
|
349
624
|
}), N = () => {
|
|
350
|
-
const { remoteCallerData:
|
|
351
|
-
return
|
|
625
|
+
const { remoteCallerData: u } = this.sipConnector;
|
|
626
|
+
return u.incomingNumber;
|
|
352
627
|
};
|
|
353
|
-
let
|
|
354
|
-
const
|
|
355
|
-
i("enterRoom", { _room:
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}),
|
|
360
|
-
|
|
361
|
-
},
|
|
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
|
|
633
|
+
});
|
|
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 = () => {
|
|
362
637
|
i("onFinish"), E && E();
|
|
363
638
|
};
|
|
364
|
-
if (i("onBeforeProgressCall"),
|
|
365
|
-
const
|
|
366
|
-
|
|
639
|
+
if (i("onBeforeProgressCall"), S) {
|
|
640
|
+
const u = N();
|
|
641
|
+
S(u);
|
|
367
642
|
}
|
|
368
|
-
return
|
|
643
|
+
return A().then(V).catch((u) => L(u)).finally(H);
|
|
369
644
|
};
|
|
370
645
|
updatePresentation = async ({
|
|
371
|
-
mediaStream:
|
|
646
|
+
mediaStream: e,
|
|
372
647
|
isP2P: t,
|
|
373
|
-
maxBitrate:
|
|
648
|
+
maxBitrate: r,
|
|
374
649
|
contentHint: s,
|
|
375
|
-
simulcastEncodings:
|
|
650
|
+
simulcastEncodings: o,
|
|
376
651
|
degradationPreference: c,
|
|
377
652
|
sendEncodings: a,
|
|
378
|
-
preferredMimeTypesVideoCodecs:
|
|
653
|
+
preferredMimeTypesVideoCodecs: d,
|
|
379
654
|
excludeMimeTypesVideoCodecs: l
|
|
380
655
|
}) => {
|
|
381
|
-
const
|
|
656
|
+
const f = D(
|
|
382
657
|
{
|
|
383
658
|
degradationPreference: c
|
|
384
659
|
},
|
|
385
660
|
{
|
|
386
|
-
preferredMimeTypesVideoCodecs:
|
|
661
|
+
preferredMimeTypesVideoCodecs: d,
|
|
387
662
|
excludeMimeTypesVideoCodecs: l
|
|
388
663
|
}
|
|
389
664
|
);
|
|
390
|
-
return i("updatePresentation"), this.sipConnector.updatePresentation(
|
|
665
|
+
return i("updatePresentation"), this.sipConnector.updatePresentation(e, {
|
|
391
666
|
isP2P: t,
|
|
392
|
-
maxBitrate:
|
|
667
|
+
maxBitrate: r,
|
|
393
668
|
contentHint: s,
|
|
394
|
-
sendEncodings:
|
|
395
|
-
mediaStream:
|
|
396
|
-
simulcastEncodings:
|
|
669
|
+
sendEncodings: P({
|
|
670
|
+
mediaStream: e,
|
|
671
|
+
simulcastEncodings: o,
|
|
397
672
|
sendEncodings: a
|
|
398
673
|
}),
|
|
399
|
-
onAddedTransceiver:
|
|
674
|
+
onAddedTransceiver: f
|
|
400
675
|
});
|
|
401
676
|
};
|
|
402
677
|
startPresentation = async ({
|
|
403
|
-
mediaStream:
|
|
678
|
+
mediaStream: e,
|
|
404
679
|
isP2P: t,
|
|
405
|
-
maxBitrate:
|
|
680
|
+
maxBitrate: r,
|
|
406
681
|
contentHint: s,
|
|
407
|
-
simulcastEncodings:
|
|
682
|
+
simulcastEncodings: o,
|
|
408
683
|
degradationPreference: c,
|
|
409
684
|
sendEncodings: a,
|
|
410
|
-
preferredMimeTypesVideoCodecs:
|
|
685
|
+
preferredMimeTypesVideoCodecs: d,
|
|
411
686
|
excludeMimeTypesVideoCodecs: l,
|
|
412
|
-
callLimit:
|
|
687
|
+
callLimit: f
|
|
413
688
|
}) => {
|
|
414
|
-
const
|
|
689
|
+
const h = D(
|
|
415
690
|
{
|
|
416
691
|
degradationPreference: c
|
|
417
692
|
},
|
|
418
693
|
{
|
|
419
|
-
preferredMimeTypesVideoCodecs:
|
|
694
|
+
preferredMimeTypesVideoCodecs: d,
|
|
420
695
|
excludeMimeTypesVideoCodecs: l
|
|
421
696
|
}
|
|
422
697
|
);
|
|
423
|
-
return i("startPresentation"), this.sipConnector.startPresentation(
|
|
698
|
+
return i("startPresentation"), this.sipConnector.startPresentation(e, {
|
|
424
699
|
isP2P: t,
|
|
425
|
-
maxBitrate:
|
|
700
|
+
maxBitrate: r,
|
|
426
701
|
contentHint: s,
|
|
427
|
-
callLimit:
|
|
428
|
-
sendEncodings:
|
|
429
|
-
mediaStream:
|
|
430
|
-
simulcastEncodings:
|
|
702
|
+
callLimit: f,
|
|
703
|
+
sendEncodings: P({
|
|
704
|
+
mediaStream: e,
|
|
705
|
+
simulcastEncodings: o,
|
|
431
706
|
sendEncodings: a
|
|
432
707
|
}),
|
|
433
|
-
onAddedTransceiver:
|
|
708
|
+
onAddedTransceiver: h
|
|
434
709
|
});
|
|
435
710
|
};
|
|
436
|
-
stopShareSipConnector = async ({ isP2P:
|
|
437
|
-
isP2P:
|
|
711
|
+
stopShareSipConnector = async ({ isP2P: e = !1 } = {}) => (i("stopShareSipConnector"), this.sipConnector.stopPresentation({
|
|
712
|
+
isP2P: e
|
|
438
713
|
}).catch((t) => {
|
|
439
714
|
i(t);
|
|
440
715
|
}));
|
|
441
716
|
sendRefusalToTurnOnMic = async () => {
|
|
442
|
-
i("sendRefusalToTurnOnMic"), await this.sipConnector.sendRefusalToTurnOnMic().catch((
|
|
443
|
-
i("sendRefusalToTurnOnMic: error",
|
|
717
|
+
i("sendRefusalToTurnOnMic"), await this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
|
|
718
|
+
i("sendRefusalToTurnOnMic: error", e);
|
|
444
719
|
});
|
|
445
720
|
};
|
|
446
721
|
sendRefusalToTurnOnCam = async () => {
|
|
447
|
-
i("sendRefusalToTurnOnCam"), await this.sipConnector.sendRefusalToTurnOnCam().catch((
|
|
448
|
-
i("sendRefusalToTurnOnCam: error",
|
|
722
|
+
i("sendRefusalToTurnOnCam"), await this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
|
|
723
|
+
i("sendRefusalToTurnOnCam: error", e);
|
|
449
724
|
});
|
|
450
725
|
};
|
|
451
726
|
sendMediaState = async ({
|
|
452
|
-
isEnabledCam:
|
|
727
|
+
isEnabledCam: e,
|
|
453
728
|
isEnabledMic: t
|
|
454
729
|
}) => {
|
|
455
|
-
i("sendMediaState"), await this.sipConnector.sendMediaState({ cam:
|
|
730
|
+
i("sendMediaState"), await this.sipConnector.sendMediaState({ cam: e, mic: t });
|
|
456
731
|
};
|
|
457
|
-
replaceMediaStream = async (
|
|
732
|
+
replaceMediaStream = async (e, {
|
|
458
733
|
deleteExisting: t,
|
|
459
|
-
addMissing:
|
|
734
|
+
addMissing: r,
|
|
460
735
|
forceRenegotiation: s,
|
|
461
|
-
contentHint:
|
|
736
|
+
contentHint: o,
|
|
462
737
|
simulcastEncodings: c,
|
|
463
738
|
degradationPreference: a,
|
|
464
|
-
sendEncodings:
|
|
465
|
-
}
|
|
466
|
-
const l =
|
|
739
|
+
sendEncodings: d
|
|
740
|
+
}) => {
|
|
741
|
+
const l = D(
|
|
467
742
|
{
|
|
468
743
|
degradationPreference: a
|
|
469
744
|
},
|
|
@@ -472,15 +747,15 @@ class bn {
|
|
|
472
747
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
473
748
|
}
|
|
474
749
|
);
|
|
475
|
-
return i("replaceMediaStream"), this.sipConnector.replaceMediaStream(
|
|
750
|
+
return i("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
|
|
476
751
|
deleteExisting: t,
|
|
477
|
-
addMissing:
|
|
752
|
+
addMissing: r,
|
|
478
753
|
forceRenegotiation: s,
|
|
479
|
-
contentHint:
|
|
480
|
-
sendEncodings:
|
|
481
|
-
mediaStream:
|
|
754
|
+
contentHint: o,
|
|
755
|
+
sendEncodings: P({
|
|
756
|
+
mediaStream: e,
|
|
482
757
|
simulcastEncodings: c,
|
|
483
|
-
sendEncodings:
|
|
758
|
+
sendEncodings: d
|
|
484
759
|
}),
|
|
485
760
|
onAddedTransceiver: l
|
|
486
761
|
});
|
|
@@ -489,324 +764,169 @@ class bn {
|
|
|
489
764
|
i("askPermissionToEnableCam"), await this.sipConnector.askPermissionToEnableCam();
|
|
490
765
|
};
|
|
491
766
|
resolveHandleReadyRemoteStreamsDebounced = ({
|
|
492
|
-
onReadyRemoteStreams:
|
|
493
|
-
}) =>
|
|
767
|
+
onReadyRemoteStreams: e
|
|
768
|
+
}) => ae(() => {
|
|
494
769
|
const t = this.sipConnector.getRemoteStreams();
|
|
495
|
-
i("remoteStreams", t), t &&
|
|
770
|
+
i("remoteStreams", t), t && e(t);
|
|
496
771
|
}, 200);
|
|
497
772
|
// eslint-disable-next-line class-methods-use-this
|
|
498
773
|
resolveHandleReadyRemoteStreams = ({
|
|
499
|
-
onReadyRemoteStreams:
|
|
774
|
+
onReadyRemoteStreams: e
|
|
500
775
|
}) => ({ track: t }) => {
|
|
501
|
-
|
|
776
|
+
Ge(t) && e();
|
|
502
777
|
};
|
|
503
778
|
getRemoteStreams = () => (i("getRemoteStreams"), this.sipConnector.getRemoteStreams());
|
|
504
|
-
onUseLicense = (
|
|
505
|
-
onMustStopPresentation = (
|
|
506
|
-
onMoveToSpectators = (
|
|
507
|
-
onMoveToParticipants = (
|
|
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));
|
|
508
783
|
}
|
|
509
|
-
const
|
|
510
|
-
const { url:
|
|
511
|
-
let
|
|
512
|
-
return (t ===
|
|
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;
|
|
513
788
|
};
|
|
514
|
-
var
|
|
515
|
-
const
|
|
516
|
-
const { cause:
|
|
517
|
-
let
|
|
518
|
-
switch (
|
|
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) {
|
|
519
794
|
case "Forbidden": {
|
|
520
|
-
|
|
795
|
+
r = "WRONG_USER_OR_PASSWORD";
|
|
521
796
|
break;
|
|
522
797
|
}
|
|
523
|
-
case
|
|
524
|
-
|
|
798
|
+
case R.BAD_MEDIA_DESCRIPTION: {
|
|
799
|
+
r = "BAD_MEDIA_ERROR";
|
|
525
800
|
break;
|
|
526
801
|
}
|
|
527
|
-
case
|
|
528
|
-
|
|
802
|
+
case R.NOT_FOUND: {
|
|
803
|
+
r = "NOT_FOUND_ERROR";
|
|
529
804
|
break;
|
|
530
805
|
}
|
|
531
806
|
default:
|
|
532
|
-
t !== void 0 && t._ws?.readyState === 3 ?
|
|
807
|
+
t !== void 0 && t._ws?.readyState === 3 ? r = "WS_CONNECTION_FAILED" : U(n) !== void 0 && U(n) !== "" && (r = "CONNECT_SERVER_FAILED_BY_LINK");
|
|
533
808
|
}
|
|
534
|
-
return
|
|
535
|
-
},
|
|
536
|
-
let
|
|
809
|
+
return r;
|
|
810
|
+
}, ze = (n) => {
|
|
811
|
+
let e = "";
|
|
537
812
|
try {
|
|
538
|
-
|
|
813
|
+
e = JSON.stringify(n);
|
|
539
814
|
} catch (t) {
|
|
540
815
|
i("failed to stringify message", t);
|
|
541
816
|
}
|
|
542
|
-
return
|
|
543
|
-
},
|
|
544
|
-
const { code:
|
|
545
|
-
return typeof
|
|
546
|
-
},
|
|
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({
|
|
547
822
|
__proto__: null,
|
|
548
|
-
EErrorTypes:
|
|
549
|
-
getLinkError:
|
|
550
|
-
getTypeFromError:
|
|
551
|
-
getValuesFromError:
|
|
552
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
553
|
-
sessionId:
|
|
554
|
-
remoteAddress:
|
|
823
|
+
EErrorTypes: se,
|
|
824
|
+
getLinkError: U,
|
|
825
|
+
getTypeFromError: qe,
|
|
826
|
+
getValuesFromError: en
|
|
827
|
+
}, Symbol.toStringTag, { value: "Module" })), tn = ({
|
|
828
|
+
sessionId: n,
|
|
829
|
+
remoteAddress: e,
|
|
555
830
|
isMutedAudio: t,
|
|
556
|
-
isMutedVideo:
|
|
831
|
+
isMutedVideo: r,
|
|
557
832
|
isRegistered: s,
|
|
558
|
-
isPresentationCall:
|
|
833
|
+
isPresentationCall: o
|
|
559
834
|
}) => {
|
|
560
|
-
const c = [], a = t ? "0" : "1",
|
|
561
|
-
return c.push(`X-Vinteo-Mic-State: ${a}`, `X-Vinteo-MainCam-State: ${
|
|
562
|
-
},
|
|
563
|
-
let
|
|
564
|
-
return
|
|
565
|
-
},
|
|
566
|
-
appName:
|
|
567
|
-
appVersion:
|
|
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,
|
|
568
843
|
browserName: t,
|
|
569
|
-
browserVersion:
|
|
844
|
+
browserVersion: r
|
|
570
845
|
}) => {
|
|
571
|
-
const
|
|
572
|
-
return `ChromeNew - ${t === void 0 ?
|
|
573
|
-
},
|
|
574
|
-
isUnifiedSdpSemantic:
|
|
575
|
-
appVersion:
|
|
846
|
+
const o = `${on(n)} ${e}`;
|
|
847
|
+
return `ChromeNew - ${t === void 0 ? o : `${t} ${r}, ${o}`}`;
|
|
848
|
+
}, an = ({
|
|
849
|
+
isUnifiedSdpSemantic: n,
|
|
850
|
+
appVersion: e,
|
|
576
851
|
browserName: t,
|
|
577
|
-
browserVersion:
|
|
852
|
+
browserVersion: r,
|
|
578
853
|
appName: s
|
|
579
|
-
}) =>
|
|
580
|
-
accumulatedKeys:
|
|
581
|
-
sendKey:
|
|
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,
|
|
582
857
|
canRunTask: t
|
|
583
858
|
}) => {
|
|
584
|
-
const s =
|
|
585
|
-
return
|
|
586
|
-
},
|
|
587
|
-
const
|
|
588
|
-
if (
|
|
589
|
-
|
|
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();
|
|
590
865
|
return;
|
|
591
866
|
}
|
|
592
|
-
|
|
593
|
-
}, t =
|
|
594
|
-
let c, a,
|
|
595
|
-
const
|
|
596
|
-
onStartMainCamForced:
|
|
597
|
-
onStartMainCamNotForced:
|
|
598
|
-
onStopMainCamForced:
|
|
599
|
-
onStopMainCamNotForced:
|
|
600
|
-
onStartMicForced:
|
|
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,
|
|
601
876
|
onStartMicNotForced: E,
|
|
602
|
-
onStopMicForced:
|
|
603
|
-
onStopMicNotForced:
|
|
877
|
+
onStopMicForced: M,
|
|
878
|
+
onStopMicNotForced: b
|
|
604
879
|
}) => {
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
|
|
880
|
+
const B = e(
|
|
881
|
+
S,
|
|
882
|
+
g
|
|
608
883
|
);
|
|
609
|
-
c = t(
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
|
|
884
|
+
c = t(B);
|
|
885
|
+
const _ = e(
|
|
886
|
+
m,
|
|
887
|
+
p
|
|
613
888
|
);
|
|
614
|
-
a =
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
const N =
|
|
618
|
-
l =
|
|
619
|
-
},
|
|
620
|
-
c?.(), a?.(),
|
|
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?.();
|
|
621
896
|
};
|
|
622
897
|
return {
|
|
623
|
-
start: (
|
|
624
|
-
|
|
898
|
+
start: (S) => {
|
|
899
|
+
f(S);
|
|
625
900
|
},
|
|
626
901
|
stop: () => {
|
|
627
|
-
|
|
902
|
+
h();
|
|
628
903
|
}
|
|
629
904
|
};
|
|
630
|
-
},
|
|
905
|
+
}, An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
631
906
|
__proto__: null,
|
|
632
|
-
PURGATORY_CONFERENCE_NUMBER:
|
|
633
|
-
createSyncMediaState:
|
|
634
|
-
error:
|
|
635
|
-
getExtraHeaders:
|
|
636
|
-
getUserAgent:
|
|
637
|
-
hasPurgatory:
|
|
638
|
-
sendDtmfAccumulated:
|
|
907
|
+
PURGATORY_CONFERENCE_NUMBER: re,
|
|
908
|
+
createSyncMediaState: Cn,
|
|
909
|
+
error: nn,
|
|
910
|
+
getExtraHeaders: tn,
|
|
911
|
+
getUserAgent: an,
|
|
912
|
+
hasPurgatory: x,
|
|
913
|
+
sendDtmfAccumulated: un
|
|
639
914
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
640
|
-
var
|
|
641
|
-
const rn = (e) => [...e.keys()].map((n) => e.get(n)), cn = (e, n) => rn(e).find((t) => t?.type === n), an = async (e) => e.getStats().then((n) => cn(n, "codec")?.mimeType), un = (e) => e.find((n) => n.track?.kind === "video"), dn = async (e, n, t) => {
|
|
642
|
-
const { isChanged: o, parameters: s } = await Q(e, {
|
|
643
|
-
encodings: [
|
|
644
|
-
{
|
|
645
|
-
scaleResolutionDownBy: n.scaleResolutionDownBy,
|
|
646
|
-
maxBitrate: n.maxBitrate
|
|
647
|
-
}
|
|
648
|
-
]
|
|
649
|
-
});
|
|
650
|
-
return o && t && t(s), { isChanged: o, parameters: s };
|
|
651
|
-
}, ie = fe(), ln = async () => ie().catch((e) => {
|
|
652
|
-
i("videoSendingBalancer: error", e);
|
|
653
|
-
}), fn = async (e) => (ie.add(e), ln()), j = async ({
|
|
654
|
-
sender: e,
|
|
655
|
-
scaleResolutionDownBy: n,
|
|
656
|
-
maxBitrate: t,
|
|
657
|
-
onSetParameters: o
|
|
658
|
-
}) => fn(async () => dn(e, { scaleResolutionDownBy: n, maxBitrate: t }, o)), hn = async ({ sender: e, codec: n }, t) => {
|
|
659
|
-
const s = Be(n);
|
|
660
|
-
return j({
|
|
661
|
-
sender: e,
|
|
662
|
-
maxBitrate: s,
|
|
663
|
-
onSetParameters: t,
|
|
664
|
-
scaleResolutionDownBy: 200
|
|
665
|
-
});
|
|
666
|
-
}, k = async ({
|
|
667
|
-
sender: e,
|
|
668
|
-
videoTrack: n,
|
|
669
|
-
codec: t
|
|
670
|
-
}, o) => {
|
|
671
|
-
const c = n.getSettings().width, a = c === void 0 ? we(t) : te(c, t);
|
|
672
|
-
return j({
|
|
673
|
-
sender: e,
|
|
674
|
-
maxBitrate: a,
|
|
675
|
-
onSetParameters: o,
|
|
676
|
-
scaleResolutionDownBy: 1
|
|
677
|
-
});
|
|
678
|
-
}, gn = async ({
|
|
679
|
-
sender: e,
|
|
680
|
-
videoTrack: n,
|
|
681
|
-
resolution: t,
|
|
682
|
-
codec: o
|
|
683
|
-
}, s) => {
|
|
684
|
-
const [r, c] = t.split("x"), { maxBitrate: a, scaleResolutionDownBy: u } = oe({
|
|
685
|
-
videoTrack: n,
|
|
686
|
-
codec: o,
|
|
687
|
-
targetSize: {
|
|
688
|
-
width: Number(r),
|
|
689
|
-
height: Number(c)
|
|
690
|
-
}
|
|
691
|
-
});
|
|
692
|
-
return j({
|
|
693
|
-
sender: e,
|
|
694
|
-
maxBitrate: a,
|
|
695
|
-
onSetParameters: s,
|
|
696
|
-
scaleResolutionDownBy: u
|
|
697
|
-
});
|
|
698
|
-
}, Cn = async ({
|
|
699
|
-
mainCam: e,
|
|
700
|
-
resolutionMainCam: n,
|
|
701
|
-
sender: t,
|
|
702
|
-
videoTrack: o,
|
|
703
|
-
codec: s
|
|
704
|
-
}, r) => {
|
|
705
|
-
switch (e) {
|
|
706
|
-
case w.PAUSE_MAIN_CAM:
|
|
707
|
-
return hn({ sender: t, codec: s }, r);
|
|
708
|
-
case w.RESUME_MAIN_CAM:
|
|
709
|
-
return k({ sender: t, videoTrack: o, codec: s }, r);
|
|
710
|
-
case w.MAX_MAIN_CAM_RESOLUTION:
|
|
711
|
-
return n !== void 0 ? gn(
|
|
712
|
-
{ sender: t, videoTrack: o, codec: s, resolution: n },
|
|
713
|
-
r
|
|
714
|
-
) : k({ sender: t, videoTrack: o, codec: s }, r);
|
|
715
|
-
case w.ADMIN_STOP_MAIN_CAM:
|
|
716
|
-
case w.ADMIN_START_MAIN_CAM:
|
|
717
|
-
case void 0:
|
|
718
|
-
return k({ sender: t, videoTrack: o, codec: s }, r);
|
|
719
|
-
default:
|
|
720
|
-
return k({ sender: t, videoTrack: o, codec: s }, r);
|
|
721
|
-
}
|
|
722
|
-
}, G = {
|
|
723
|
-
isChanged: !1,
|
|
724
|
-
parameters: {
|
|
725
|
-
encodings: [{}],
|
|
726
|
-
transactionId: "0",
|
|
727
|
-
codecs: [],
|
|
728
|
-
headerExtensions: [],
|
|
729
|
-
rtcp: {}
|
|
730
|
-
}
|
|
731
|
-
}, K = async ({
|
|
732
|
-
mainCam: e,
|
|
733
|
-
resolutionMainCam: n,
|
|
734
|
-
connection: t,
|
|
735
|
-
onSetParameters: o,
|
|
736
|
-
ignoreForCodec: s
|
|
737
|
-
}) => {
|
|
738
|
-
const r = t.getSenders(), c = un(r);
|
|
739
|
-
if (!c?.track)
|
|
740
|
-
return G;
|
|
741
|
-
const a = await an(c);
|
|
742
|
-
return ne(a, s) ? G : Cn(
|
|
743
|
-
{
|
|
744
|
-
mainCam: e,
|
|
745
|
-
resolutionMainCam: n,
|
|
746
|
-
sender: c,
|
|
747
|
-
codec: a,
|
|
748
|
-
videoTrack: c.track
|
|
749
|
-
},
|
|
750
|
-
o
|
|
751
|
-
);
|
|
752
|
-
}, An = (e, {
|
|
753
|
-
ignoreForCodec: n,
|
|
754
|
-
onSetParameters: t
|
|
755
|
-
} = {}) => {
|
|
756
|
-
const o = async () => {
|
|
757
|
-
const { connection: u } = e;
|
|
758
|
-
if (!u)
|
|
759
|
-
throw new Error("connection is not exist");
|
|
760
|
-
return K({
|
|
761
|
-
connection: u,
|
|
762
|
-
onSetParameters: t,
|
|
763
|
-
ignoreForCodec: n
|
|
764
|
-
});
|
|
765
|
-
};
|
|
766
|
-
let s = o;
|
|
767
|
-
const r = (u) => {
|
|
768
|
-
s = async () => {
|
|
769
|
-
const { mainCam: l, resolutionMainCam: h } = u, { connection: f } = e;
|
|
770
|
-
if (!f)
|
|
771
|
-
throw new Error("connection is not exist");
|
|
772
|
-
return K({
|
|
773
|
-
mainCam: l,
|
|
774
|
-
resolutionMainCam: h,
|
|
775
|
-
connection: f,
|
|
776
|
-
onSetParameters: t,
|
|
777
|
-
ignoreForCodec: n
|
|
778
|
-
});
|
|
779
|
-
}, s().catch(x);
|
|
780
|
-
};
|
|
781
|
-
return {
|
|
782
|
-
subscribe: () => {
|
|
783
|
-
e.on("api:main-cam-control", r);
|
|
784
|
-
},
|
|
785
|
-
unsubscribe: () => {
|
|
786
|
-
e.off("api:main-cam-control", r);
|
|
787
|
-
},
|
|
788
|
-
balanceByTrack: o,
|
|
789
|
-
resetMainCamControl() {
|
|
790
|
-
s = o;
|
|
791
|
-
},
|
|
792
|
-
async reBalance() {
|
|
793
|
-
return s();
|
|
794
|
-
}
|
|
795
|
-
};
|
|
796
|
-
};
|
|
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 || {});
|
|
797
916
|
export {
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
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,
|
|
804
924
|
Dn as disableDebug,
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
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
|
|
812
932
|
};
|