sip-connector 16.2.0 → 18.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -45
- package/dist/@SipConnector-CFYT0HQB.cjs +1 -0
- package/dist/{@SipConnector-D1YBDd7g.js → @SipConnector-UTHCoMXw.js} +880 -800
- package/dist/ApiManager/__tests-utils__/helpers.d.ts +2 -4
- package/dist/ApiManager/constants.d.ts +1 -2
- package/dist/ApiManager/eventNames.d.ts +1 -2
- package/dist/ApiManager/index.d.ts +1 -0
- package/dist/CallManager/@CallManager.d.ts +7 -6
- package/dist/CallManager/AbstractCallStrategy.d.ts +5 -1
- package/dist/CallManager/MCUCallStrategy.d.ts +1 -0
- package/dist/CallManager/eventNames.d.ts +42 -2
- package/dist/CallManager/index.d.ts +2 -1
- package/dist/CallManager/types.d.ts +5 -4
- package/dist/PresentationManager/types.d.ts +1 -1
- package/dist/SipConnector/@SipConnector.d.ts +4 -1
- package/dist/SipConnector/eventNames.d.ts +1 -1
- package/dist/SipConnectorFacade/index.d.ts +1 -1
- package/dist/StatsPeerConnection/index.d.ts +1 -1
- package/dist/TransceiverManager/@TransceiverManager.d.ts +70 -0
- package/dist/TransceiverManager/index.d.ts +1 -0
- package/dist/TransceiverManager/types.d.ts +11 -0
- package/dist/VideoSendingBalancer/index.d.ts +1 -1
- package/dist/__fixtures__/RTCPeerConnectionMock.d.ts +2 -1
- package/dist/__fixtures__/RTCRtpTransceiverMock.d.ts +16 -0
- package/dist/__fixtures__/eventNames.d.ts +1 -1
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +166 -143
- package/dist/index.cjs +1 -1
- package/dist/index.js +83 -83
- package/package.json +12 -12
- package/dist/@SipConnector-B5FFHZzJ.cjs +0 -1
- /package/dist/SipConnectorFacade/{SipConnectorFacade.d.ts → @SipConnectorFacade.d.ts} +0 -0
- /package/dist/StatsPeerConnection/{StatsPeerConnection.d.ts → @StatsPeerConnection.d.ts} +0 -0
- /package/dist/VideoSendingBalancer/{VideoSendingBalancer.d.ts → @VideoSendingBalancer.d.ts} +0 -0
|
@@ -1,357 +1,19 @@
|
|
|
1
|
-
import { Events as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { SetTimeoutRequest as
|
|
1
|
+
import { Events as w, TypedEvents as H } from "events-constructor";
|
|
2
|
+
import x from "debug";
|
|
3
|
+
import { hasCanceledError as Ne, repeatedCallsAsync as J } from "repeated-calls";
|
|
4
|
+
import { setup as Ae, createActor as Re } from "xstate";
|
|
5
|
+
import { createStackPromises as K } from "stack-promises";
|
|
6
|
+
import { CancelableRequest as Ie } from "@krivega/cancelable-promise";
|
|
7
|
+
import { SetTimeoutRequest as j } from "@krivega/timeout-requester";
|
|
8
8
|
import "ua-parser-js";
|
|
9
9
|
import "sequent-promises";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"peerconnection",
|
|
13
|
-
"connecting",
|
|
14
|
-
"sending",
|
|
15
|
-
"progress",
|
|
16
|
-
"accepted",
|
|
17
|
-
"confirmed",
|
|
18
|
-
"ended",
|
|
19
|
-
"failed",
|
|
20
|
-
"newInfo",
|
|
21
|
-
"newDTMF",
|
|
22
|
-
"presentation:start",
|
|
23
|
-
"presentation:started",
|
|
24
|
-
"presentation:end",
|
|
25
|
-
"presentation:ended",
|
|
26
|
-
"presentation:failed",
|
|
27
|
-
"reinvite",
|
|
28
|
-
"update",
|
|
29
|
-
"refer",
|
|
30
|
-
"replaces",
|
|
31
|
-
"sdp",
|
|
32
|
-
"icecandidate",
|
|
33
|
-
"getusermediafailed",
|
|
34
|
-
"peerconnection:createofferfailed",
|
|
35
|
-
"peerconnection:createanswerfailed",
|
|
36
|
-
"peerconnection:setlocaldescriptionfailed",
|
|
37
|
-
"peerconnection:setremotedescriptionfailed"
|
|
38
|
-
], me = [
|
|
39
|
-
"peerconnection:confirmed",
|
|
40
|
-
"peerconnection:ontrack",
|
|
41
|
-
"ended:fromserver"
|
|
42
|
-
], ne = [
|
|
43
|
-
...te,
|
|
44
|
-
...me
|
|
45
|
-
], pe = (n, e) => {
|
|
46
|
-
n.getVideoTracks().forEach((s) => {
|
|
47
|
-
"contentHint" in s && s.contentHint !== e && (s.contentHint = e);
|
|
48
|
-
});
|
|
49
|
-
}, B = (n, {
|
|
50
|
-
directionVideo: e,
|
|
51
|
-
directionAudio: t,
|
|
52
|
-
contentHint: s
|
|
53
|
-
} = {}) => {
|
|
54
|
-
if (!n || e === "recvonly" && t === "recvonly")
|
|
55
|
-
return;
|
|
56
|
-
const r = t === "recvonly" ? [] : n.getAudioTracks(), i = e === "recvonly" ? [] : n.getVideoTracks(), a = [...r, ...i], o = new MediaStream(a);
|
|
57
|
-
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && pe(o, s), o;
|
|
58
|
-
};
|
|
59
|
-
function Pe(n) {
|
|
60
|
-
return (e) => `sip:${e}@${n}`;
|
|
61
|
-
}
|
|
62
|
-
const fe = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, se = (n) => n.trim().replaceAll(" ", "_"), Oe = fe(1e5, 99999999), ve = (n) => n.some((t) => {
|
|
63
|
-
const { kind: s } = t;
|
|
64
|
-
return s === "video";
|
|
65
|
-
});
|
|
66
|
-
class De {
|
|
67
|
-
isPendingCall = !1;
|
|
68
|
-
isPendingAnswer = !1;
|
|
69
|
-
rtcSession;
|
|
70
|
-
remoteStreams = {};
|
|
71
|
-
events;
|
|
72
|
-
callConfiguration = {};
|
|
73
|
-
constructor(e) {
|
|
74
|
-
this.events = e;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
var re = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(re || {});
|
|
78
|
-
class ye {
|
|
79
|
-
remoteStreams = {};
|
|
80
|
-
reset() {
|
|
81
|
-
this.remoteStreams = {};
|
|
82
|
-
}
|
|
83
|
-
generateStream(e, t) {
|
|
84
|
-
const { id: s } = e, r = this.remoteStreams[s] ?? new MediaStream();
|
|
85
|
-
return t && r.addTrack(t), r.addTrack(e), this.remoteStreams[s] = r, r;
|
|
86
|
-
}
|
|
87
|
-
generateAudioStream(e) {
|
|
88
|
-
const { id: t } = e, s = this.remoteStreams[t] ?? new MediaStream();
|
|
89
|
-
return s.addTrack(e), this.remoteStreams[t] = s, s;
|
|
90
|
-
}
|
|
91
|
-
generateStreams(e) {
|
|
92
|
-
const t = [];
|
|
93
|
-
return e.forEach((s, r) => {
|
|
94
|
-
if (s.kind === "audio")
|
|
95
|
-
return;
|
|
96
|
-
const i = s, a = e[r - 1];
|
|
97
|
-
let o;
|
|
98
|
-
a?.kind === "audio" && (o = a);
|
|
99
|
-
const c = this.generateStream(i, o);
|
|
100
|
-
t.push(c);
|
|
101
|
-
}), t;
|
|
102
|
-
}
|
|
103
|
-
generateAudioStreams(e) {
|
|
104
|
-
return e.map((t) => this.generateAudioStream(t));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
class be extends De {
|
|
108
|
-
remoteStreamsManager = new ye();
|
|
109
|
-
disposers = /* @__PURE__ */ new Set();
|
|
110
|
-
constructor(e) {
|
|
111
|
-
super(e), e.on(E.FAILED, this.handleEnded), e.on(E.ENDED, this.handleEnded);
|
|
112
|
-
}
|
|
113
|
-
get requested() {
|
|
114
|
-
return this.isPendingCall || this.isPendingAnswer;
|
|
115
|
-
}
|
|
116
|
-
get connection() {
|
|
117
|
-
return this.rtcSession?.connection;
|
|
118
|
-
}
|
|
119
|
-
get isCallActive() {
|
|
120
|
-
return this.rtcSession?.isEstablished() === !0;
|
|
121
|
-
}
|
|
122
|
-
get establishedRTCSession() {
|
|
123
|
-
return this.rtcSession?.isEstablished() === !0 ? this.rtcSession : void 0;
|
|
124
|
-
}
|
|
125
|
-
startCall = async (e, t, {
|
|
126
|
-
number: s,
|
|
127
|
-
mediaStream: r,
|
|
128
|
-
extraHeaders: i = [],
|
|
129
|
-
ontrack: a,
|
|
130
|
-
iceServers: o,
|
|
131
|
-
directionVideo: c,
|
|
132
|
-
directionAudio: d,
|
|
133
|
-
contentHint: u,
|
|
134
|
-
offerToReceiveAudio: T = !0,
|
|
135
|
-
offerToReceiveVideo: g = !0,
|
|
136
|
-
degradationPreference: S,
|
|
137
|
-
sendEncodings: m,
|
|
138
|
-
onAddedTransceiver: I
|
|
139
|
-
}) => (this.isPendingCall = !0, new Promise((R, y) => {
|
|
140
|
-
this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(R).catch((b) => {
|
|
141
|
-
y(b);
|
|
142
|
-
}), this.rtcSession = e.call(t(s), {
|
|
143
|
-
extraHeaders: i,
|
|
144
|
-
mediaStream: B(r, {
|
|
145
|
-
directionVideo: c,
|
|
146
|
-
directionAudio: d,
|
|
147
|
-
contentHint: u
|
|
148
|
-
}),
|
|
149
|
-
// необходимо передавать в методе call, чтобы подписаться на события peerconnection,
|
|
150
|
-
// так как в методе call создается RTCSession
|
|
151
|
-
// и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
|
|
152
|
-
eventHandlers: this.events.triggers,
|
|
153
|
-
directionVideo: c,
|
|
154
|
-
directionAudio: d,
|
|
155
|
-
pcConfig: {
|
|
156
|
-
iceServers: o
|
|
157
|
-
},
|
|
158
|
-
rtcOfferConstraints: {
|
|
159
|
-
offerToReceiveAudio: T,
|
|
160
|
-
offerToReceiveVideo: g
|
|
161
|
-
},
|
|
162
|
-
degradationPreference: S,
|
|
163
|
-
sendEncodings: m,
|
|
164
|
-
onAddedTransceiver: I
|
|
165
|
-
});
|
|
166
|
-
}).finally(() => {
|
|
167
|
-
this.isPendingCall = !1;
|
|
168
|
-
}));
|
|
169
|
-
async endCall() {
|
|
170
|
-
const { rtcSession: e } = this;
|
|
171
|
-
if (e && !e.isEnded())
|
|
172
|
-
return e.terminateAsync({
|
|
173
|
-
cause: re.CANCELED
|
|
174
|
-
}).finally(() => {
|
|
175
|
-
this.reset();
|
|
176
|
-
});
|
|
177
|
-
this.reset();
|
|
178
|
-
}
|
|
179
|
-
answerToIncomingCall = async (e, {
|
|
180
|
-
mediaStream: t,
|
|
181
|
-
ontrack: s,
|
|
182
|
-
extraHeaders: r = [],
|
|
183
|
-
iceServers: i,
|
|
184
|
-
directionVideo: a,
|
|
185
|
-
directionAudio: o,
|
|
186
|
-
offerToReceiveAudio: c,
|
|
187
|
-
offerToReceiveVideo: d,
|
|
188
|
-
contentHint: u,
|
|
189
|
-
degradationPreference: T,
|
|
190
|
-
sendEncodings: g,
|
|
191
|
-
onAddedTransceiver: S
|
|
192
|
-
}) => (this.isPendingAnswer = !0, new Promise((m, I) => {
|
|
193
|
-
try {
|
|
194
|
-
const R = e();
|
|
195
|
-
this.rtcSession = R, this.subscribeToSessionEvents(R), this.callConfiguration.answer = !0, this.callConfiguration.number = R.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(m).catch((b) => {
|
|
196
|
-
I(b);
|
|
197
|
-
});
|
|
198
|
-
const y = B(t, {
|
|
199
|
-
directionVideo: a,
|
|
200
|
-
directionAudio: o,
|
|
201
|
-
contentHint: u
|
|
202
|
-
});
|
|
203
|
-
R.answer({
|
|
204
|
-
extraHeaders: r,
|
|
205
|
-
directionVideo: a,
|
|
206
|
-
directionAudio: o,
|
|
207
|
-
mediaStream: y,
|
|
208
|
-
pcConfig: {
|
|
209
|
-
iceServers: i
|
|
210
|
-
},
|
|
211
|
-
rtcOfferConstraints: {
|
|
212
|
-
offerToReceiveAudio: c,
|
|
213
|
-
offerToReceiveVideo: d
|
|
214
|
-
},
|
|
215
|
-
degradationPreference: T,
|
|
216
|
-
sendEncodings: g,
|
|
217
|
-
onAddedTransceiver: S
|
|
218
|
-
});
|
|
219
|
-
} catch (R) {
|
|
220
|
-
I(R);
|
|
221
|
-
}
|
|
222
|
-
}).finally(() => {
|
|
223
|
-
this.isPendingAnswer = !1;
|
|
224
|
-
}));
|
|
225
|
-
getEstablishedRTCSession() {
|
|
226
|
-
return this.rtcSession?.isEstablished() === !0 ? this.rtcSession : void 0;
|
|
227
|
-
}
|
|
228
|
-
getCallConfiguration() {
|
|
229
|
-
return { ...this.callConfiguration };
|
|
230
|
-
}
|
|
231
|
-
getRemoteStreams() {
|
|
232
|
-
if (!this.connection)
|
|
233
|
-
return;
|
|
234
|
-
const t = this.connection.getReceivers().map(({ track: s }) => s);
|
|
235
|
-
return ve(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
|
|
236
|
-
}
|
|
237
|
-
async replaceMediaStream(e, t) {
|
|
238
|
-
if (!this.rtcSession)
|
|
239
|
-
throw new Error("No rtcSession established");
|
|
240
|
-
const { contentHint: s } = t ?? {}, r = B(e, { contentHint: s });
|
|
241
|
-
if (r === void 0)
|
|
242
|
-
throw new Error("No preparedMediaStream");
|
|
243
|
-
return this.rtcSession.replaceMediaStream(r, t);
|
|
244
|
-
}
|
|
245
|
-
async restartIce(e) {
|
|
246
|
-
if (!this.rtcSession)
|
|
247
|
-
throw new Error("No rtcSession established");
|
|
248
|
-
return this.rtcSession.restartIce(e);
|
|
249
|
-
}
|
|
250
|
-
handleCall = async ({
|
|
251
|
-
ontrack: e
|
|
252
|
-
}) => new Promise((t, s) => {
|
|
253
|
-
const r = () => {
|
|
254
|
-
this.events.on(E.PEER_CONNECTION, u), this.events.on(E.CONFIRMED, T);
|
|
255
|
-
}, i = () => {
|
|
256
|
-
this.events.off(E.PEER_CONNECTION, u), this.events.off(E.CONFIRMED, T);
|
|
257
|
-
}, a = () => {
|
|
258
|
-
this.events.on(E.FAILED, c), this.events.on(E.ENDED, c);
|
|
259
|
-
}, o = () => {
|
|
260
|
-
this.events.off(E.FAILED, c), this.events.off(E.ENDED, c);
|
|
261
|
-
}, c = (g) => {
|
|
262
|
-
i(), o(), s(g);
|
|
263
|
-
};
|
|
264
|
-
let d;
|
|
265
|
-
const u = ({ peerconnection: g }) => {
|
|
266
|
-
d = g;
|
|
267
|
-
const S = (m) => {
|
|
268
|
-
this.events.trigger(E.PEER_CONNECTION_ONTRACK, g), e && e(m);
|
|
269
|
-
};
|
|
270
|
-
g.addEventListener("track", S), this.disposers.add(() => {
|
|
271
|
-
g.removeEventListener("track", S);
|
|
272
|
-
});
|
|
273
|
-
}, T = () => {
|
|
274
|
-
d !== void 0 && this.events.trigger(E.PEER_CONNECTION_CONFIRMED, d), i(), o(), t(d);
|
|
275
|
-
};
|
|
276
|
-
r(), a();
|
|
277
|
-
});
|
|
278
|
-
subscribeToSessionEvents(e) {
|
|
279
|
-
this.events.eachTriggers((t, s) => {
|
|
280
|
-
const r = te.find((i) => i === s);
|
|
281
|
-
r && (e.on(r, t), this.disposers.add(() => {
|
|
282
|
-
e.off(r, t);
|
|
283
|
-
}));
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
unsubscribeFromSessionEvents() {
|
|
287
|
-
this.disposers.forEach((e) => {
|
|
288
|
-
e();
|
|
289
|
-
}), this.disposers.clear();
|
|
290
|
-
}
|
|
291
|
-
handleEnded = (e) => {
|
|
292
|
-
const { originator: t } = e;
|
|
293
|
-
t === $.REMOTE && this.events.trigger(E.ENDED_FROM_SERVER, e), this.reset();
|
|
294
|
-
};
|
|
295
|
-
reset = () => {
|
|
296
|
-
delete this.rtcSession, this.remoteStreamsManager.reset(), this.unsubscribeFromSessionEvents(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1;
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
class Ue {
|
|
300
|
-
events;
|
|
301
|
-
strategy;
|
|
302
|
-
constructor(e) {
|
|
303
|
-
this.events = new D(ne), this.strategy = e ?? new be(this.events);
|
|
304
|
-
}
|
|
305
|
-
get requested() {
|
|
306
|
-
return this.strategy.requested;
|
|
307
|
-
}
|
|
308
|
-
get connection() {
|
|
309
|
-
return this.strategy.connection;
|
|
310
|
-
}
|
|
311
|
-
get establishedRTCSession() {
|
|
312
|
-
return this.strategy.establishedRTCSession;
|
|
313
|
-
}
|
|
314
|
-
get isCallActive() {
|
|
315
|
-
return this.strategy.isCallActive;
|
|
316
|
-
}
|
|
317
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
318
|
-
on(e, t) {
|
|
319
|
-
return this.events.on(e, t);
|
|
320
|
-
}
|
|
321
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
322
|
-
once(e, t) {
|
|
323
|
-
return this.events.once(e, t);
|
|
324
|
-
}
|
|
325
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
326
|
-
onceRace(e, t) {
|
|
327
|
-
return this.events.onceRace(e, t);
|
|
328
|
-
}
|
|
329
|
-
async wait(e) {
|
|
330
|
-
return this.events.wait(e);
|
|
331
|
-
}
|
|
332
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
333
|
-
off(e, t) {
|
|
334
|
-
this.events.off(e, t);
|
|
335
|
-
}
|
|
336
|
-
setStrategy(e) {
|
|
337
|
-
this.strategy = e;
|
|
338
|
-
}
|
|
339
|
-
startCall = async (...e) => this.strategy.startCall(...e);
|
|
340
|
-
endCall = async () => this.strategy.endCall();
|
|
341
|
-
answerToIncomingCall = async (...e) => this.strategy.answerToIncomingCall(...e);
|
|
342
|
-
getEstablishedRTCSession = () => this.strategy.getEstablishedRTCSession();
|
|
343
|
-
getCallConfiguration = () => this.strategy.getCallConfiguration();
|
|
344
|
-
getRemoteStreams = () => this.strategy.getRemoteStreams();
|
|
345
|
-
replaceMediaStream = async (...e) => this.strategy.replaceMediaStream(...e);
|
|
346
|
-
restartIce = async (e) => this.strategy.restartIce(e);
|
|
347
|
-
}
|
|
348
|
-
const G = "sip-connector", A = q(G), Tn = () => {
|
|
349
|
-
q.enable(G);
|
|
10
|
+
const q = "sip-connector", E = x(q), Tn = () => {
|
|
11
|
+
x.enable(q);
|
|
350
12
|
}, Sn = () => {
|
|
351
|
-
|
|
352
|
-
},
|
|
353
|
-
var h = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n))(h || {}),
|
|
354
|
-
const
|
|
13
|
+
x.enable(`-${q}`);
|
|
14
|
+
}, _e = "Error decline with 603", me = 1006, Me = (n) => typeof n == "object" && n !== null && "code" in n && n.code === me, pe = (n) => n.message === _e;
|
|
15
|
+
var h = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n))(h || {}), L = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(L || {}), $ = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))($ || {}), v = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.RESTART = "application/vinteo.webrtc.restart", n))(v || {}), M = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(M || {}), P = /* @__PURE__ */ ((n) => (n.PAUSE_MAIN_CAM = "PAUSEMAINCAM", n.RESUME_MAIN_CAM = "RESUMEMAINCAM", n.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", n.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", n.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", n))(P || {}), V = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(V || {}), W = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(W || {}), Pe = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Pe || {}), g = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n.RESTART = "restart", n))(g || {});
|
|
16
|
+
const Z = [
|
|
355
17
|
"participation:accepting-word-request",
|
|
356
18
|
"participation:cancelling-word-request",
|
|
357
19
|
"participant:move-request-to-stream",
|
|
@@ -365,7 +27,6 @@ const ie = [
|
|
|
365
27
|
"participant:removed-from-list-moderators",
|
|
366
28
|
"participant:move-request-to-spectators",
|
|
367
29
|
"participant:move-request-to-participants",
|
|
368
|
-
"participant:move-request-to-spectators-over-sfu",
|
|
369
30
|
"channels",
|
|
370
31
|
"enterRoom",
|
|
371
32
|
"shareState",
|
|
@@ -383,7 +44,7 @@ const ie = [
|
|
|
383
44
|
"restart"
|
|
384
45
|
];
|
|
385
46
|
var _ = /* @__PURE__ */ ((n) => (n.CHANNELS = "channels", n.WEBCAST_STARTED = "WebcastStarted", n.WEBCAST_STOPPED = "WebcastStopped", n.ACCOUNT_CHANGED = "accountChanged", n.ACCOUNT_DELETED = "accountDeleted", n.ADDED_TO_LIST_MODERATORS = "addedToListModerators", n.REMOVED_FROM_LIST_MODERATORS = "removedFromListModerators", n.ACCEPTING_WORD_REQUEST = "ParticipationRequestAccepted", n.CANCELLING_WORD_REQUEST = "ParticipationRequestRejected", n.MOVE_REQUEST_TO_STREAM = "ParticipantMovedToWebcast", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "ConferenceParticipantTokenIssued", n))(_ || {});
|
|
386
|
-
class
|
|
47
|
+
class ve {
|
|
387
48
|
events;
|
|
388
49
|
connectionManager;
|
|
389
50
|
callManager;
|
|
@@ -391,44 +52,44 @@ class $e {
|
|
|
391
52
|
connectionManager: e,
|
|
392
53
|
callManager: t
|
|
393
54
|
}) {
|
|
394
|
-
this.connectionManager = e, this.callManager = t, this.events = new
|
|
55
|
+
this.connectionManager = e, this.callManager = t, this.events = new w(Z), this.subscribe();
|
|
395
56
|
}
|
|
396
57
|
async waitChannels() {
|
|
397
|
-
return this.wait(
|
|
58
|
+
return this.wait(g.CHANNELS);
|
|
398
59
|
}
|
|
399
60
|
async waitSyncMediaState() {
|
|
400
|
-
return this.wait(
|
|
61
|
+
return this.wait(g.ADMIN_FORCE_SYNC_MEDIA_STATE);
|
|
401
62
|
}
|
|
402
63
|
async sendDTMF(e) {
|
|
403
64
|
return new Promise((t, s) => {
|
|
404
|
-
let
|
|
65
|
+
let i;
|
|
405
66
|
try {
|
|
406
|
-
|
|
407
|
-
} catch (
|
|
408
|
-
s(
|
|
67
|
+
i = this.getEstablishedRTCSessionProtected();
|
|
68
|
+
} catch (r) {
|
|
69
|
+
s(r);
|
|
409
70
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}),
|
|
71
|
+
i && (this.callManager.once("newDTMF", ({ originator: r }) => {
|
|
72
|
+
r === "local" && t();
|
|
73
|
+
}), i.sendDTMF(e, {
|
|
413
74
|
duration: 120,
|
|
414
75
|
interToneGap: 600
|
|
415
76
|
}));
|
|
416
77
|
});
|
|
417
78
|
}
|
|
418
79
|
async sendChannels({ inputChannels: e, outputChannels: t }) {
|
|
419
|
-
const s = this.getEstablishedRTCSessionProtected(),
|
|
420
|
-
|
|
421
|
-
|
|
80
|
+
const s = this.getEstablishedRTCSessionProtected(), i = `${h.INPUT_CHANNELS}: ${e}`, r = `${h.OUTPUT_CHANNELS}: ${t}`, a = [
|
|
81
|
+
i,
|
|
82
|
+
r
|
|
422
83
|
];
|
|
423
84
|
return s.sendInfo(M.CHANNELS, void 0, { extraHeaders: a });
|
|
424
85
|
}
|
|
425
86
|
async sendMediaState({ cam: e, mic: t }, s = {}) {
|
|
426
|
-
const
|
|
427
|
-
|
|
87
|
+
const i = this.getEstablishedRTCSessionProtected(), r = `${h.MEDIA_STATE}: currentstate`, a = `${h.MAIN_CAM_STATE}: ${Number(e)}`, o = `${h.MIC_STATE}: ${Number(t)}`, c = [
|
|
88
|
+
r,
|
|
428
89
|
a,
|
|
429
90
|
o
|
|
430
91
|
];
|
|
431
|
-
return
|
|
92
|
+
return i.sendInfo(M.MEDIA_STATE, void 0, {
|
|
432
93
|
noTerminateWhenError: !0,
|
|
433
94
|
...s,
|
|
434
95
|
extraHeaders: c
|
|
@@ -437,10 +98,10 @@ class $e {
|
|
|
437
98
|
async sendStats({
|
|
438
99
|
availableIncomingBitrate: e
|
|
439
100
|
}) {
|
|
440
|
-
const t = this.getEstablishedRTCSessionProtected(),
|
|
101
|
+
const t = this.getEstablishedRTCSessionProtected(), i = [`${h.AVAILABLE_INCOMING_BITRATE}: ${e}`];
|
|
441
102
|
return t.sendInfo(M.STATS, void 0, {
|
|
442
103
|
noTerminateWhenError: !0,
|
|
443
|
-
extraHeaders:
|
|
104
|
+
extraHeaders: i
|
|
444
105
|
});
|
|
445
106
|
}
|
|
446
107
|
async sendRefusalToTurnOn(e, t = {}) {
|
|
@@ -488,9 +149,9 @@ class $e {
|
|
|
488
149
|
noTerminateWhenError: !0,
|
|
489
150
|
...e,
|
|
490
151
|
extraHeaders: s
|
|
491
|
-
}).catch((
|
|
492
|
-
if (
|
|
493
|
-
throw
|
|
152
|
+
}).catch((i) => {
|
|
153
|
+
if (pe(i))
|
|
154
|
+
throw i;
|
|
494
155
|
});
|
|
495
156
|
}
|
|
496
157
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
@@ -534,7 +195,7 @@ class $e {
|
|
|
534
195
|
this.handleNotify(s);
|
|
535
196
|
}
|
|
536
197
|
} catch (t) {
|
|
537
|
-
|
|
198
|
+
E("error parse notify", t);
|
|
538
199
|
}
|
|
539
200
|
};
|
|
540
201
|
handleNotify = (e) => {
|
|
@@ -593,56 +254,56 @@ class $e {
|
|
|
593
254
|
break;
|
|
594
255
|
}
|
|
595
256
|
default:
|
|
596
|
-
|
|
257
|
+
E("unknown cmd", e);
|
|
597
258
|
}
|
|
598
259
|
};
|
|
599
260
|
handleNewInfo = (e) => {
|
|
600
261
|
const { originator: t } = e;
|
|
601
|
-
if (t !==
|
|
262
|
+
if (t !== "remote")
|
|
602
263
|
return;
|
|
603
|
-
const { request: s } = e, r =
|
|
264
|
+
const { request: s } = e, i = s, r = i.getHeader(h.CONTENT_TYPE);
|
|
604
265
|
if (r !== void 0)
|
|
605
266
|
switch (r) {
|
|
606
|
-
case
|
|
607
|
-
this.triggerEnterRoom(
|
|
267
|
+
case v.ENTER_ROOM: {
|
|
268
|
+
this.triggerEnterRoom(i), this.maybeTriggerChannels(i);
|
|
608
269
|
break;
|
|
609
270
|
}
|
|
610
|
-
case
|
|
611
|
-
this.maybeHandleNotify(
|
|
271
|
+
case v.NOTIFY: {
|
|
272
|
+
this.maybeHandleNotify(i);
|
|
612
273
|
break;
|
|
613
274
|
}
|
|
614
|
-
case
|
|
615
|
-
this.triggerShareState(
|
|
275
|
+
case v.SHARE_STATE: {
|
|
276
|
+
this.triggerShareState(i);
|
|
616
277
|
break;
|
|
617
278
|
}
|
|
618
|
-
case
|
|
619
|
-
this.triggerMainCamControl(
|
|
279
|
+
case v.MAIN_CAM: {
|
|
280
|
+
this.triggerMainCamControl(i);
|
|
620
281
|
break;
|
|
621
282
|
}
|
|
622
|
-
case
|
|
623
|
-
this.triggerMicControl(
|
|
283
|
+
case v.MIC: {
|
|
284
|
+
this.triggerMicControl(i);
|
|
624
285
|
break;
|
|
625
286
|
}
|
|
626
|
-
case
|
|
627
|
-
this.triggerUseLicense(
|
|
287
|
+
case v.USE_LICENSE: {
|
|
288
|
+
this.triggerUseLicense(i);
|
|
628
289
|
break;
|
|
629
290
|
}
|
|
630
|
-
case
|
|
631
|
-
this.maybeTriggerParticipantMoveRequest(
|
|
291
|
+
case v.PARTICIPANT_STATE: {
|
|
292
|
+
this.maybeTriggerParticipantMoveRequest(i);
|
|
632
293
|
break;
|
|
633
294
|
}
|
|
634
|
-
case
|
|
635
|
-
this.triggerRestart(
|
|
295
|
+
case v.RESTART: {
|
|
296
|
+
this.triggerRestart(i);
|
|
636
297
|
break;
|
|
637
298
|
}
|
|
638
299
|
}
|
|
639
300
|
};
|
|
640
301
|
triggerChannelsNotify = (e) => {
|
|
641
|
-
const t = e.input, s = e.output,
|
|
302
|
+
const t = e.input, s = e.output, i = {
|
|
642
303
|
inputChannels: t,
|
|
643
304
|
outputChannels: s
|
|
644
305
|
};
|
|
645
|
-
this.events.trigger(
|
|
306
|
+
this.events.trigger(g.CHANNELS_NOTIFY, i);
|
|
646
307
|
};
|
|
647
308
|
triggerWebcastStartedNotify = ({
|
|
648
309
|
body: { conference: e, type: t }
|
|
@@ -651,7 +312,7 @@ class $e {
|
|
|
651
312
|
conference: e,
|
|
652
313
|
type: t
|
|
653
314
|
};
|
|
654
|
-
this.events.trigger(
|
|
315
|
+
this.events.trigger(g.WEBCAST_STARTED, s);
|
|
655
316
|
};
|
|
656
317
|
triggerWebcastStoppedNotify = ({
|
|
657
318
|
body: { conference: e, type: t }
|
|
@@ -660,7 +321,7 @@ class $e {
|
|
|
660
321
|
conference: e,
|
|
661
322
|
type: t
|
|
662
323
|
};
|
|
663
|
-
this.events.trigger(
|
|
324
|
+
this.events.trigger(g.WEBCAST_STOPPED, s);
|
|
664
325
|
};
|
|
665
326
|
triggerAddedToListModeratorsNotify = ({
|
|
666
327
|
conference: e
|
|
@@ -669,7 +330,7 @@ class $e {
|
|
|
669
330
|
conference: e
|
|
670
331
|
};
|
|
671
332
|
this.events.trigger(
|
|
672
|
-
|
|
333
|
+
g.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
|
|
673
334
|
t
|
|
674
335
|
);
|
|
675
336
|
};
|
|
@@ -680,7 +341,7 @@ class $e {
|
|
|
680
341
|
conference: e
|
|
681
342
|
};
|
|
682
343
|
this.events.trigger(
|
|
683
|
-
|
|
344
|
+
g.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
|
|
684
345
|
t
|
|
685
346
|
);
|
|
686
347
|
};
|
|
@@ -690,7 +351,7 @@ class $e {
|
|
|
690
351
|
const t = {
|
|
691
352
|
conference: e
|
|
692
353
|
};
|
|
693
|
-
this.events.trigger(
|
|
354
|
+
this.events.trigger(g.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
|
|
694
355
|
};
|
|
695
356
|
triggerParticipationCancellingWordRequest = ({
|
|
696
357
|
body: { conference: e }
|
|
@@ -698,7 +359,7 @@ class $e {
|
|
|
698
359
|
const t = {
|
|
699
360
|
conference: e
|
|
700
361
|
};
|
|
701
|
-
this.events.trigger(
|
|
362
|
+
this.events.trigger(g.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
|
|
702
363
|
};
|
|
703
364
|
triggerParticipantMoveRequestToStream = ({
|
|
704
365
|
body: { conference: e }
|
|
@@ -706,132 +367,470 @@ class $e {
|
|
|
706
367
|
const t = {
|
|
707
368
|
conference: e
|
|
708
369
|
};
|
|
709
|
-
this.events.trigger(
|
|
370
|
+
this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
|
|
710
371
|
};
|
|
711
372
|
triggerAccountChangedNotify = () => {
|
|
712
|
-
this.events.trigger(
|
|
373
|
+
this.events.trigger(g.ACCOUNT_CHANGED, void 0);
|
|
713
374
|
};
|
|
714
375
|
triggerAccountDeletedNotify = () => {
|
|
715
|
-
this.events.trigger(
|
|
376
|
+
this.events.trigger(g.ACCOUNT_DELETED, void 0);
|
|
716
377
|
};
|
|
717
378
|
triggerConferenceParticipantTokenIssued = ({
|
|
718
379
|
body: { conference: e, participant: t, jwt: s }
|
|
719
380
|
}) => {
|
|
720
|
-
const
|
|
381
|
+
const i = {
|
|
721
382
|
conference: e,
|
|
722
383
|
participant: t,
|
|
723
384
|
jwt: s
|
|
724
385
|
};
|
|
725
386
|
this.events.trigger(
|
|
726
|
-
|
|
727
|
-
|
|
387
|
+
g.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
|
|
388
|
+
i
|
|
728
389
|
);
|
|
729
390
|
};
|
|
730
391
|
maybeTriggerChannels = (e) => {
|
|
731
392
|
const t = e.getHeader(h.INPUT_CHANNELS), s = e.getHeader(h.OUTPUT_CHANNELS);
|
|
732
393
|
if (t && s) {
|
|
733
|
-
const
|
|
394
|
+
const i = {
|
|
734
395
|
inputChannels: t,
|
|
735
396
|
outputChannels: s
|
|
736
397
|
};
|
|
737
|
-
this.events.trigger(
|
|
398
|
+
this.events.trigger(g.CHANNELS, i);
|
|
738
399
|
}
|
|
739
400
|
};
|
|
740
401
|
triggerEnterRoom = (e) => {
|
|
741
402
|
const t = e.getHeader(h.CONTENT_ENTER_ROOM), s = e.getHeader(h.PARTICIPANT_NAME);
|
|
742
|
-
this.events.trigger(
|
|
403
|
+
this.events.trigger(g.ENTER_ROOM, { room: t, participantName: s });
|
|
743
404
|
};
|
|
744
405
|
triggerShareState = (e) => {
|
|
745
406
|
const t = e.getHeader(h.CONTENT_SHARE_STATE);
|
|
746
407
|
if (t !== void 0)
|
|
747
408
|
switch (t) {
|
|
748
|
-
case
|
|
749
|
-
this.events.trigger(
|
|
409
|
+
case L.AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
410
|
+
this.events.trigger(g.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
|
|
750
411
|
break;
|
|
751
412
|
}
|
|
752
|
-
case
|
|
753
|
-
this.events.trigger(
|
|
413
|
+
case L.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
414
|
+
this.events.trigger(g.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
|
|
754
415
|
break;
|
|
755
416
|
}
|
|
756
|
-
case
|
|
757
|
-
this.events.trigger(
|
|
417
|
+
case L.MUST_STOP_PRESENTATION: {
|
|
418
|
+
this.events.trigger(g.MUST_STOP_PRESENTATION, void 0);
|
|
758
419
|
break;
|
|
759
420
|
}
|
|
760
421
|
}
|
|
761
422
|
};
|
|
762
423
|
maybeTriggerParticipantMoveRequest = (e) => {
|
|
763
424
|
const t = e.getHeader(h.CONTENT_PARTICIPANT_STATE);
|
|
764
|
-
t ===
|
|
425
|
+
t === $.SPECTATOR && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === $.PARTICIPANT && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0);
|
|
765
426
|
};
|
|
766
427
|
triggerMainCamControl = (e) => {
|
|
767
|
-
const t = e.getHeader(h.MAIN_CAM), s = e.getHeader(h.MEDIA_SYNC),
|
|
428
|
+
const t = e.getHeader(h.MAIN_CAM), s = e.getHeader(h.MEDIA_SYNC), i = s === W.ADMIN_SYNC_FORCED;
|
|
768
429
|
if (t === P.ADMIN_START_MAIN_CAM) {
|
|
769
|
-
this.events.trigger(
|
|
430
|
+
this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: i });
|
|
770
431
|
return;
|
|
771
432
|
}
|
|
772
|
-
if (t === P.ADMIN_STOP_MAIN_CAM) {
|
|
773
|
-
this.events.trigger(
|
|
433
|
+
if (t === P.ADMIN_STOP_MAIN_CAM) {
|
|
434
|
+
this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
(t === P.RESUME_MAIN_CAM || t === P.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
|
|
438
|
+
const r = e.getHeader(h.MAIN_CAM_RESOLUTION);
|
|
439
|
+
this.events.trigger(g.MAIN_CAM_CONTROL, {
|
|
440
|
+
mainCam: t,
|
|
441
|
+
resolutionMainCam: r
|
|
442
|
+
});
|
|
443
|
+
};
|
|
444
|
+
triggerMicControl = (e) => {
|
|
445
|
+
const t = e.getHeader(h.MIC), i = e.getHeader(h.MEDIA_SYNC) === W.ADMIN_SYNC_FORCED;
|
|
446
|
+
t === V.ADMIN_START_MIC ? this.events.trigger(g.ADMIN_START_MIC, { isSyncForced: i }) : t === V.ADMIN_STOP_MIC && this.events.trigger(g.ADMIN_STOP_MIC, { isSyncForced: i });
|
|
447
|
+
};
|
|
448
|
+
triggerUseLicense = (e) => {
|
|
449
|
+
const t = e.getHeader(h.CONTENT_USE_LICENSE);
|
|
450
|
+
this.events.trigger(g.USE_LICENSE, t);
|
|
451
|
+
};
|
|
452
|
+
triggerRestart = (e) => {
|
|
453
|
+
const t = e.getHeader(
|
|
454
|
+
h.TRACKS_DIRECTION
|
|
455
|
+
), s = Number(
|
|
456
|
+
e.getHeader(h.AUDIO_TRACK_COUNT)
|
|
457
|
+
), i = Number(
|
|
458
|
+
e.getHeader(h.VIDEO_TRACK_COUNT)
|
|
459
|
+
), r = { tracksDirection: t, audioTrackCount: s, videoTrackCount: i };
|
|
460
|
+
this.events.trigger(g.RESTART, r);
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
var N = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n))(N || {}), fe = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(fe || {});
|
|
464
|
+
const ee = [
|
|
465
|
+
"peerconnection",
|
|
466
|
+
"connecting",
|
|
467
|
+
"sending",
|
|
468
|
+
"progress",
|
|
469
|
+
"accepted",
|
|
470
|
+
"confirmed",
|
|
471
|
+
"ended",
|
|
472
|
+
"failed",
|
|
473
|
+
"newInfo",
|
|
474
|
+
"newDTMF",
|
|
475
|
+
"presentation:start",
|
|
476
|
+
"presentation:started",
|
|
477
|
+
"presentation:end",
|
|
478
|
+
"presentation:ended",
|
|
479
|
+
"presentation:failed",
|
|
480
|
+
"reinvite",
|
|
481
|
+
"update",
|
|
482
|
+
"refer",
|
|
483
|
+
"replaces",
|
|
484
|
+
"sdp",
|
|
485
|
+
"icecandidate",
|
|
486
|
+
"getusermediafailed",
|
|
487
|
+
"peerconnection:createofferfailed",
|
|
488
|
+
"peerconnection:createanswerfailed",
|
|
489
|
+
"peerconnection:setlocaldescriptionfailed",
|
|
490
|
+
"peerconnection:setremotedescriptionfailed"
|
|
491
|
+
], Oe = [
|
|
492
|
+
"peerconnection:confirmed",
|
|
493
|
+
"peerconnection:ontrack",
|
|
494
|
+
"ended:fromserver"
|
|
495
|
+
], te = [
|
|
496
|
+
...ee,
|
|
497
|
+
...Oe
|
|
498
|
+
], De = (n, e) => {
|
|
499
|
+
n.getVideoTracks().forEach((s) => {
|
|
500
|
+
"contentHint" in s && s.contentHint !== e && (s.contentHint = e);
|
|
501
|
+
});
|
|
502
|
+
}, B = (n, {
|
|
503
|
+
directionVideo: e,
|
|
504
|
+
directionAudio: t,
|
|
505
|
+
contentHint: s
|
|
506
|
+
} = {}) => {
|
|
507
|
+
if (!n || e === "recvonly" && t === "recvonly")
|
|
508
|
+
return;
|
|
509
|
+
const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
|
|
510
|
+
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && De(o, s), o;
|
|
511
|
+
};
|
|
512
|
+
function ye(n) {
|
|
513
|
+
return (e) => `sip:${e}@${n}`;
|
|
514
|
+
}
|
|
515
|
+
const be = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, ne = (n) => n.trim().replaceAll(" ", "_"), we = be(1e5, 99999999), Ue = (n) => n.some((t) => {
|
|
516
|
+
const { kind: s } = t;
|
|
517
|
+
return s === "video";
|
|
518
|
+
});
|
|
519
|
+
class Le {
|
|
520
|
+
isPendingCall = !1;
|
|
521
|
+
isPendingAnswer = !1;
|
|
522
|
+
rtcSession;
|
|
523
|
+
remoteStreams = {};
|
|
524
|
+
events;
|
|
525
|
+
callConfiguration = {};
|
|
526
|
+
constructor(e) {
|
|
527
|
+
this.events = e;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
var se = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(se || {});
|
|
531
|
+
class Be {
|
|
532
|
+
remoteStreams = {};
|
|
533
|
+
reset() {
|
|
534
|
+
this.remoteStreams = {};
|
|
535
|
+
}
|
|
536
|
+
generateStream(e, t) {
|
|
537
|
+
const { id: s } = e, i = this.remoteStreams[s] ?? new MediaStream();
|
|
538
|
+
return t && i.addTrack(t), i.addTrack(e), this.remoteStreams[s] = i, i;
|
|
539
|
+
}
|
|
540
|
+
generateAudioStream(e) {
|
|
541
|
+
const { id: t } = e, s = this.remoteStreams[t] ?? new MediaStream();
|
|
542
|
+
return s.addTrack(e), this.remoteStreams[t] = s, s;
|
|
543
|
+
}
|
|
544
|
+
generateStreams(e) {
|
|
545
|
+
const t = [];
|
|
546
|
+
return e.forEach((s, i) => {
|
|
547
|
+
if (s.kind === "audio")
|
|
548
|
+
return;
|
|
549
|
+
const r = s, a = e[i - 1];
|
|
550
|
+
let o;
|
|
551
|
+
a?.kind === "audio" && (o = a);
|
|
552
|
+
const c = this.generateStream(r, o);
|
|
553
|
+
t.push(c);
|
|
554
|
+
}), t;
|
|
555
|
+
}
|
|
556
|
+
generateAudioStreams(e) {
|
|
557
|
+
return e.map((t) => this.generateAudioStream(t));
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
class ke extends Le {
|
|
561
|
+
remoteStreamsManager = new Be();
|
|
562
|
+
disposers = /* @__PURE__ */ new Set();
|
|
563
|
+
constructor(e) {
|
|
564
|
+
super(e), e.on(N.FAILED, this.handleEnded), e.on(N.ENDED, this.handleEnded);
|
|
565
|
+
}
|
|
566
|
+
get requested() {
|
|
567
|
+
return this.isPendingCall || this.isPendingAnswer;
|
|
568
|
+
}
|
|
569
|
+
get connection() {
|
|
570
|
+
return this.rtcSession?.connection;
|
|
571
|
+
}
|
|
572
|
+
get isCallActive() {
|
|
573
|
+
return this.rtcSession?.isEstablished() === !0;
|
|
574
|
+
}
|
|
575
|
+
get establishedRTCSession() {
|
|
576
|
+
return this.rtcSession?.isEstablished() === !0 ? this.rtcSession : void 0;
|
|
577
|
+
}
|
|
578
|
+
startCall = async (e, t, {
|
|
579
|
+
number: s,
|
|
580
|
+
mediaStream: i,
|
|
581
|
+
extraHeaders: r = [],
|
|
582
|
+
ontrack: a,
|
|
583
|
+
iceServers: o,
|
|
584
|
+
directionVideo: c,
|
|
585
|
+
directionAudio: d,
|
|
586
|
+
contentHint: u,
|
|
587
|
+
offerToReceiveAudio: T = !0,
|
|
588
|
+
offerToReceiveVideo: l = !0,
|
|
589
|
+
degradationPreference: S,
|
|
590
|
+
sendEncodings: m,
|
|
591
|
+
onAddedTransceiver: I
|
|
592
|
+
}) => (this.isPendingCall = !0, new Promise((R, D) => {
|
|
593
|
+
this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(R).catch((k) => {
|
|
594
|
+
D(k);
|
|
595
|
+
}), this.rtcSession = e.call(t(s), {
|
|
596
|
+
mediaStream: B(i, {
|
|
597
|
+
directionVideo: c,
|
|
598
|
+
directionAudio: d,
|
|
599
|
+
contentHint: u
|
|
600
|
+
}),
|
|
601
|
+
pcConfig: {
|
|
602
|
+
iceServers: o
|
|
603
|
+
},
|
|
604
|
+
rtcOfferConstraints: {
|
|
605
|
+
offerToReceiveAudio: T,
|
|
606
|
+
offerToReceiveVideo: l
|
|
607
|
+
},
|
|
608
|
+
// необходимо передавать в методе call, чтобы подписаться на события peerconnection,
|
|
609
|
+
// так как в методе call создается RTCSession
|
|
610
|
+
// и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
|
|
611
|
+
eventHandlers: this.events.triggers,
|
|
612
|
+
extraHeaders: r,
|
|
613
|
+
directionVideo: c,
|
|
614
|
+
directionAudio: d,
|
|
615
|
+
degradationPreference: S,
|
|
616
|
+
sendEncodings: m,
|
|
617
|
+
onAddedTransceiver: I
|
|
618
|
+
});
|
|
619
|
+
}).finally(() => {
|
|
620
|
+
this.isPendingCall = !1;
|
|
621
|
+
}));
|
|
622
|
+
async endCall() {
|
|
623
|
+
const { rtcSession: e } = this;
|
|
624
|
+
if (e && !e.isEnded())
|
|
625
|
+
return e.terminateAsync({
|
|
626
|
+
cause: se.CANCELED
|
|
627
|
+
}).finally(() => {
|
|
628
|
+
this.reset();
|
|
629
|
+
});
|
|
630
|
+
this.reset();
|
|
631
|
+
}
|
|
632
|
+
answerToIncomingCall = async (e, {
|
|
633
|
+
mediaStream: t,
|
|
634
|
+
ontrack: s,
|
|
635
|
+
extraHeaders: i = [],
|
|
636
|
+
iceServers: r,
|
|
637
|
+
directionVideo: a,
|
|
638
|
+
directionAudio: o,
|
|
639
|
+
offerToReceiveAudio: c,
|
|
640
|
+
offerToReceiveVideo: d,
|
|
641
|
+
contentHint: u,
|
|
642
|
+
degradationPreference: T,
|
|
643
|
+
sendEncodings: l,
|
|
644
|
+
onAddedTransceiver: S
|
|
645
|
+
}) => (this.isPendingAnswer = !0, new Promise((m, I) => {
|
|
646
|
+
try {
|
|
647
|
+
const R = e();
|
|
648
|
+
this.rtcSession = R, this.subscribeToSessionEvents(R), this.callConfiguration.answer = !0, this.callConfiguration.number = R.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(m).catch((D) => {
|
|
649
|
+
I(D);
|
|
650
|
+
}), R.answer({
|
|
651
|
+
pcConfig: {
|
|
652
|
+
iceServers: r
|
|
653
|
+
},
|
|
654
|
+
rtcOfferConstraints: {
|
|
655
|
+
offerToReceiveAudio: c,
|
|
656
|
+
offerToReceiveVideo: d
|
|
657
|
+
},
|
|
658
|
+
mediaStream: B(t, {
|
|
659
|
+
directionVideo: a,
|
|
660
|
+
directionAudio: o,
|
|
661
|
+
contentHint: u
|
|
662
|
+
}),
|
|
663
|
+
extraHeaders: i,
|
|
664
|
+
directionVideo: a,
|
|
665
|
+
directionAudio: o,
|
|
666
|
+
degradationPreference: T,
|
|
667
|
+
sendEncodings: l,
|
|
668
|
+
onAddedTransceiver: S
|
|
669
|
+
});
|
|
670
|
+
} catch (R) {
|
|
671
|
+
I(R);
|
|
672
|
+
}
|
|
673
|
+
}).finally(() => {
|
|
674
|
+
this.isPendingAnswer = !1;
|
|
675
|
+
}));
|
|
676
|
+
getEstablishedRTCSession() {
|
|
677
|
+
return this.rtcSession?.isEstablished() === !0 ? this.rtcSession : void 0;
|
|
678
|
+
}
|
|
679
|
+
getCallConfiguration() {
|
|
680
|
+
return { ...this.callConfiguration };
|
|
681
|
+
}
|
|
682
|
+
getRemoteStreams() {
|
|
683
|
+
if (!this.connection)
|
|
774
684
|
return;
|
|
775
|
-
}
|
|
776
|
-
(t
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
685
|
+
const t = this.connection.getReceivers().map(({ track: s }) => s);
|
|
686
|
+
return Ue(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
|
|
687
|
+
}
|
|
688
|
+
async replaceMediaStream(e, t) {
|
|
689
|
+
if (!this.rtcSession)
|
|
690
|
+
throw new Error("No rtcSession established");
|
|
691
|
+
const { contentHint: s } = t ?? {}, i = B(e, { contentHint: s });
|
|
692
|
+
if (i === void 0)
|
|
693
|
+
throw new Error("No preparedMediaStream");
|
|
694
|
+
return this.rtcSession.replaceMediaStream(i, t);
|
|
695
|
+
}
|
|
696
|
+
async restartIce(e) {
|
|
697
|
+
if (!this.rtcSession)
|
|
698
|
+
throw new Error("No rtcSession established");
|
|
699
|
+
return this.rtcSession.restartIce(e);
|
|
700
|
+
}
|
|
701
|
+
async addTransceiver(e, t) {
|
|
702
|
+
if (!this.rtcSession)
|
|
703
|
+
throw new Error("No rtcSession established");
|
|
704
|
+
return this.rtcSession.addTransceiver(e, t);
|
|
705
|
+
}
|
|
706
|
+
handleCall = async ({
|
|
707
|
+
ontrack: e
|
|
708
|
+
}) => new Promise((t, s) => {
|
|
709
|
+
const i = () => {
|
|
710
|
+
this.events.on(N.PEER_CONNECTION, u), this.events.on(N.CONFIRMED, T);
|
|
711
|
+
}, r = () => {
|
|
712
|
+
this.events.off(N.PEER_CONNECTION, u), this.events.off(N.CONFIRMED, T);
|
|
713
|
+
}, a = () => {
|
|
714
|
+
this.events.on(N.FAILED, c), this.events.on(N.ENDED, c);
|
|
715
|
+
}, o = () => {
|
|
716
|
+
this.events.off(N.FAILED, c), this.events.off(N.ENDED, c);
|
|
717
|
+
}, c = (l) => {
|
|
718
|
+
r(), o(), s(l);
|
|
719
|
+
};
|
|
720
|
+
let d;
|
|
721
|
+
const u = ({ peerconnection: l }) => {
|
|
722
|
+
d = l;
|
|
723
|
+
const S = (m) => {
|
|
724
|
+
this.events.trigger(N.PEER_CONNECTION_ONTRACK, m), e && e(m);
|
|
725
|
+
};
|
|
726
|
+
l.addEventListener("track", S), this.disposers.add(() => {
|
|
727
|
+
l.removeEventListener("track", S);
|
|
728
|
+
});
|
|
729
|
+
}, T = () => {
|
|
730
|
+
d !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, d), r(), o(), t(d);
|
|
731
|
+
};
|
|
732
|
+
i(), a();
|
|
733
|
+
});
|
|
734
|
+
subscribeToSessionEvents(e) {
|
|
735
|
+
this.events.eachTriggers((t, s) => {
|
|
736
|
+
const i = ee.find((r) => r === s);
|
|
737
|
+
i && (e.on(i, t), this.disposers.add(() => {
|
|
738
|
+
e.off(i, t);
|
|
739
|
+
}));
|
|
781
740
|
});
|
|
741
|
+
}
|
|
742
|
+
unsubscribeFromSessionEvents() {
|
|
743
|
+
this.disposers.forEach((e) => {
|
|
744
|
+
e();
|
|
745
|
+
}), this.disposers.clear();
|
|
746
|
+
}
|
|
747
|
+
handleEnded = (e) => {
|
|
748
|
+
const { originator: t } = e;
|
|
749
|
+
t === "remote" && this.events.trigger(N.ENDED_FROM_SERVER, e), this.reset();
|
|
782
750
|
};
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
t === W.ADMIN_START_MIC ? this.events.trigger(l.ADMIN_START_MIC, { isSyncForced: r }) : t === W.ADMIN_STOP_MIC && this.events.trigger(l.ADMIN_STOP_MIC, { isSyncForced: r });
|
|
786
|
-
};
|
|
787
|
-
triggerUseLicense = (e) => {
|
|
788
|
-
const t = e.getHeader(h.CONTENT_USE_LICENSE);
|
|
789
|
-
this.events.trigger(l.USE_LICENSE, t);
|
|
790
|
-
};
|
|
791
|
-
triggerRestart = (e) => {
|
|
792
|
-
const t = e.getHeader(
|
|
793
|
-
h.TRACKS_DIRECTION
|
|
794
|
-
), s = Number(
|
|
795
|
-
e.getHeader(h.AUDIO_TRACK_COUNT)
|
|
796
|
-
), r = Number(
|
|
797
|
-
e.getHeader(h.VIDEO_TRACK_COUNT)
|
|
798
|
-
), i = { tracksDirection: t, audioTrackCount: s, videoTrackCount: r };
|
|
799
|
-
this.events.trigger(l.RESTART, i);
|
|
751
|
+
reset = () => {
|
|
752
|
+
delete this.rtcSession, this.remoteStreamsManager.reset(), this.unsubscribeFromSessionEvents(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1;
|
|
800
753
|
};
|
|
801
754
|
}
|
|
802
|
-
|
|
755
|
+
class Fe {
|
|
756
|
+
events;
|
|
757
|
+
strategy;
|
|
758
|
+
constructor(e) {
|
|
759
|
+
this.events = new H(te), this.strategy = e ?? new ke(this.events);
|
|
760
|
+
}
|
|
761
|
+
get requested() {
|
|
762
|
+
return this.strategy.requested;
|
|
763
|
+
}
|
|
764
|
+
get connection() {
|
|
765
|
+
return this.strategy.connection;
|
|
766
|
+
}
|
|
767
|
+
get establishedRTCSession() {
|
|
768
|
+
return this.strategy.establishedRTCSession;
|
|
769
|
+
}
|
|
770
|
+
get isCallActive() {
|
|
771
|
+
return this.strategy.isCallActive;
|
|
772
|
+
}
|
|
773
|
+
on(e, t) {
|
|
774
|
+
return this.events.on(e, t);
|
|
775
|
+
}
|
|
776
|
+
once(e, t) {
|
|
777
|
+
return this.events.once(e, t);
|
|
778
|
+
}
|
|
779
|
+
onceRace(e, t) {
|
|
780
|
+
return this.events.onceRace(e, t);
|
|
781
|
+
}
|
|
782
|
+
async wait(e) {
|
|
783
|
+
return this.events.wait(e);
|
|
784
|
+
}
|
|
785
|
+
off(e, t) {
|
|
786
|
+
this.events.off(e, t);
|
|
787
|
+
}
|
|
788
|
+
setStrategy(e) {
|
|
789
|
+
this.strategy = e;
|
|
790
|
+
}
|
|
791
|
+
startCall = async (...e) => this.strategy.startCall(...e);
|
|
792
|
+
endCall = async () => this.strategy.endCall();
|
|
793
|
+
answerToIncomingCall = async (...e) => this.strategy.answerToIncomingCall(...e);
|
|
794
|
+
getEstablishedRTCSession = () => this.strategy.getEstablishedRTCSession();
|
|
795
|
+
getCallConfiguration = () => this.strategy.getCallConfiguration();
|
|
796
|
+
getRemoteStreams = () => this.strategy.getRemoteStreams();
|
|
797
|
+
addTransceiver = async (...e) => this.strategy.addTransceiver(...e);
|
|
798
|
+
replaceMediaStream = async (...e) => this.strategy.replaceMediaStream(...e);
|
|
799
|
+
restartIce = async (e) => this.strategy.restartIce(e);
|
|
800
|
+
}
|
|
801
|
+
const $e = (n, e) => (n.degradationPreference = e.degradationPreference, n), Ve = (n, e) => {
|
|
803
802
|
n.encodings ??= [];
|
|
804
803
|
for (let t = n.encodings.length; t < e; t += 1)
|
|
805
804
|
n.encodings.push({});
|
|
806
805
|
return n;
|
|
807
|
-
},
|
|
808
|
-
if (
|
|
806
|
+
}, ie = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, We = ie(), He = (n, e) => {
|
|
807
|
+
if (We(n, e))
|
|
809
808
|
return n;
|
|
810
|
-
},
|
|
811
|
-
const t = n.maxBitrate, s =
|
|
809
|
+
}, xe = (n, e) => {
|
|
810
|
+
const t = n.maxBitrate, s = He(e, t);
|
|
812
811
|
return s !== void 0 && (n.maxBitrate = s), n;
|
|
813
|
-
},
|
|
814
|
-
|
|
815
|
-
),
|
|
816
|
-
const t = n === void 0 ? void 0 : Math.max(n,
|
|
817
|
-
if (t !== void 0 &&
|
|
812
|
+
}, re = 1, qe = ie(
|
|
813
|
+
re
|
|
814
|
+
), Ge = (n, e) => {
|
|
815
|
+
const t = n === void 0 ? void 0 : Math.max(n, re);
|
|
816
|
+
if (t !== void 0 && qe(
|
|
818
817
|
t,
|
|
819
818
|
e
|
|
820
819
|
))
|
|
821
820
|
return t;
|
|
822
|
-
},
|
|
823
|
-
const t = n.scaleResolutionDownBy, s =
|
|
821
|
+
}, Qe = (n, e) => {
|
|
822
|
+
const t = n.scaleResolutionDownBy, s = Ge(
|
|
824
823
|
e,
|
|
825
824
|
t
|
|
826
825
|
);
|
|
827
826
|
return s !== void 0 && (n.scaleResolutionDownBy = s), n;
|
|
828
|
-
},
|
|
827
|
+
}, Ye = (n, e) => {
|
|
829
828
|
const t = e.encodings?.length ?? 0;
|
|
830
|
-
return
|
|
831
|
-
const
|
|
832
|
-
|
|
829
|
+
return Ve(n, t), n.encodings.forEach((s, i) => {
|
|
830
|
+
const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
|
|
831
|
+
xe(s, a), Qe(s, o);
|
|
833
832
|
}), n;
|
|
834
|
-
},
|
|
833
|
+
}, ze = (n, e) => {
|
|
835
834
|
if (n.codecs?.length !== e.codecs?.length)
|
|
836
835
|
return !0;
|
|
837
836
|
for (let t = 0; t < (n.codecs?.length ?? 0); t++)
|
|
@@ -848,15 +847,15 @@ const Ve = (n, e) => (n.degradationPreference = e.degradationPreference, n), We
|
|
|
848
847
|
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
849
848
|
return !0;
|
|
850
849
|
return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
|
|
851
|
-
},
|
|
850
|
+
}, Xe = async (n, e) => {
|
|
852
851
|
const t = n.getParameters(), s = JSON.parse(
|
|
853
852
|
JSON.stringify(t)
|
|
854
853
|
);
|
|
855
|
-
|
|
856
|
-
const
|
|
857
|
-
return
|
|
858
|
-
},
|
|
859
|
-
const { isChanged: s, parameters:
|
|
854
|
+
Ye(t, e), $e(t, e);
|
|
855
|
+
const i = ze(s, t);
|
|
856
|
+
return i && await n.setParameters(t), { parameters: t, isChanged: i };
|
|
857
|
+
}, ae = async (n, e, t) => {
|
|
858
|
+
const { isChanged: s, parameters: i } = await Xe(n, {
|
|
860
859
|
encodings: [
|
|
861
860
|
{
|
|
862
861
|
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
@@ -864,21 +863,21 @@ const Ve = (n, e) => (n.degradationPreference = e.degradationPreference, n), We
|
|
|
864
863
|
}
|
|
865
864
|
]
|
|
866
865
|
});
|
|
867
|
-
return s && t && t(
|
|
868
|
-
},
|
|
869
|
-
const s =
|
|
866
|
+
return s && t && t(i), { isChanged: s, parameters: i };
|
|
867
|
+
}, Je = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), Ke = async (n, e, t) => {
|
|
868
|
+
const s = Je(n, e);
|
|
870
869
|
if (s)
|
|
871
|
-
return
|
|
870
|
+
return ae(s, { maxBitrate: t });
|
|
872
871
|
};
|
|
873
|
-
var
|
|
874
|
-
const
|
|
872
|
+
var f = /* @__PURE__ */ ((n) => (n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n))(f || {});
|
|
873
|
+
const oe = [
|
|
875
874
|
"presentation:start",
|
|
876
875
|
"presentation:started",
|
|
877
876
|
"presentation:end",
|
|
878
877
|
"presentation:ended",
|
|
879
878
|
"presentation:failed"
|
|
880
|
-
],
|
|
881
|
-
class
|
|
879
|
+
], je = 1, Cn = (n) => Ne(n);
|
|
880
|
+
class Ze {
|
|
882
881
|
events;
|
|
883
882
|
promisePendingStartPresentation;
|
|
884
883
|
promisePendingStopPresentation;
|
|
@@ -890,7 +889,7 @@ class et {
|
|
|
890
889
|
callManager: e,
|
|
891
890
|
maxBitrate: t
|
|
892
891
|
}) {
|
|
893
|
-
this.callManager = e, this.maxBitrate = t, this.events = new
|
|
892
|
+
this.callManager = e, this.maxBitrate = t, this.events = new w(oe), this.subscribe();
|
|
894
893
|
}
|
|
895
894
|
get isPendingPresentation() {
|
|
896
895
|
return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
|
|
@@ -898,8 +897,8 @@ class et {
|
|
|
898
897
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
899
898
|
async startPresentation(e, t, {
|
|
900
899
|
isNeedReinvite: s,
|
|
901
|
-
contentHint:
|
|
902
|
-
sendEncodings:
|
|
900
|
+
contentHint: i,
|
|
901
|
+
sendEncodings: r,
|
|
903
902
|
onAddedTransceiver: a
|
|
904
903
|
} = {}, o) {
|
|
905
904
|
const c = this.getRtcSessionProtected();
|
|
@@ -910,8 +909,8 @@ class et {
|
|
|
910
909
|
stream: t,
|
|
911
910
|
presentationOptions: {
|
|
912
911
|
isNeedReinvite: s,
|
|
913
|
-
contentHint:
|
|
914
|
-
sendEncodings:
|
|
912
|
+
contentHint: i,
|
|
913
|
+
sendEncodings: r,
|
|
915
914
|
onAddedTransceiver: a
|
|
916
915
|
},
|
|
917
916
|
options: o
|
|
@@ -923,17 +922,17 @@ class et {
|
|
|
923
922
|
let s = this.promisePendingStartPresentation ?? Promise.resolve(void 0);
|
|
924
923
|
this.promisePendingStartPresentation && await this.promisePendingStartPresentation.catch(() => {
|
|
925
924
|
});
|
|
926
|
-
const
|
|
927
|
-
return
|
|
928
|
-
throw this.events.trigger(
|
|
929
|
-
}) : t && this.events.trigger(
|
|
925
|
+
const i = this.callManager.getEstablishedRTCSession();
|
|
926
|
+
return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
|
|
927
|
+
throw this.events.trigger(f.FAILED_PRESENTATION, r), r;
|
|
928
|
+
}) : t && this.events.trigger(f.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
|
|
930
929
|
this.resetPresentation();
|
|
931
930
|
});
|
|
932
931
|
}
|
|
933
932
|
async updatePresentation(e, t, {
|
|
934
933
|
contentHint: s,
|
|
935
|
-
sendEncodings:
|
|
936
|
-
onAddedTransceiver:
|
|
934
|
+
sendEncodings: i,
|
|
935
|
+
onAddedTransceiver: r
|
|
937
936
|
} = {}) {
|
|
938
937
|
const a = this.getRtcSessionProtected();
|
|
939
938
|
if (!this.streamPresentationCurrent)
|
|
@@ -941,8 +940,8 @@ class et {
|
|
|
941
940
|
return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this.sendPresentation(e, a, t, {
|
|
942
941
|
contentHint: s,
|
|
943
942
|
isNeedReinvite: !1,
|
|
944
|
-
sendEncodings:
|
|
945
|
-
onAddedTransceiver:
|
|
943
|
+
sendEncodings: i,
|
|
944
|
+
onAddedTransceiver: r
|
|
946
945
|
}).then(async (o) => (await this.setMaxBitrate(), o));
|
|
947
946
|
}
|
|
948
947
|
cancelSendPresentationWithRepeatedCalls() {
|
|
@@ -969,56 +968,56 @@ class et {
|
|
|
969
968
|
}
|
|
970
969
|
subscribe() {
|
|
971
970
|
this.callManager.on("presentation:start", (e) => {
|
|
972
|
-
this.events.trigger(
|
|
971
|
+
this.events.trigger(f.START_PRESENTATION, e);
|
|
973
972
|
}), this.callManager.on("presentation:started", (e) => {
|
|
974
|
-
this.events.trigger(
|
|
973
|
+
this.events.trigger(f.STARTED_PRESENTATION, e);
|
|
975
974
|
}), this.callManager.on("presentation:end", (e) => {
|
|
976
|
-
this.events.trigger(
|
|
975
|
+
this.events.trigger(f.END_PRESENTATION, e);
|
|
977
976
|
}), this.callManager.on("presentation:ended", (e) => {
|
|
978
|
-
this.events.trigger(
|
|
977
|
+
this.events.trigger(f.ENDED_PRESENTATION, e);
|
|
979
978
|
}), this.callManager.on("presentation:failed", (e) => {
|
|
980
|
-
this.events.trigger(
|
|
979
|
+
this.events.trigger(f.FAILED_PRESENTATION, e);
|
|
981
980
|
}), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
|
|
982
981
|
}
|
|
983
982
|
async sendPresentationWithDuplicatedCalls(e, {
|
|
984
983
|
rtcSession: t,
|
|
985
984
|
stream: s,
|
|
986
|
-
presentationOptions:
|
|
987
|
-
options:
|
|
988
|
-
callLimit:
|
|
985
|
+
presentationOptions: i,
|
|
986
|
+
options: r = {
|
|
987
|
+
callLimit: je
|
|
989
988
|
}
|
|
990
989
|
}) {
|
|
991
990
|
const a = async () => this.sendPresentation(
|
|
992
991
|
e,
|
|
993
992
|
t,
|
|
994
993
|
s,
|
|
995
|
-
|
|
994
|
+
i
|
|
996
995
|
), o = () => !!this.streamPresentationCurrent;
|
|
997
|
-
return this.cancelableSendPresentationWithRepeatedCalls =
|
|
996
|
+
return this.cancelableSendPresentationWithRepeatedCalls = J({
|
|
998
997
|
targetFunction: a,
|
|
999
998
|
isComplete: o,
|
|
1000
999
|
isRejectAsValid: !0,
|
|
1001
|
-
...
|
|
1000
|
+
...r
|
|
1002
1001
|
}), this.cancelableSendPresentationWithRepeatedCalls.then((c) => c);
|
|
1003
1002
|
}
|
|
1004
1003
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
1005
1004
|
async sendPresentation(e, t, s, {
|
|
1006
|
-
isNeedReinvite:
|
|
1007
|
-
contentHint:
|
|
1005
|
+
isNeedReinvite: i = !0,
|
|
1006
|
+
contentHint: r = "detail",
|
|
1008
1007
|
degradationPreference: a,
|
|
1009
1008
|
sendEncodings: o,
|
|
1010
1009
|
onAddedTransceiver: c
|
|
1011
1010
|
}) {
|
|
1012
|
-
const d = B(s, { contentHint:
|
|
1011
|
+
const d = B(s, { contentHint: r });
|
|
1013
1012
|
if (d === void 0)
|
|
1014
1013
|
throw new Error("No streamPresentationTarget");
|
|
1015
1014
|
this.streamPresentationCurrent = d;
|
|
1016
|
-
const u = e().then(async () => t.startPresentation(d,
|
|
1015
|
+
const u = e().then(async () => t.startPresentation(d, i, {
|
|
1017
1016
|
degradationPreference: a,
|
|
1018
1017
|
sendEncodings: o,
|
|
1019
1018
|
onAddedTransceiver: c
|
|
1020
1019
|
})).then(this.setMaxBitrate).then(() => s).catch((T) => {
|
|
1021
|
-
throw this.removeStreamPresentationCurrent(), this.events.trigger(
|
|
1020
|
+
throw this.removeStreamPresentationCurrent(), this.events.trigger(f.FAILED_PRESENTATION, T), T;
|
|
1022
1021
|
});
|
|
1023
1022
|
return this.promisePendingStartPresentation = u, u.finally(() => {
|
|
1024
1023
|
this.promisePendingStartPresentation = void 0;
|
|
@@ -1028,8 +1027,8 @@ class et {
|
|
|
1028
1027
|
const { connection: e } = this.callManager, { streamPresentationCurrent: t } = this, { maxBitrate: s } = this;
|
|
1029
1028
|
if (!e || !t || s === void 0)
|
|
1030
1029
|
return;
|
|
1031
|
-
const
|
|
1032
|
-
await
|
|
1030
|
+
const i = e.getSenders();
|
|
1031
|
+
await Ke(i, t, s);
|
|
1033
1032
|
};
|
|
1034
1033
|
getRtcSessionProtected = () => {
|
|
1035
1034
|
const e = this.callManager.getEstablishedRTCSession();
|
|
@@ -1050,7 +1049,7 @@ class et {
|
|
|
1050
1049
|
delete this.streamPresentationCurrent;
|
|
1051
1050
|
}
|
|
1052
1051
|
}
|
|
1053
|
-
class
|
|
1052
|
+
class et {
|
|
1054
1053
|
data = {};
|
|
1055
1054
|
getUa;
|
|
1056
1055
|
constructor(e) {
|
|
@@ -1123,8 +1122,8 @@ class tt {
|
|
|
1123
1122
|
return this.data.register === !0;
|
|
1124
1123
|
}
|
|
1125
1124
|
}
|
|
1126
|
-
var
|
|
1127
|
-
const
|
|
1125
|
+
var A = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n))(A || {});
|
|
1126
|
+
const ce = [
|
|
1128
1127
|
"connecting",
|
|
1129
1128
|
"connected",
|
|
1130
1129
|
"disconnected",
|
|
@@ -1134,8 +1133,8 @@ const he = [
|
|
|
1134
1133
|
"registrationFailed",
|
|
1135
1134
|
"newMessage",
|
|
1136
1135
|
"sipEvent"
|
|
1137
|
-
],
|
|
1138
|
-
class
|
|
1136
|
+
], de = [...ce], tt = 3;
|
|
1137
|
+
class nt {
|
|
1139
1138
|
cancelableConnectWithRepeatedCalls;
|
|
1140
1139
|
JsSIP;
|
|
1141
1140
|
events;
|
|
@@ -1154,71 +1153,71 @@ class st {
|
|
|
1154
1153
|
}
|
|
1155
1154
|
connect = async (e, t) => (this.cancelRequests(), this.connectWithDuplicatedCalls(e, t));
|
|
1156
1155
|
set = async ({ displayName: e }) => new Promise((t, s) => {
|
|
1157
|
-
const
|
|
1158
|
-
if (!
|
|
1156
|
+
const i = this.getUa();
|
|
1157
|
+
if (!i) {
|
|
1159
1158
|
s(new Error("this.ua is not initialized"));
|
|
1160
1159
|
return;
|
|
1161
1160
|
}
|
|
1162
|
-
let
|
|
1161
|
+
let r = !1;
|
|
1163
1162
|
const a = this.getConnectionConfiguration();
|
|
1164
|
-
e !== void 0 && e !== a.displayName && (
|
|
1165
|
-
const o =
|
|
1163
|
+
e !== void 0 && e !== a.displayName && (r = i.set("display_name", ne(e)), this.updateConnectionConfiguration("displayName", e));
|
|
1164
|
+
const o = r;
|
|
1166
1165
|
o ? t(o) : s(new Error("nothing changed"));
|
|
1167
1166
|
});
|
|
1168
1167
|
disconnect = async () => {
|
|
1169
1168
|
const e = new Promise((s) => {
|
|
1170
|
-
this.events.once(
|
|
1169
|
+
this.events.once(A.DISCONNECTED, () => {
|
|
1171
1170
|
s();
|
|
1172
1171
|
});
|
|
1173
1172
|
}), t = this.getUa();
|
|
1174
|
-
return t ? t.stop() : this.events.trigger(
|
|
1173
|
+
return t ? t.stop() : this.events.trigger(A.DISCONNECTED, void 0), e.finally(() => {
|
|
1175
1174
|
this.setUa(void 0), this.stateMachine.reset();
|
|
1176
1175
|
});
|
|
1177
1176
|
};
|
|
1178
1177
|
cancelRequests() {
|
|
1179
1178
|
this.cancelConnectWithRepeatedCalls();
|
|
1180
1179
|
}
|
|
1181
|
-
connectWithDuplicatedCalls = async (e, { callLimit: t =
|
|
1182
|
-
const s = async () => this.connectInner(e),
|
|
1183
|
-
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d =
|
|
1180
|
+
connectWithDuplicatedCalls = async (e, { callLimit: t = tt } = {}) => {
|
|
1181
|
+
const s = async () => this.connectInner(e), i = (r) => {
|
|
1182
|
+
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = r != null && !Me(r);
|
|
1184
1183
|
return c || d;
|
|
1185
1184
|
};
|
|
1186
|
-
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls =
|
|
1185
|
+
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = J({
|
|
1187
1186
|
targetFunction: s,
|
|
1188
|
-
isComplete:
|
|
1187
|
+
isComplete: i,
|
|
1189
1188
|
callLimit: t,
|
|
1190
1189
|
isRejectAsValid: !0,
|
|
1191
1190
|
isCheckBeforeCall: !1
|
|
1192
|
-
}), this.cancelableConnectWithRepeatedCalls.then((
|
|
1193
|
-
if (
|
|
1194
|
-
return
|
|
1195
|
-
throw
|
|
1191
|
+
}), this.cancelableConnectWithRepeatedCalls.then((r) => {
|
|
1192
|
+
if (r instanceof this.JsSIP.UA)
|
|
1193
|
+
return r;
|
|
1194
|
+
throw r;
|
|
1196
1195
|
});
|
|
1197
1196
|
};
|
|
1198
1197
|
hasEqualConnectionConfiguration(e) {
|
|
1199
|
-
const { configuration: t } = this.uaFactory.createConfiguration(e),
|
|
1200
|
-
return
|
|
1198
|
+
const { configuration: t } = this.uaFactory.createConfiguration(e), i = this.getUa()?.configuration;
|
|
1199
|
+
return i ? i.password === t.password && i.register === t.register && i.uri.toString() === t.uri && i.display_name === t.display_name && i.user_agent === t.user_agent && i.sockets === t.sockets && i.session_timers === t.session_timers && i.register_expires === t.register_expires && i.connection_recovery_min_interval === t.connection_recovery_min_interval && i.connection_recovery_max_interval === t.connection_recovery_max_interval : !1;
|
|
1201
1200
|
}
|
|
1202
1201
|
connectInner = async (e) => this.initUa(e).then(async () => this.start());
|
|
1203
1202
|
initUa = async ({
|
|
1204
1203
|
user: e,
|
|
1205
1204
|
password: t,
|
|
1206
1205
|
sipServerUrl: s,
|
|
1207
|
-
sipWebSocketServerURL:
|
|
1208
|
-
remoteAddress:
|
|
1206
|
+
sipWebSocketServerURL: i,
|
|
1207
|
+
remoteAddress: r,
|
|
1209
1208
|
sessionTimers: a,
|
|
1210
1209
|
registerExpires: o,
|
|
1211
1210
|
connectionRecoveryMinInterval: c,
|
|
1212
1211
|
connectionRecoveryMaxInterval: d,
|
|
1213
1212
|
userAgent: u,
|
|
1214
1213
|
displayName: T = "",
|
|
1215
|
-
register:
|
|
1214
|
+
register: l = !1,
|
|
1216
1215
|
extraHeaders: S = []
|
|
1217
1216
|
}) => {
|
|
1218
1217
|
this.stateMachine.startInitUa(), this.setConnectionConfiguration({
|
|
1219
1218
|
sipServerUrl: s,
|
|
1220
1219
|
displayName: T,
|
|
1221
|
-
register:
|
|
1220
|
+
register: l,
|
|
1222
1221
|
user: e,
|
|
1223
1222
|
password: t
|
|
1224
1223
|
}), this.getUa() && await this.disconnect();
|
|
@@ -1227,15 +1226,15 @@ class st {
|
|
|
1227
1226
|
user: e,
|
|
1228
1227
|
password: t,
|
|
1229
1228
|
sipServerUrl: s,
|
|
1230
|
-
sipWebSocketServerURL:
|
|
1229
|
+
sipWebSocketServerURL: i,
|
|
1231
1230
|
displayName: T,
|
|
1232
|
-
register:
|
|
1231
|
+
register: l,
|
|
1233
1232
|
sessionTimers: a,
|
|
1234
1233
|
registerExpires: o,
|
|
1235
1234
|
connectionRecoveryMinInterval: c,
|
|
1236
1235
|
connectionRecoveryMaxInterval: d,
|
|
1237
1236
|
userAgent: u,
|
|
1238
|
-
remoteAddress:
|
|
1237
|
+
remoteAddress: r,
|
|
1239
1238
|
extraHeaders: S
|
|
1240
1239
|
},
|
|
1241
1240
|
this.events
|
|
@@ -1248,40 +1247,40 @@ class st {
|
|
|
1248
1247
|
t(new Error("this.ua is not initialized"));
|
|
1249
1248
|
return;
|
|
1250
1249
|
}
|
|
1251
|
-
let
|
|
1252
|
-
|
|
1250
|
+
let i;
|
|
1251
|
+
i = ((c, d) => {
|
|
1253
1252
|
if (this.getConnectionConfiguration().register === !0)
|
|
1254
1253
|
return this.registrationManager.subscribeToStartEvents(c, d);
|
|
1255
|
-
const T =
|
|
1256
|
-
return this.events.on(T, c),
|
|
1254
|
+
const T = A.CONNECTED, l = [A.DISCONNECTED];
|
|
1255
|
+
return this.events.on(T, c), l.forEach((S) => {
|
|
1257
1256
|
this.events.on(S, d);
|
|
1258
1257
|
}), () => {
|
|
1259
|
-
this.events.off(T, c),
|
|
1258
|
+
this.events.off(T, c), l.forEach((S) => {
|
|
1260
1259
|
this.events.off(S, d);
|
|
1261
1260
|
});
|
|
1262
1261
|
};
|
|
1263
1262
|
})(() => {
|
|
1264
|
-
|
|
1263
|
+
i?.(), e(s);
|
|
1265
1264
|
}, (c) => {
|
|
1266
|
-
|
|
1265
|
+
i?.(), t(c);
|
|
1267
1266
|
}), s.start();
|
|
1268
1267
|
});
|
|
1269
1268
|
cancelConnectWithRepeatedCalls() {
|
|
1270
1269
|
this.cancelableConnectWithRepeatedCalls?.cancel();
|
|
1271
1270
|
}
|
|
1272
1271
|
}
|
|
1273
|
-
var
|
|
1274
|
-
const
|
|
1272
|
+
var he = /* @__PURE__ */ ((n) => (n.START_CONNECT = "START_CONNECT", n.START_INIT_UA = "START_INIT_UA", n.UA_CONNECTED = "UA_CONNECTED", n.UA_REGISTERED = "UA_REGISTERED", n.UA_UNREGISTERED = "UA_UNREGISTERED", n.UA_DISCONNECTED = "UA_DISCONNECTED", n.CONNECTION_FAILED = "CONNECTION_FAILED", n.RESET = "RESET", n))(he || {});
|
|
1273
|
+
const st = Ae({
|
|
1275
1274
|
types: {
|
|
1276
1275
|
context: {},
|
|
1277
1276
|
events: {}
|
|
1278
1277
|
},
|
|
1279
1278
|
actions: {
|
|
1280
1279
|
logTransition: (n, e) => {
|
|
1281
|
-
|
|
1280
|
+
E(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
1282
1281
|
},
|
|
1283
1282
|
logStateChange: (n, e) => {
|
|
1284
|
-
|
|
1283
|
+
E("ConnectionStateMachine state changed", e.state);
|
|
1285
1284
|
}
|
|
1286
1285
|
}
|
|
1287
1286
|
}).createMachine({
|
|
@@ -1592,10 +1591,10 @@ class it {
|
|
|
1592
1591
|
unsubscribeFromEvents;
|
|
1593
1592
|
actorSubscription;
|
|
1594
1593
|
constructor(e) {
|
|
1595
|
-
this.events = e, this.actor =
|
|
1594
|
+
this.events = e, this.actor = Re(st), this.actorSubscription = this.actor.subscribe((t) => {
|
|
1596
1595
|
const s = t.value;
|
|
1597
|
-
this.stateChangeListeners.forEach((
|
|
1598
|
-
|
|
1596
|
+
this.stateChangeListeners.forEach((i) => {
|
|
1597
|
+
i(s);
|
|
1599
1598
|
});
|
|
1600
1599
|
}), this.actor.start(), this.subscribeToEvents();
|
|
1601
1600
|
}
|
|
@@ -1678,7 +1677,7 @@ class it {
|
|
|
1678
1677
|
return this.actor.getSnapshot().can({ type: e });
|
|
1679
1678
|
}
|
|
1680
1679
|
getValidEvents() {
|
|
1681
|
-
return Object.values(
|
|
1680
|
+
return Object.values(he).filter((e) => this.canTransition(e));
|
|
1682
1681
|
}
|
|
1683
1682
|
hasState(e) {
|
|
1684
1683
|
return this.actor.getSnapshot().matches(e);
|
|
@@ -1686,7 +1685,7 @@ class it {
|
|
|
1686
1685
|
sendEvent(e) {
|
|
1687
1686
|
const t = this.actor.getSnapshot(), s = { type: e };
|
|
1688
1687
|
if (!t.can(s)) {
|
|
1689
|
-
|
|
1688
|
+
E(
|
|
1690
1689
|
`Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
|
|
1691
1690
|
);
|
|
1692
1691
|
return;
|
|
@@ -1747,7 +1746,7 @@ class it {
|
|
|
1747
1746
|
};
|
|
1748
1747
|
}
|
|
1749
1748
|
}
|
|
1750
|
-
class
|
|
1749
|
+
class rt {
|
|
1751
1750
|
events;
|
|
1752
1751
|
getUaProtected;
|
|
1753
1752
|
constructor(e) {
|
|
@@ -1756,35 +1755,35 @@ class at {
|
|
|
1756
1755
|
async register() {
|
|
1757
1756
|
const e = this.getUaProtected();
|
|
1758
1757
|
return new Promise((t, s) => {
|
|
1759
|
-
e.on(
|
|
1758
|
+
e.on(A.REGISTERED, t), e.on(A.REGISTRATION_FAILED, s), e.register();
|
|
1760
1759
|
});
|
|
1761
1760
|
}
|
|
1762
1761
|
async unregister() {
|
|
1763
1762
|
const e = this.getUaProtected();
|
|
1764
1763
|
return new Promise((t) => {
|
|
1765
|
-
e.on(
|
|
1764
|
+
e.on(A.UNREGISTERED, t), e.unregister();
|
|
1766
1765
|
});
|
|
1767
1766
|
}
|
|
1768
1767
|
async tryRegister() {
|
|
1769
1768
|
try {
|
|
1770
1769
|
await this.unregister();
|
|
1771
1770
|
} catch (e) {
|
|
1772
|
-
|
|
1771
|
+
E("tryRegister", e);
|
|
1773
1772
|
}
|
|
1774
1773
|
return this.register();
|
|
1775
1774
|
}
|
|
1776
1775
|
subscribeToStartEvents(e, t) {
|
|
1777
|
-
const s =
|
|
1778
|
-
return this.events.on(s, e),
|
|
1779
|
-
this.events.on(
|
|
1776
|
+
const s = A.REGISTERED, i = [A.REGISTRATION_FAILED, A.DISCONNECTED];
|
|
1777
|
+
return this.events.on(s, e), i.forEach((r) => {
|
|
1778
|
+
this.events.on(r, t);
|
|
1780
1779
|
}), () => {
|
|
1781
|
-
this.events.off(s, e),
|
|
1782
|
-
this.events.off(
|
|
1780
|
+
this.events.off(s, e), i.forEach((r) => {
|
|
1781
|
+
this.events.off(r, t);
|
|
1783
1782
|
});
|
|
1784
1783
|
};
|
|
1785
1784
|
}
|
|
1786
1785
|
}
|
|
1787
|
-
class
|
|
1786
|
+
class at {
|
|
1788
1787
|
uaFactory;
|
|
1789
1788
|
getUaProtected;
|
|
1790
1789
|
constructor(e) {
|
|
@@ -1794,14 +1793,14 @@ class ot {
|
|
|
1794
1793
|
* Отправляет SIP OPTIONS запрос к указанному адресу
|
|
1795
1794
|
*/
|
|
1796
1795
|
async sendOptions(e, t, s) {
|
|
1797
|
-
const
|
|
1798
|
-
return new Promise((
|
|
1796
|
+
const i = this.getUaProtected();
|
|
1797
|
+
return new Promise((r, a) => {
|
|
1799
1798
|
try {
|
|
1800
|
-
|
|
1799
|
+
i.sendOptions(e, t, {
|
|
1801
1800
|
extraHeaders: s,
|
|
1802
1801
|
eventHandlers: {
|
|
1803
1802
|
succeeded: () => {
|
|
1804
|
-
|
|
1803
|
+
r();
|
|
1805
1804
|
},
|
|
1806
1805
|
failed: a
|
|
1807
1806
|
}
|
|
@@ -1815,8 +1814,8 @@ class ot {
|
|
|
1815
1814
|
* Отправляет SIP OPTIONS запрос к собственному URI (ping)
|
|
1816
1815
|
*/
|
|
1817
1816
|
async ping(e, t) {
|
|
1818
|
-
const
|
|
1819
|
-
return this.sendOptions(
|
|
1817
|
+
const i = this.getUaProtected().configuration.uri;
|
|
1818
|
+
return this.sendOptions(i, e, t);
|
|
1820
1819
|
}
|
|
1821
1820
|
/**
|
|
1822
1821
|
* Проверяет доступность телефонии, создавая временное соединение
|
|
@@ -1825,35 +1824,35 @@ class ot {
|
|
|
1825
1824
|
userAgent: e,
|
|
1826
1825
|
displayName: t,
|
|
1827
1826
|
sipServerUrl: s,
|
|
1828
|
-
sipWebSocketServerURL:
|
|
1829
|
-
remoteAddress:
|
|
1827
|
+
sipWebSocketServerURL: i,
|
|
1828
|
+
remoteAddress: r,
|
|
1830
1829
|
extraHeaders: a
|
|
1831
1830
|
}) {
|
|
1832
1831
|
return new Promise((o, c) => {
|
|
1833
1832
|
const { configuration: d } = this.uaFactory.createConfiguration({
|
|
1834
|
-
sipWebSocketServerURL:
|
|
1833
|
+
sipWebSocketServerURL: i,
|
|
1835
1834
|
displayName: t,
|
|
1836
1835
|
userAgent: e,
|
|
1837
1836
|
sipServerUrl: s
|
|
1838
|
-
}), u = this.uaFactory.createUA({ ...d, remoteAddress:
|
|
1837
|
+
}), u = this.uaFactory.createUA({ ...d, remoteAddress: r, extraHeaders: a }), T = () => {
|
|
1839
1838
|
const S = new Error("Telephony is not available");
|
|
1840
1839
|
c(S);
|
|
1841
1840
|
};
|
|
1842
|
-
u.once(
|
|
1843
|
-
const
|
|
1844
|
-
u.removeAllListeners(), u.once(
|
|
1841
|
+
u.once(A.DISCONNECTED, T);
|
|
1842
|
+
const l = () => {
|
|
1843
|
+
u.removeAllListeners(), u.once(A.DISCONNECTED, () => {
|
|
1845
1844
|
o();
|
|
1846
1845
|
}), u.stop();
|
|
1847
1846
|
};
|
|
1848
|
-
u.once(
|
|
1847
|
+
u.once(A.CONNECTED, l), u.start();
|
|
1849
1848
|
});
|
|
1850
1849
|
}
|
|
1851
1850
|
}
|
|
1852
|
-
const
|
|
1851
|
+
const ot = (n) => {
|
|
1853
1852
|
const e = [];
|
|
1854
1853
|
return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
|
|
1855
1854
|
};
|
|
1856
|
-
class
|
|
1855
|
+
class O {
|
|
1857
1856
|
JsSIP;
|
|
1858
1857
|
constructor(e) {
|
|
1859
1858
|
this.JsSIP = e;
|
|
@@ -1865,12 +1864,12 @@ class v {
|
|
|
1865
1864
|
register: e,
|
|
1866
1865
|
password: t,
|
|
1867
1866
|
user: s,
|
|
1868
|
-
sipServerUrl:
|
|
1869
|
-
sipWebSocketServerURL:
|
|
1867
|
+
sipServerUrl: i,
|
|
1868
|
+
sipWebSocketServerURL: r
|
|
1870
1869
|
}) {
|
|
1871
|
-
if (!r)
|
|
1872
|
-
throw new Error("sipServerUrl is required");
|
|
1873
1870
|
if (!i)
|
|
1871
|
+
throw new Error("sipServerUrl is required");
|
|
1872
|
+
if (!r)
|
|
1874
1873
|
throw new Error("sipWebSocketServerURL is required");
|
|
1875
1874
|
if (e && (t === void 0 || t === ""))
|
|
1876
1875
|
throw new Error("password is required for authorized connection");
|
|
@@ -1878,18 +1877,18 @@ class v {
|
|
|
1878
1877
|
throw new Error("user is required for authorized connection");
|
|
1879
1878
|
}
|
|
1880
1879
|
static resolveAuthorizationUser(e, t) {
|
|
1881
|
-
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${
|
|
1880
|
+
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${we()}`;
|
|
1882
1881
|
}
|
|
1883
1882
|
static buildExtraHeaders(e, t) {
|
|
1884
|
-
const s = e !== void 0 && e !== "" ?
|
|
1883
|
+
const s = e !== void 0 && e !== "" ? ot(e) : [];
|
|
1885
1884
|
return t === void 0 ? s : [...s, ...t];
|
|
1886
1885
|
}
|
|
1887
1886
|
createConfiguration({
|
|
1888
1887
|
user: e,
|
|
1889
1888
|
password: t,
|
|
1890
1889
|
sipWebSocketServerURL: s,
|
|
1891
|
-
displayName:
|
|
1892
|
-
sipServerUrl:
|
|
1890
|
+
displayName: i = "",
|
|
1891
|
+
sipServerUrl: r,
|
|
1893
1892
|
register: a = !1,
|
|
1894
1893
|
sessionTimers: o = !1,
|
|
1895
1894
|
registerExpires: c = 300,
|
|
@@ -1898,20 +1897,20 @@ class v {
|
|
|
1898
1897
|
connectionRecoveryMaxInterval: u = 6,
|
|
1899
1898
|
userAgent: T
|
|
1900
1899
|
}) {
|
|
1901
|
-
|
|
1900
|
+
O.validateConfiguration({
|
|
1902
1901
|
register: a,
|
|
1903
1902
|
password: t,
|
|
1904
1903
|
user: e,
|
|
1905
|
-
sipServerUrl:
|
|
1904
|
+
sipServerUrl: r,
|
|
1906
1905
|
sipWebSocketServerURL: s
|
|
1907
1906
|
});
|
|
1908
|
-
const
|
|
1907
|
+
const l = O.resolveAuthorizationUser(a, e), S = ye(r), m = S(l), I = new this.JsSIP.WebSocketInterface(s);
|
|
1909
1908
|
return {
|
|
1910
1909
|
configuration: {
|
|
1911
1910
|
password: t,
|
|
1912
1911
|
register: a,
|
|
1913
1912
|
uri: m,
|
|
1914
|
-
display_name:
|
|
1913
|
+
display_name: ne(i),
|
|
1915
1914
|
user_agent: T,
|
|
1916
1915
|
sdpSemantics: "unified-plan",
|
|
1917
1916
|
sockets: [I],
|
|
@@ -1927,25 +1926,25 @@ class v {
|
|
|
1927
1926
|
};
|
|
1928
1927
|
}
|
|
1929
1928
|
createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
|
|
1930
|
-
const
|
|
1931
|
-
return
|
|
1929
|
+
const i = new this.JsSIP.UA(s), r = O.buildExtraHeaders(e, t);
|
|
1930
|
+
return r.length > 0 && i.registrator().setExtraHeaders(r), i;
|
|
1932
1931
|
}
|
|
1933
1932
|
/**
|
|
1934
1933
|
* Создает UA с полным жизненным циклом - конфигурация + создание + настройка событий
|
|
1935
1934
|
*/
|
|
1936
1935
|
createUAWithConfiguration(e, t) {
|
|
1937
|
-
const { configuration: s, helpers:
|
|
1936
|
+
const { configuration: s, helpers: i } = this.createConfiguration(e), r = this.createUA({
|
|
1938
1937
|
...s,
|
|
1939
1938
|
remoteAddress: e.remoteAddress,
|
|
1940
1939
|
extraHeaders: e.extraHeaders
|
|
1941
1940
|
});
|
|
1942
1941
|
return t.eachTriggers((a, o) => {
|
|
1943
|
-
const c =
|
|
1944
|
-
c &&
|
|
1945
|
-
}), { ua:
|
|
1942
|
+
const c = ce.find((d) => d === o);
|
|
1943
|
+
c && r.on(c, a);
|
|
1944
|
+
}), { ua: r, helpers: i };
|
|
1946
1945
|
}
|
|
1947
1946
|
}
|
|
1948
|
-
class
|
|
1947
|
+
class ct {
|
|
1949
1948
|
events;
|
|
1950
1949
|
ua;
|
|
1951
1950
|
socket;
|
|
@@ -1957,15 +1956,15 @@ class dt {
|
|
|
1957
1956
|
configurationManager;
|
|
1958
1957
|
JsSIP;
|
|
1959
1958
|
constructor({ JsSIP: e }) {
|
|
1960
|
-
this.JsSIP = e, this.events = new
|
|
1959
|
+
this.JsSIP = e, this.events = new w(de), this.uaFactory = new O(e), this.registrationManager = new rt({
|
|
1961
1960
|
events: this.events,
|
|
1962
1961
|
getUaProtected: this.getUaProtected
|
|
1963
|
-
}), this.stateMachine = new it(this.events), this.configurationManager = new
|
|
1962
|
+
}), this.stateMachine = new it(this.events), this.configurationManager = new et({
|
|
1964
1963
|
getUa: this.getUa
|
|
1965
|
-
}), this.sipOperations = new
|
|
1964
|
+
}), this.sipOperations = new at({
|
|
1966
1965
|
uaFactory: this.uaFactory,
|
|
1967
1966
|
getUaProtected: this.getUaProtected
|
|
1968
|
-
}), this.connectionFlow = new
|
|
1967
|
+
}), this.connectionFlow = new nt({
|
|
1969
1968
|
JsSIP: this.JsSIP,
|
|
1970
1969
|
events: this.events,
|
|
1971
1970
|
uaFactory: this.uaFactory,
|
|
@@ -2003,7 +2002,7 @@ class dt {
|
|
|
2003
2002
|
return this.stateMachine.state;
|
|
2004
2003
|
}
|
|
2005
2004
|
get isRegistered() {
|
|
2006
|
-
return
|
|
2005
|
+
return O.isRegisteredUA(this.ua);
|
|
2007
2006
|
}
|
|
2008
2007
|
get isRegisterConfig() {
|
|
2009
2008
|
return this.configurationManager.isRegister();
|
|
@@ -2056,9 +2055,9 @@ class dt {
|
|
|
2056
2055
|
};
|
|
2057
2056
|
getUa = () => this.ua;
|
|
2058
2057
|
}
|
|
2059
|
-
class
|
|
2058
|
+
class dt {
|
|
2060
2059
|
connectionManager;
|
|
2061
|
-
stackPromises =
|
|
2060
|
+
stackPromises = K({
|
|
2062
2061
|
noRunIsNotActual: !0
|
|
2063
2062
|
});
|
|
2064
2063
|
constructor({ connectionManager: e }) {
|
|
@@ -2074,19 +2073,19 @@ class ht {
|
|
|
2074
2073
|
ping = async (...e) => this.stackPromises.run(async () => this.connectionManager.ping(...e));
|
|
2075
2074
|
set = async (...e) => this.stackPromises.run(async () => this.connectionManager.set(...e));
|
|
2076
2075
|
}
|
|
2077
|
-
var
|
|
2078
|
-
const
|
|
2076
|
+
var b = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(b || {});
|
|
2077
|
+
const le = [
|
|
2079
2078
|
"incomingCall",
|
|
2080
2079
|
"declinedIncomingCall",
|
|
2081
2080
|
"terminatedIncomingCall",
|
|
2082
2081
|
"failedIncomingCall"
|
|
2083
|
-
],
|
|
2084
|
-
class
|
|
2082
|
+
], ht = 486, lt = 487;
|
|
2083
|
+
class gt {
|
|
2085
2084
|
events;
|
|
2086
2085
|
incomingRTCSession;
|
|
2087
2086
|
connectionManager;
|
|
2088
2087
|
constructor(e) {
|
|
2089
|
-
this.connectionManager = e, this.events = new
|
|
2088
|
+
this.connectionManager = e, this.events = new w(le), this.start();
|
|
2090
2089
|
}
|
|
2091
2090
|
get remoteCallerData() {
|
|
2092
2091
|
return {
|
|
@@ -2120,15 +2119,15 @@ class ut {
|
|
|
2120
2119
|
} = {}) {
|
|
2121
2120
|
return new Promise((t, s) => {
|
|
2122
2121
|
try {
|
|
2123
|
-
const
|
|
2124
|
-
this.removeIncomingSession(), this.events.trigger(
|
|
2125
|
-
} catch (
|
|
2126
|
-
s(
|
|
2122
|
+
const i = this.getIncomingRTCSession(), r = this.remoteCallerData;
|
|
2123
|
+
this.removeIncomingSession(), this.events.trigger(b.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
|
|
2124
|
+
} catch (i) {
|
|
2125
|
+
s(i);
|
|
2127
2126
|
}
|
|
2128
2127
|
});
|
|
2129
2128
|
}
|
|
2130
2129
|
async busyIncomingCall() {
|
|
2131
|
-
return this.declineToIncomingCall({ statusCode:
|
|
2130
|
+
return this.declineToIncomingCall({ statusCode: ht });
|
|
2132
2131
|
}
|
|
2133
2132
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
2134
2133
|
on(e, t) {
|
|
@@ -2159,25 +2158,25 @@ class ut {
|
|
|
2159
2158
|
originator: e,
|
|
2160
2159
|
session: t
|
|
2161
2160
|
}) => {
|
|
2162
|
-
e ===
|
|
2161
|
+
e === "remote" && this.setIncomingSession(t);
|
|
2163
2162
|
};
|
|
2164
2163
|
setIncomingSession(e) {
|
|
2165
2164
|
this.incomingRTCSession = e;
|
|
2166
2165
|
const t = this.remoteCallerData;
|
|
2167
2166
|
e.on("failed", (s) => {
|
|
2168
|
-
this.removeIncomingSession(), s.originator ===
|
|
2169
|
-
}), this.events.trigger(
|
|
2167
|
+
this.removeIncomingSession(), s.originator === "local" ? this.events.trigger(b.TERMINATED_INCOMING_CALL, t) : this.events.trigger(b.FAILED_INCOMING_CALL, t);
|
|
2168
|
+
}), this.events.trigger(b.INCOMING_CALL, t);
|
|
2170
2169
|
}
|
|
2171
2170
|
removeIncomingSession() {
|
|
2172
2171
|
delete this.incomingRTCSession;
|
|
2173
2172
|
}
|
|
2174
2173
|
}
|
|
2175
|
-
const
|
|
2174
|
+
const y = 1e3;
|
|
2176
2175
|
var C = /* @__PURE__ */ ((n) => (n.INBOUND_RTP = "inbound-rtp", n.REMOTE_OUTBOUND_RTP = "remote-outbound-rtp", n.MEDIA_SOURCE = "media-source", n.OUTBOUND_RTP = "outbound-rtp", n.REMOTE_INBOUND_RTP = "remote-inbound-rtp", n.CODEC = "codec", n.CANDIDATE_PAIR = "candidate-pair", n.CERTIFICATE = "certificate", n.TRANSPORT = "transport", n.LOCAL_CANDIDATE = "local-candidate", n.REMOTE_CANDIDATE = "remote-candidate", n))(C || {});
|
|
2177
|
-
const
|
|
2176
|
+
const ge = ["collected"], Q = () => "performance" in window ? performance.now() : Date.now(), U = (n) => [...n.keys()].reduce((e, t) => {
|
|
2178
2177
|
const s = n.get(t);
|
|
2179
2178
|
return s === void 0 ? e : { ...e, [s.type]: s };
|
|
2180
|
-
}, {}),
|
|
2179
|
+
}, {}), ut = (n) => {
|
|
2181
2180
|
if (!n)
|
|
2182
2181
|
return {
|
|
2183
2182
|
outboundRtp: void 0,
|
|
@@ -2185,14 +2184,14 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2185
2184
|
mediaSource: void 0,
|
|
2186
2185
|
remoteInboundRtp: void 0
|
|
2187
2186
|
};
|
|
2188
|
-
const e =
|
|
2187
|
+
const e = U(n);
|
|
2189
2188
|
return {
|
|
2190
2189
|
outboundRtp: e[C.OUTBOUND_RTP],
|
|
2191
2190
|
codec: e[C.CODEC],
|
|
2192
2191
|
mediaSource: e[C.MEDIA_SOURCE],
|
|
2193
2192
|
remoteInboundRtp: e[C.REMOTE_INBOUND_RTP]
|
|
2194
2193
|
};
|
|
2195
|
-
},
|
|
2194
|
+
}, Y = (n) => {
|
|
2196
2195
|
if (!n)
|
|
2197
2196
|
return {
|
|
2198
2197
|
outboundRtp: void 0,
|
|
@@ -2200,14 +2199,14 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2200
2199
|
mediaSource: void 0,
|
|
2201
2200
|
remoteInboundRtp: void 0
|
|
2202
2201
|
};
|
|
2203
|
-
const e =
|
|
2202
|
+
const e = U(n);
|
|
2204
2203
|
return {
|
|
2205
2204
|
outboundRtp: e[C.OUTBOUND_RTP],
|
|
2206
2205
|
codec: e[C.CODEC],
|
|
2207
2206
|
mediaSource: e[C.MEDIA_SOURCE],
|
|
2208
2207
|
remoteInboundRtp: e[C.REMOTE_INBOUND_RTP]
|
|
2209
2208
|
};
|
|
2210
|
-
},
|
|
2209
|
+
}, z = ({
|
|
2211
2210
|
videoReceiversStats: n,
|
|
2212
2211
|
synchronizationSourcesVideo: e
|
|
2213
2212
|
}) => {
|
|
@@ -2217,13 +2216,13 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2217
2216
|
codec: void 0,
|
|
2218
2217
|
synchronizationSources: e
|
|
2219
2218
|
};
|
|
2220
|
-
const t =
|
|
2219
|
+
const t = U(n);
|
|
2221
2220
|
return {
|
|
2222
2221
|
inboundRtp: t[C.INBOUND_RTP],
|
|
2223
2222
|
codec: t[C.CODEC],
|
|
2224
2223
|
synchronizationSources: e
|
|
2225
2224
|
};
|
|
2226
|
-
},
|
|
2225
|
+
}, Tt = ({
|
|
2227
2226
|
audioReceiverStats: n,
|
|
2228
2227
|
synchronizationSourcesAudio: e
|
|
2229
2228
|
}) => {
|
|
@@ -2234,14 +2233,14 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2234
2233
|
remoteOutboundRtp: void 0,
|
|
2235
2234
|
synchronizationSources: e
|
|
2236
2235
|
};
|
|
2237
|
-
const t =
|
|
2236
|
+
const t = U(n);
|
|
2238
2237
|
return {
|
|
2239
2238
|
inboundRtp: t[C.INBOUND_RTP],
|
|
2240
2239
|
codec: t[C.CODEC],
|
|
2241
2240
|
remoteOutboundRtp: t[C.REMOTE_OUTBOUND_RTP],
|
|
2242
2241
|
synchronizationSources: e
|
|
2243
2242
|
};
|
|
2244
|
-
},
|
|
2243
|
+
}, ue = (n) => {
|
|
2245
2244
|
if (!n)
|
|
2246
2245
|
return {
|
|
2247
2246
|
candidatePair: void 0,
|
|
@@ -2250,7 +2249,7 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2250
2249
|
remoteCandidate: void 0,
|
|
2251
2250
|
transport: void 0
|
|
2252
2251
|
};
|
|
2253
|
-
const e =
|
|
2252
|
+
const e = U(n);
|
|
2254
2253
|
return {
|
|
2255
2254
|
candidatePair: e[C.CANDIDATE_PAIR],
|
|
2256
2255
|
certificate: e[C.CERTIFICATE],
|
|
@@ -2258,63 +2257,63 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2258
2257
|
remoteCandidate: e[C.REMOTE_CANDIDATE],
|
|
2259
2258
|
transport: e[C.TRANSPORT]
|
|
2260
2259
|
};
|
|
2261
|
-
},
|
|
2260
|
+
}, St = ({
|
|
2262
2261
|
audioSenderStats: n,
|
|
2263
2262
|
videoSenderFirstStats: e,
|
|
2264
2263
|
videoSenderSecondStats: t
|
|
2265
2264
|
}) => ({
|
|
2266
|
-
video:
|
|
2267
|
-
secondVideo:
|
|
2268
|
-
audio:
|
|
2269
|
-
additional:
|
|
2265
|
+
video: Y(e),
|
|
2266
|
+
secondVideo: Y(t),
|
|
2267
|
+
audio: ut(n),
|
|
2268
|
+
additional: ue(
|
|
2270
2269
|
n ?? e ?? t
|
|
2271
2270
|
)
|
|
2272
|
-
}),
|
|
2271
|
+
}), Ct = ({
|
|
2273
2272
|
audioReceiverStats: n,
|
|
2274
2273
|
videoReceiverFirstStats: e,
|
|
2275
2274
|
videoReceiverSecondStats: t,
|
|
2276
2275
|
synchronizationSources: s
|
|
2277
2276
|
}) => ({
|
|
2278
|
-
video:
|
|
2277
|
+
video: z({
|
|
2279
2278
|
videoReceiversStats: e,
|
|
2280
2279
|
synchronizationSourcesVideo: s.video
|
|
2281
2280
|
}),
|
|
2282
|
-
secondVideo:
|
|
2281
|
+
secondVideo: z({
|
|
2283
2282
|
videoReceiversStats: t,
|
|
2284
2283
|
synchronizationSourcesVideo: s.video
|
|
2285
2284
|
}),
|
|
2286
|
-
audio:
|
|
2285
|
+
audio: Tt({
|
|
2287
2286
|
audioReceiverStats: n,
|
|
2288
2287
|
synchronizationSourcesAudio: s.audio
|
|
2289
2288
|
}),
|
|
2290
|
-
additional:
|
|
2289
|
+
additional: ue(
|
|
2291
2290
|
n ?? e ?? t
|
|
2292
2291
|
)
|
|
2293
|
-
}),
|
|
2292
|
+
}), Et = ({
|
|
2294
2293
|
audioSenderStats: n,
|
|
2295
2294
|
videoSenderFirstStats: e,
|
|
2296
2295
|
videoSenderSecondStats: t,
|
|
2297
2296
|
audioReceiverStats: s,
|
|
2298
|
-
videoReceiverFirstStats:
|
|
2299
|
-
videoReceiverSecondStats:
|
|
2297
|
+
videoReceiverFirstStats: i,
|
|
2298
|
+
videoReceiverSecondStats: r,
|
|
2300
2299
|
synchronizationSources: a
|
|
2301
2300
|
}) => {
|
|
2302
|
-
const o =
|
|
2301
|
+
const o = St({
|
|
2303
2302
|
audioSenderStats: n,
|
|
2304
2303
|
videoSenderFirstStats: e,
|
|
2305
2304
|
videoSenderSecondStats: t
|
|
2306
|
-
}), c =
|
|
2305
|
+
}), c = Ct({
|
|
2307
2306
|
audioReceiverStats: s,
|
|
2308
|
-
videoReceiverFirstStats:
|
|
2309
|
-
videoReceiverSecondStats:
|
|
2307
|
+
videoReceiverFirstStats: i,
|
|
2308
|
+
videoReceiverSecondStats: r,
|
|
2310
2309
|
synchronizationSources: a
|
|
2311
2310
|
});
|
|
2312
2311
|
return {
|
|
2313
2312
|
outbound: o,
|
|
2314
2313
|
inbound: c
|
|
2315
2314
|
};
|
|
2316
|
-
},
|
|
2317
|
-
const e = "audio", t = "video", s = n.getSenders(),
|
|
2315
|
+
}, Nt = async (n) => {
|
|
2316
|
+
const e = "audio", t = "video", s = n.getSenders(), i = s.find((l) => l.track?.kind === e), r = s.filter((l) => l.track?.kind === t), a = n.getReceivers(), o = a.find((l) => l.track.kind === e), c = a.filter((l) => l.track.kind === t), d = {
|
|
2318
2317
|
trackIdentifier: o?.track.id,
|
|
2319
2318
|
item: o?.getSynchronizationSources()[0]
|
|
2320
2319
|
}, u = {
|
|
@@ -2325,47 +2324,47 @@ const Te = ["collected"], Y = () => "performance" in window ? performance.now()
|
|
|
2325
2324
|
video: u
|
|
2326
2325
|
};
|
|
2327
2326
|
return Promise.all([
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
o?.getStats(),
|
|
2332
|
-
c[0]?.getStats(),
|
|
2333
|
-
c[1]?.getStats()
|
|
2334
|
-
]).then((
|
|
2327
|
+
i?.getStats() ?? Promise.resolve(void 0),
|
|
2328
|
+
r[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2329
|
+
r[1]?.getStats() ?? Promise.resolve(void 0),
|
|
2330
|
+
o?.getStats() ?? Promise.resolve(void 0),
|
|
2331
|
+
c[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2332
|
+
c[1]?.getStats() ?? Promise.resolve(void 0)
|
|
2333
|
+
]).then((l) => {
|
|
2335
2334
|
const [
|
|
2336
2335
|
S,
|
|
2337
2336
|
m,
|
|
2338
2337
|
I,
|
|
2339
2338
|
R,
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
] =
|
|
2339
|
+
D,
|
|
2340
|
+
k
|
|
2341
|
+
] = l;
|
|
2343
2342
|
return {
|
|
2344
2343
|
synchronizationSources: T,
|
|
2345
2344
|
audioSenderStats: S,
|
|
2346
2345
|
videoSenderFirstStats: m,
|
|
2347
2346
|
videoSenderSecondStats: I,
|
|
2348
2347
|
audioReceiverStats: R,
|
|
2349
|
-
videoReceiverFirstStats:
|
|
2350
|
-
videoReceiverSecondStats:
|
|
2348
|
+
videoReceiverFirstStats: D,
|
|
2349
|
+
videoReceiverSecondStats: k
|
|
2351
2350
|
};
|
|
2352
2351
|
});
|
|
2353
|
-
},
|
|
2354
|
-
|
|
2352
|
+
}, At = (n) => {
|
|
2353
|
+
E(String(n));
|
|
2355
2354
|
};
|
|
2356
|
-
class
|
|
2355
|
+
class Rt {
|
|
2357
2356
|
events;
|
|
2358
2357
|
setTimeoutRequest;
|
|
2359
|
-
requesterAllStatistics = new
|
|
2358
|
+
requesterAllStatistics = new Ie(Nt);
|
|
2360
2359
|
constructor() {
|
|
2361
|
-
this.events = new
|
|
2360
|
+
this.events = new H(ge), this.setTimeoutRequest = new j();
|
|
2362
2361
|
}
|
|
2363
2362
|
get requested() {
|
|
2364
2363
|
return this.setTimeoutRequest.requested;
|
|
2365
2364
|
}
|
|
2366
2365
|
start(e, {
|
|
2367
|
-
interval: t =
|
|
2368
|
-
onError: s =
|
|
2366
|
+
interval: t = y,
|
|
2367
|
+
onError: s = At
|
|
2369
2368
|
} = {}) {
|
|
2370
2369
|
this.stop(), this.setTimeoutRequest.request(() => {
|
|
2371
2370
|
this.collectStatistics(e, {
|
|
@@ -2394,21 +2393,21 @@ class It {
|
|
|
2394
2393
|
collectStatistics = (e, {
|
|
2395
2394
|
onError: t
|
|
2396
2395
|
}) => {
|
|
2397
|
-
const s =
|
|
2398
|
-
this.requesterAllStatistics.request(e).then((
|
|
2399
|
-
this.events.trigger("collected",
|
|
2400
|
-
const a =
|
|
2401
|
-
let o =
|
|
2402
|
-
a > 48 ? o =
|
|
2396
|
+
const s = Q();
|
|
2397
|
+
this.requesterAllStatistics.request(e).then((i) => {
|
|
2398
|
+
this.events.trigger("collected", Et(i));
|
|
2399
|
+
const a = Q() - s;
|
|
2400
|
+
let o = y;
|
|
2401
|
+
a > 48 ? o = y * 4 : a > 32 ? o = y * 3 : a > 16 && (o = y * 2), this.start(e, {
|
|
2403
2402
|
onError: t,
|
|
2404
2403
|
interval: o
|
|
2405
2404
|
});
|
|
2406
|
-
}).catch((
|
|
2407
|
-
t && t(
|
|
2405
|
+
}).catch((i) => {
|
|
2406
|
+
t && t(i);
|
|
2408
2407
|
});
|
|
2409
2408
|
};
|
|
2410
2409
|
}
|
|
2411
|
-
class
|
|
2410
|
+
class It {
|
|
2412
2411
|
availableIncomingBitrate;
|
|
2413
2412
|
statsPeerConnection;
|
|
2414
2413
|
callManager;
|
|
@@ -2418,7 +2417,7 @@ class _t {
|
|
|
2418
2417
|
callManager: e,
|
|
2419
2418
|
apiManager: t
|
|
2420
2419
|
}) {
|
|
2421
|
-
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new
|
|
2420
|
+
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Rt(), this.subscribe();
|
|
2422
2421
|
}
|
|
2423
2422
|
get events() {
|
|
2424
2423
|
return this.statsPeerConnection.events;
|
|
@@ -2456,29 +2455,137 @@ class _t {
|
|
|
2456
2455
|
};
|
|
2457
2456
|
maybeSendStats() {
|
|
2458
2457
|
this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
|
|
2459
|
-
|
|
2458
|
+
E("Failed to send stats", e);
|
|
2460
2459
|
});
|
|
2461
2460
|
}
|
|
2462
2461
|
}
|
|
2463
|
-
const
|
|
2464
|
-
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs,
|
|
2465
|
-
return
|
|
2466
|
-
},
|
|
2467
|
-
const
|
|
2462
|
+
const _t = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), mt = (n) => {
|
|
2463
|
+
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
|
|
2464
|
+
return _t(s, i);
|
|
2465
|
+
}, Mt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
|
|
2466
|
+
const i = e.indexOf(t.mimeType), r = e.indexOf(s.mimeType), a = i === -1 ? Number.MAX_VALUE : i, o = r === -1 ? Number.MAX_VALUE : r;
|
|
2468
2467
|
return a - o;
|
|
2469
|
-
}),
|
|
2468
|
+
}), pt = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Pt = (n, {
|
|
2470
2469
|
preferredMimeTypesVideoCodecs: e,
|
|
2471
2470
|
excludeMimeTypesVideoCodecs: t
|
|
2472
2471
|
}) => {
|
|
2473
2472
|
try {
|
|
2474
2473
|
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
2475
|
-
const s = mt("video"),
|
|
2476
|
-
n.setCodecPreferences(
|
|
2474
|
+
const s = mt("video"), i = pt(s, t), r = Mt(i, e);
|
|
2475
|
+
n.setCodecPreferences(r);
|
|
2477
2476
|
}
|
|
2478
2477
|
} catch (s) {
|
|
2479
|
-
|
|
2478
|
+
E("setCodecPreferences error", s);
|
|
2479
|
+
}
|
|
2480
|
+
};
|
|
2481
|
+
class vt {
|
|
2482
|
+
/**
|
|
2483
|
+
* Хранилище основных transceiver'ов
|
|
2484
|
+
*/
|
|
2485
|
+
transceivers = {};
|
|
2486
|
+
callManager;
|
|
2487
|
+
apiManager;
|
|
2488
|
+
constructor({
|
|
2489
|
+
callManager: e,
|
|
2490
|
+
apiManager: t
|
|
2491
|
+
}) {
|
|
2492
|
+
this.callManager = e, this.apiManager = t, this.subscribe();
|
|
2493
|
+
}
|
|
2494
|
+
/**
|
|
2495
|
+
* Сохраняет transceiver в соответствующем хранилище в зависимости от типа трека и mid
|
|
2496
|
+
*/
|
|
2497
|
+
storeTransceiver(e, t) {
|
|
2498
|
+
const { kind: s } = t;
|
|
2499
|
+
if (s === "audio")
|
|
2500
|
+
this.transceivers.mainAudio ??= e;
|
|
2501
|
+
else {
|
|
2502
|
+
const { mid: i } = e;
|
|
2503
|
+
i === "2" ? this.transceivers.presentationVideo ??= e : this.transceivers.mainVideo ??= e;
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
/**
|
|
2507
|
+
* Возвращает все сохраненные transceiver'ы
|
|
2508
|
+
*/
|
|
2509
|
+
getTransceivers() {
|
|
2510
|
+
return { ...this.transceivers };
|
|
2511
|
+
}
|
|
2512
|
+
/**
|
|
2513
|
+
* Возвращает основной аудио transceiver
|
|
2514
|
+
*/
|
|
2515
|
+
getMainAudioTransceiver() {
|
|
2516
|
+
return this.transceivers.mainAudio;
|
|
2517
|
+
}
|
|
2518
|
+
/**
|
|
2519
|
+
* Возвращает основной видео transceiver
|
|
2520
|
+
*/
|
|
2521
|
+
getMainVideoTransceiver() {
|
|
2522
|
+
return this.transceivers.mainVideo;
|
|
2523
|
+
}
|
|
2524
|
+
/**
|
|
2525
|
+
* Возвращает презентационный видео transceiver
|
|
2526
|
+
*/
|
|
2527
|
+
getPresentationVideoTransceiver() {
|
|
2528
|
+
return this.transceivers.presentationVideo;
|
|
2529
|
+
}
|
|
2530
|
+
/**
|
|
2531
|
+
* Проверяет, есть ли сохраненный transceiver для указанного типа
|
|
2532
|
+
*/
|
|
2533
|
+
hasTransceiver(e) {
|
|
2534
|
+
return this.transceivers[e] !== void 0;
|
|
2535
|
+
}
|
|
2536
|
+
/**
|
|
2537
|
+
* Очищает все сохраненные transceiver'ы
|
|
2538
|
+
*/
|
|
2539
|
+
clear() {
|
|
2540
|
+
this.transceivers.mainVideo = void 0, this.transceivers.mainAudio = void 0, this.transceivers.presentationVideo = void 0;
|
|
2541
|
+
}
|
|
2542
|
+
/**
|
|
2543
|
+
* Возвращает количество сохраненных transceiver'ов
|
|
2544
|
+
*/
|
|
2545
|
+
getCount() {
|
|
2546
|
+
let e = 0;
|
|
2547
|
+
return this.transceivers.mainAudio && (e += 1), this.transceivers.mainVideo && (e += 1), this.transceivers.presentationVideo && (e += 1), e;
|
|
2548
|
+
}
|
|
2549
|
+
/**
|
|
2550
|
+
* Проверяет, пустое ли хранилище
|
|
2551
|
+
*/
|
|
2552
|
+
isEmpty() {
|
|
2553
|
+
return this.getCount() === 0;
|
|
2480
2554
|
}
|
|
2481
|
-
|
|
2555
|
+
/**
|
|
2556
|
+
* Обрабатывает событие restart от ApiManager
|
|
2557
|
+
*/
|
|
2558
|
+
handleRestart = (e) => {
|
|
2559
|
+
this.updateTransceivers(e).catch((t) => {
|
|
2560
|
+
E("Failed to update transceivers", t);
|
|
2561
|
+
}).finally(() => {
|
|
2562
|
+
this.callManager.restartIce().catch((t) => {
|
|
2563
|
+
E("Failed to restart ICE", t);
|
|
2564
|
+
});
|
|
2565
|
+
});
|
|
2566
|
+
};
|
|
2567
|
+
/**
|
|
2568
|
+
* Обновляет transceiver'ы в соответствии с данными restart
|
|
2569
|
+
*/
|
|
2570
|
+
updateTransceivers = async (e) => {
|
|
2571
|
+
const { videoTrackCount: t } = e;
|
|
2572
|
+
t === 2 && (this.getTransceivers().presentationVideo !== void 0 || await this.callManager.addTransceiver("video", {
|
|
2573
|
+
direction: "recvonly"
|
|
2574
|
+
}).catch((r) => {
|
|
2575
|
+
E("Failed to add presentation video transceiver", r);
|
|
2576
|
+
}));
|
|
2577
|
+
};
|
|
2578
|
+
subscribe() {
|
|
2579
|
+
this.callManager.on("peerconnection:ontrack", this.handleTrack), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded), this.apiManager.on("restart", this.handleRestart);
|
|
2580
|
+
}
|
|
2581
|
+
handleTrack = (e) => {
|
|
2582
|
+
this.storeTransceiver(e.transceiver, e.track);
|
|
2583
|
+
};
|
|
2584
|
+
handleEnded = () => {
|
|
2585
|
+
this.clear();
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
const ft = (n) => [...n.keys()].map((e) => n.get(e)), Ot = (n, e) => ft(n).find((t) => t?.type === e), Dt = async (n) => n.getStats().then((e) => Ot(e, "codec")?.mimeType);
|
|
2482
2589
|
class yt {
|
|
2483
2590
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
2484
2591
|
async getCodecFromSender(e) {
|
|
@@ -2486,7 +2593,7 @@ class yt {
|
|
|
2486
2593
|
}
|
|
2487
2594
|
}
|
|
2488
2595
|
class bt {
|
|
2489
|
-
stackPromises =
|
|
2596
|
+
stackPromises = K({
|
|
2490
2597
|
noRunIsNotActual: !0
|
|
2491
2598
|
});
|
|
2492
2599
|
/**
|
|
@@ -2506,32 +2613,32 @@ class bt {
|
|
|
2506
2613
|
*/
|
|
2507
2614
|
async run() {
|
|
2508
2615
|
return this.stackPromises().catch((e) => {
|
|
2509
|
-
|
|
2616
|
+
E("TaskQueue: error", e);
|
|
2510
2617
|
});
|
|
2511
2618
|
}
|
|
2512
2619
|
}
|
|
2513
|
-
class
|
|
2620
|
+
class wt {
|
|
2514
2621
|
taskQueue;
|
|
2515
2622
|
onSetParameters;
|
|
2516
2623
|
constructor(e) {
|
|
2517
2624
|
this.onSetParameters = e, this.taskQueue = new bt();
|
|
2518
2625
|
}
|
|
2519
2626
|
async setEncodingsToSender(e, t) {
|
|
2520
|
-
return this.taskQueue.add(async () =>
|
|
2627
|
+
return this.taskQueue.add(async () => ae(e, t, this.onSetParameters));
|
|
2521
2628
|
}
|
|
2522
2629
|
stop() {
|
|
2523
2630
|
this.taskQueue.stop();
|
|
2524
2631
|
}
|
|
2525
2632
|
}
|
|
2526
|
-
const
|
|
2633
|
+
const Te = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Ut = 1e6, p = (n) => n * Ut, Se = p(0.06), Ce = p(4), Lt = (n) => n <= 64 ? Se : n <= 128 ? p(0.12) : n <= 256 ? p(0.25) : n <= 384 ? p(0.32) : n <= 426 ? p(0.38) : n <= 640 ? p(0.5) : n <= 848 ? p(0.7) : n <= 1280 ? p(1) : n <= 1920 ? p(2) : Ce, Bt = "av1", kt = (n) => Te(n, Bt), Ft = 0.6, G = (n, e) => kt(e) ? n * Ft : n, $t = (n) => G(Se, n), Vt = (n) => G(Ce, n), X = (n, e) => {
|
|
2527
2634
|
const t = Lt(n);
|
|
2528
|
-
return
|
|
2529
|
-
},
|
|
2635
|
+
return G(t, e);
|
|
2636
|
+
}, F = 1, Wt = ({
|
|
2530
2637
|
videoTrack: n,
|
|
2531
2638
|
targetSize: e
|
|
2532
2639
|
}) => {
|
|
2533
|
-
const t = n.getSettings(), s = t.width,
|
|
2534
|
-
return Math.max(
|
|
2640
|
+
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? F : s / e.width, a = i === void 0 ? F : i / e.height;
|
|
2641
|
+
return Math.max(r, a, F);
|
|
2535
2642
|
};
|
|
2536
2643
|
class Ht {
|
|
2537
2644
|
ignoreForCodec;
|
|
@@ -2552,8 +2659,8 @@ class Ht {
|
|
|
2552
2659
|
senderFinder: e,
|
|
2553
2660
|
codecProvider: t,
|
|
2554
2661
|
parametersSetter: s
|
|
2555
|
-
},
|
|
2556
|
-
this.senderFinder = e, this.codecProvider = t, this.parametersSetter = s, this.ignoreForCodec =
|
|
2662
|
+
}, i) {
|
|
2663
|
+
this.senderFinder = e, this.codecProvider = t, this.parametersSetter = s, this.ignoreForCodec = i.ignoreForCodec;
|
|
2557
2664
|
}
|
|
2558
2665
|
/**
|
|
2559
2666
|
* Выполняет балансировку на основе заголовков от сервера
|
|
@@ -2562,21 +2669,21 @@ class Ht {
|
|
|
2562
2669
|
* @returns Promise с результатом балансировки
|
|
2563
2670
|
*/
|
|
2564
2671
|
async balance(e, t) {
|
|
2565
|
-
const s = e.getSenders(),
|
|
2566
|
-
if (!
|
|
2567
|
-
return { ...this.resultNoChanged, sender:
|
|
2568
|
-
const
|
|
2569
|
-
if (
|
|
2570
|
-
return { ...this.resultNoChanged, sender:
|
|
2672
|
+
const s = e.getSenders(), i = this.senderFinder.findVideoSender(s);
|
|
2673
|
+
if (!i?.track)
|
|
2674
|
+
return { ...this.resultNoChanged, sender: i };
|
|
2675
|
+
const r = await this.codecProvider.getCodecFromSender(i);
|
|
2676
|
+
if (Te(r, this.ignoreForCodec))
|
|
2677
|
+
return { ...this.resultNoChanged, sender: i };
|
|
2571
2678
|
const { mainCam: a, resolutionMainCam: o } = t ?? {};
|
|
2572
2679
|
return this.processSender(
|
|
2573
2680
|
{ mainCam: a, resolutionMainCam: o },
|
|
2574
2681
|
{
|
|
2575
|
-
sender:
|
|
2576
|
-
codec:
|
|
2577
|
-
videoTrack:
|
|
2682
|
+
sender: i,
|
|
2683
|
+
codec: r,
|
|
2684
|
+
videoTrack: i.track
|
|
2578
2685
|
}
|
|
2579
|
-
).then((c) => ({ ...c, sender:
|
|
2686
|
+
).then((c) => ({ ...c, sender: i }));
|
|
2580
2687
|
}
|
|
2581
2688
|
/**
|
|
2582
2689
|
* Обрабатывает отправитель в зависимости от команды управления
|
|
@@ -2584,14 +2691,14 @@ class Ht {
|
|
|
2584
2691
|
* @returns Promise с результатом обработки
|
|
2585
2692
|
*/
|
|
2586
2693
|
async processSender(e, t) {
|
|
2587
|
-
const { mainCam: s, resolutionMainCam:
|
|
2694
|
+
const { mainCam: s, resolutionMainCam: i } = e;
|
|
2588
2695
|
switch (s) {
|
|
2589
2696
|
case P.PAUSE_MAIN_CAM:
|
|
2590
2697
|
return this.downgradeResolutionSender(t);
|
|
2591
2698
|
case P.RESUME_MAIN_CAM:
|
|
2592
2699
|
return this.setBitrateByTrackResolution(t);
|
|
2593
2700
|
case P.MAX_MAIN_CAM_RESOLUTION:
|
|
2594
|
-
return
|
|
2701
|
+
return i !== void 0 ? this.setResolutionSender(i, t) : this.setBitrateByTrackResolution(t);
|
|
2595
2702
|
case P.ADMIN_STOP_MAIN_CAM:
|
|
2596
2703
|
case P.ADMIN_START_MAIN_CAM:
|
|
2597
2704
|
case void 0:
|
|
@@ -2606,11 +2713,11 @@ class Ht {
|
|
|
2606
2713
|
* @returns Promise с результатом
|
|
2607
2714
|
*/
|
|
2608
2715
|
async downgradeResolutionSender(e) {
|
|
2609
|
-
const { sender: t, codec: s } = e,
|
|
2716
|
+
const { sender: t, codec: s } = e, i = {
|
|
2610
2717
|
scaleResolutionDownBy: 200,
|
|
2611
2718
|
maxBitrate: $t(s)
|
|
2612
2719
|
};
|
|
2613
|
-
return this.parametersSetter.setEncodingsToSender(t,
|
|
2720
|
+
return this.parametersSetter.setEncodingsToSender(t, i);
|
|
2614
2721
|
}
|
|
2615
2722
|
/**
|
|
2616
2723
|
* Устанавливает битрейт на основе разрешения трека
|
|
@@ -2618,7 +2725,7 @@ class Ht {
|
|
|
2618
2725
|
* @returns Promise с результатом
|
|
2619
2726
|
*/
|
|
2620
2727
|
async setBitrateByTrackResolution(e) {
|
|
2621
|
-
const { sender: t, videoTrack: s, codec:
|
|
2728
|
+
const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? Vt(i) : X(a, i);
|
|
2622
2729
|
return this.parametersSetter.setEncodingsToSender(t, {
|
|
2623
2730
|
scaleResolutionDownBy: 1,
|
|
2624
2731
|
maxBitrate: o
|
|
@@ -2631,17 +2738,17 @@ class Ht {
|
|
|
2631
2738
|
* @returns Promise с результатом
|
|
2632
2739
|
*/
|
|
2633
2740
|
async setResolutionSender(e, t) {
|
|
2634
|
-
const [s,
|
|
2741
|
+
const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, c = {
|
|
2635
2742
|
width: Number(s),
|
|
2636
|
-
height: Number(
|
|
2743
|
+
height: Number(i)
|
|
2637
2744
|
}, d = Wt({
|
|
2638
2745
|
videoTrack: a,
|
|
2639
2746
|
targetSize: c
|
|
2640
|
-
}), u =
|
|
2747
|
+
}), u = X(c.width, o), T = {
|
|
2641
2748
|
scaleResolutionDownBy: d,
|
|
2642
2749
|
maxBitrate: u
|
|
2643
2750
|
};
|
|
2644
|
-
return this.parametersSetter.setEncodingsToSender(
|
|
2751
|
+
return this.parametersSetter.setEncodingsToSender(r, T);
|
|
2645
2752
|
}
|
|
2646
2753
|
}
|
|
2647
2754
|
const xt = (n) => n.find((e) => e.track?.kind === "video");
|
|
@@ -2664,7 +2771,7 @@ class Gt {
|
|
|
2664
2771
|
pollIntervalMs: e = 1e3,
|
|
2665
2772
|
maxPollIntervalMs: t
|
|
2666
2773
|
}) {
|
|
2667
|
-
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new
|
|
2774
|
+
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new j();
|
|
2668
2775
|
}
|
|
2669
2776
|
/**
|
|
2670
2777
|
* Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
|
|
@@ -2683,8 +2790,8 @@ class Gt {
|
|
|
2683
2790
|
attachSender(e, t) {
|
|
2684
2791
|
this.currentSender = e;
|
|
2685
2792
|
const s = e.replaceTrack.bind(e);
|
|
2686
|
-
this.originalReplaceTrack = s, e.replaceTrack = async (
|
|
2687
|
-
await s(
|
|
2793
|
+
this.originalReplaceTrack = s, e.replaceTrack = async (i) => {
|
|
2794
|
+
await s(i), this.attachTrack(t, i ?? void 0), t();
|
|
2688
2795
|
}, this.attachTrack(t, e.track);
|
|
2689
2796
|
}
|
|
2690
2797
|
detachSender() {
|
|
@@ -2693,8 +2800,8 @@ class Gt {
|
|
|
2693
2800
|
attachTrack(e, t) {
|
|
2694
2801
|
if (this.detachTrack(), !t)
|
|
2695
2802
|
return;
|
|
2696
|
-
const { width: s, height:
|
|
2697
|
-
this.lastWidth = s, this.lastHeight =
|
|
2803
|
+
const { width: s, height: i } = t.getSettings();
|
|
2804
|
+
this.lastWidth = s, this.lastHeight = i, this.currentPollIntervalMs = this.pollIntervalMs, this.schedulePoll(t, e);
|
|
2698
2805
|
}
|
|
2699
2806
|
/**
|
|
2700
2807
|
* Периодически опрашивает track с экспоненциальной адаптацией частоты.
|
|
@@ -2703,8 +2810,8 @@ class Gt {
|
|
|
2703
2810
|
*/
|
|
2704
2811
|
schedulePoll(e, t) {
|
|
2705
2812
|
const s = () => {
|
|
2706
|
-
const { width:
|
|
2707
|
-
|
|
2813
|
+
const { width: i, height: r } = e.getSettings();
|
|
2814
|
+
i !== this.lastWidth || r !== this.lastHeight ? (this.lastWidth = i, this.lastHeight = r, this.currentPollIntervalMs = this.pollIntervalMs, t()) : this.currentPollIntervalMs = Math.min(
|
|
2708
2815
|
this.currentPollIntervalMs * 2,
|
|
2709
2816
|
this.maxPollIntervalMs
|
|
2710
2817
|
), this.setTimeoutRequest.request(s, this.currentPollIntervalMs);
|
|
@@ -2744,10 +2851,10 @@ class Yt {
|
|
|
2744
2851
|
trackMonitor;
|
|
2745
2852
|
constructor(e, t, {
|
|
2746
2853
|
ignoreForCodec: s,
|
|
2747
|
-
onSetParameters:
|
|
2748
|
-
pollIntervalMs:
|
|
2854
|
+
onSetParameters: i,
|
|
2855
|
+
pollIntervalMs: r
|
|
2749
2856
|
} = {}) {
|
|
2750
|
-
this.getConnection = t, this.eventHandler = new Qt(e), this.parametersSetterWithQueue = new
|
|
2857
|
+
this.getConnection = t, this.eventHandler = new Qt(e), this.parametersSetterWithQueue = new wt(i), this.senderBalancer = new Ht(
|
|
2751
2858
|
{
|
|
2752
2859
|
senderFinder: new qt(),
|
|
2753
2860
|
codecProvider: new yt(),
|
|
@@ -2756,7 +2863,7 @@ class Yt {
|
|
|
2756
2863
|
{
|
|
2757
2864
|
ignoreForCodec: s
|
|
2758
2865
|
}
|
|
2759
|
-
), this.trackMonitor = new Gt({ pollIntervalMs:
|
|
2866
|
+
), this.trackMonitor = new Gt({ pollIntervalMs: r });
|
|
2760
2867
|
}
|
|
2761
2868
|
/**
|
|
2762
2869
|
* Подписывается на события управления главной камерой
|
|
@@ -2787,7 +2894,7 @@ class Yt {
|
|
|
2787
2894
|
const t = await this.senderBalancer.balance(e, this.serverHeaders);
|
|
2788
2895
|
return this.trackMonitor.subscribe(t.sender, () => {
|
|
2789
2896
|
this.balance().catch((s) => {
|
|
2790
|
-
|
|
2897
|
+
E("balance on track change: error", s);
|
|
2791
2898
|
});
|
|
2792
2899
|
}), t;
|
|
2793
2900
|
}
|
|
@@ -2797,11 +2904,11 @@ class Yt {
|
|
|
2797
2904
|
*/
|
|
2798
2905
|
handleMainCamControl = (e) => {
|
|
2799
2906
|
this.serverHeaders = e, this.balance().catch((t) => {
|
|
2800
|
-
|
|
2907
|
+
E("handleMainCamControl: error", t);
|
|
2801
2908
|
});
|
|
2802
2909
|
};
|
|
2803
2910
|
}
|
|
2804
|
-
const
|
|
2911
|
+
const Ee = [
|
|
2805
2912
|
"balancing-scheduled",
|
|
2806
2913
|
"balancing-started",
|
|
2807
2914
|
"balancing-stopped",
|
|
@@ -2815,13 +2922,13 @@ class zt {
|
|
|
2815
2922
|
videoSendingBalancer;
|
|
2816
2923
|
startBalancingTimer;
|
|
2817
2924
|
constructor(e, t, s = {}) {
|
|
2818
|
-
this.events = new
|
|
2925
|
+
this.events = new H(Ee), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new Yt(
|
|
2819
2926
|
t,
|
|
2820
2927
|
() => e.connection,
|
|
2821
2928
|
{
|
|
2822
2929
|
...s,
|
|
2823
|
-
onSetParameters: (
|
|
2824
|
-
this.events.trigger("parameters-updated",
|
|
2930
|
+
onSetParameters: (i) => {
|
|
2931
|
+
this.events.trigger("parameters-updated", i), s.onSetParameters?.(i);
|
|
2825
2932
|
}
|
|
2826
2933
|
}
|
|
2827
2934
|
), this.subscribe();
|
|
@@ -2877,7 +2984,7 @@ class zt {
|
|
|
2877
2984
|
scheduleBalancingStart() {
|
|
2878
2985
|
this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
|
|
2879
2986
|
this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
|
|
2880
|
-
|
|
2987
|
+
E("startBalancing: error", e);
|
|
2881
2988
|
});
|
|
2882
2989
|
}, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
|
|
2883
2990
|
}
|
|
@@ -2885,7 +2992,7 @@ class zt {
|
|
|
2885
2992
|
this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
|
|
2886
2993
|
}
|
|
2887
2994
|
}
|
|
2888
|
-
const Xt = 1e6, Jt =
|
|
2995
|
+
const Xt = 1e6, Jt = de.map((n) => `connection:${n}`), Kt = te.map((n) => `call:${n}`), jt = Z.map((n) => `api:${n}`), Zt = le.map((n) => `incoming-call:${n}`), en = oe.map((n) => `presentation:${n}`), tn = ge.map((n) => `stats:${n}`), nn = Ee.map((n) => `video-balancer:${n}`), sn = [
|
|
2889
2996
|
...Jt,
|
|
2890
2997
|
...Kt,
|
|
2891
2998
|
...jt,
|
|
@@ -2904,28 +3011,32 @@ class En {
|
|
|
2904
3011
|
presentationManager;
|
|
2905
3012
|
statsManager;
|
|
2906
3013
|
videoSendingBalancerManager;
|
|
3014
|
+
transceiverManager;
|
|
2907
3015
|
preferredMimeTypesVideoCodecs;
|
|
2908
3016
|
excludeMimeTypesVideoCodecs;
|
|
2909
3017
|
constructor({ JsSIP: e }, {
|
|
2910
3018
|
preferredMimeTypesVideoCodecs: t,
|
|
2911
3019
|
excludeMimeTypesVideoCodecs: s,
|
|
2912
|
-
videoBalancerOptions:
|
|
3020
|
+
videoBalancerOptions: i
|
|
2913
3021
|
} = {}) {
|
|
2914
|
-
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new
|
|
3022
|
+
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new w(sn), this.connectionManager = new ct({ JsSIP: e }), this.connectionQueueManager = new dt({
|
|
2915
3023
|
connectionManager: this.connectionManager
|
|
2916
|
-
}), this.callManager = new
|
|
3024
|
+
}), this.callManager = new Fe(), this.apiManager = new ve({
|
|
2917
3025
|
connectionManager: this.connectionManager,
|
|
2918
3026
|
callManager: this.callManager
|
|
2919
|
-
}), this.incomingCallManager = new
|
|
3027
|
+
}), this.incomingCallManager = new gt(this.connectionManager), this.presentationManager = new Ze({
|
|
2920
3028
|
callManager: this.callManager,
|
|
2921
3029
|
maxBitrate: Xt
|
|
2922
|
-
}), this.statsManager = new
|
|
3030
|
+
}), this.statsManager = new It({
|
|
3031
|
+
callManager: this.callManager,
|
|
3032
|
+
apiManager: this.apiManager
|
|
3033
|
+
}), this.transceiverManager = new vt({
|
|
2923
3034
|
callManager: this.callManager,
|
|
2924
3035
|
apiManager: this.apiManager
|
|
2925
3036
|
}), this.videoSendingBalancerManager = new zt(
|
|
2926
3037
|
this.callManager,
|
|
2927
3038
|
this.apiManager,
|
|
2928
|
-
|
|
3039
|
+
i
|
|
2929
3040
|
), this.subscribe();
|
|
2930
3041
|
}
|
|
2931
3042
|
get requestedConnection() {
|
|
@@ -3005,9 +3116,7 @@ class En {
|
|
|
3005
3116
|
this.getSipServerUrl,
|
|
3006
3117
|
{
|
|
3007
3118
|
...s,
|
|
3008
|
-
onAddedTransceiver:
|
|
3009
|
-
this.setCodecPreferences(r), await t?.(r, i, a);
|
|
3010
|
-
}
|
|
3119
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(t)
|
|
3011
3120
|
}
|
|
3012
3121
|
);
|
|
3013
3122
|
};
|
|
@@ -3018,9 +3127,7 @@ class En {
|
|
|
3018
3127
|
this.incomingCallManager.extractIncomingRTCSession,
|
|
3019
3128
|
{
|
|
3020
3129
|
...s,
|
|
3021
|
-
onAddedTransceiver:
|
|
3022
|
-
this.setCodecPreferences(r), await t?.(r, i, a);
|
|
3023
|
-
}
|
|
3130
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(t)
|
|
3024
3131
|
}
|
|
3025
3132
|
);
|
|
3026
3133
|
};
|
|
@@ -3030,7 +3137,7 @@ class En {
|
|
|
3030
3137
|
getRemoteStreams = () => this.callManager.getRemoteStreams();
|
|
3031
3138
|
replaceMediaStream = async (...e) => this.callManager.replaceMediaStream(...e);
|
|
3032
3139
|
async startPresentation(e, t = {}) {
|
|
3033
|
-
const { isP2P: s, callLimit:
|
|
3140
|
+
const { isP2P: s, callLimit: i, onAddedTransceiver: r, ...a } = t;
|
|
3034
3141
|
return this.presentationManager.startPresentation(
|
|
3035
3142
|
async () => {
|
|
3036
3143
|
s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
|
|
@@ -3038,11 +3145,9 @@ class En {
|
|
|
3038
3145
|
e,
|
|
3039
3146
|
{
|
|
3040
3147
|
...a,
|
|
3041
|
-
onAddedTransceiver:
|
|
3042
|
-
this.setCodecPreferences(o), await i?.(o, c, d);
|
|
3043
|
-
}
|
|
3148
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(r)
|
|
3044
3149
|
},
|
|
3045
|
-
|
|
3150
|
+
i === void 0 ? void 0 : { callLimit: i }
|
|
3046
3151
|
);
|
|
3047
3152
|
}
|
|
3048
3153
|
async stopPresentation(e = {}) {
|
|
@@ -3052,17 +3157,15 @@ class En {
|
|
|
3052
3157
|
});
|
|
3053
3158
|
}
|
|
3054
3159
|
async updatePresentation(e, t = {}) {
|
|
3055
|
-
const { isP2P: s, onAddedTransceiver:
|
|
3160
|
+
const { isP2P: s, onAddedTransceiver: i, ...r } = t;
|
|
3056
3161
|
return this.presentationManager.updatePresentation(
|
|
3057
3162
|
async () => {
|
|
3058
3163
|
s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
|
|
3059
3164
|
},
|
|
3060
3165
|
e,
|
|
3061
3166
|
{
|
|
3062
|
-
...
|
|
3063
|
-
onAddedTransceiver:
|
|
3064
|
-
this.setCodecPreferences(a), await r?.(a, o, c);
|
|
3065
|
-
}
|
|
3167
|
+
...r,
|
|
3168
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(i)
|
|
3066
3169
|
}
|
|
3067
3170
|
);
|
|
3068
3171
|
}
|
|
@@ -3109,61 +3212,38 @@ class En {
|
|
|
3109
3212
|
return this.apiManager.askPermissionToEnableCam(...e);
|
|
3110
3213
|
}
|
|
3111
3214
|
setCodecPreferences(e) {
|
|
3112
|
-
|
|
3215
|
+
Pt(e, {
|
|
3113
3216
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
3114
3217
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
3115
3218
|
});
|
|
3116
3219
|
}
|
|
3117
3220
|
subscribe() {
|
|
3118
|
-
this.connectionManager.
|
|
3119
|
-
this.connectionManager.on(t, (s) => {
|
|
3120
|
-
this.events.trigger(`connection:${t}`, s);
|
|
3121
|
-
});
|
|
3122
|
-
}), this.callManager.events.eachTriggers((e, t) => {
|
|
3123
|
-
this.callManager.on(t, (s) => {
|
|
3124
|
-
this.events.trigger(`call:${t}`, s);
|
|
3125
|
-
});
|
|
3126
|
-
}), this.apiManager.events.eachTriggers((e, t) => {
|
|
3127
|
-
this.apiManager.on(t, (s) => {
|
|
3128
|
-
this.events.trigger(`api:${t}`, s);
|
|
3129
|
-
});
|
|
3130
|
-
}), this.incomingCallManager.events.eachTriggers((e, t) => {
|
|
3131
|
-
this.incomingCallManager.on(t, (s) => {
|
|
3132
|
-
this.events.trigger(`incoming-call:${t}`, s);
|
|
3133
|
-
});
|
|
3134
|
-
}), this.presentationManager.events.eachTriggers((e, t) => {
|
|
3135
|
-
this.presentationManager.on(t, (s) => {
|
|
3136
|
-
this.events.trigger(`presentation:${t}`, s);
|
|
3137
|
-
});
|
|
3138
|
-
}), this.statsManager.events.eachTriggers((e, t) => {
|
|
3139
|
-
this.statsManager.on(t, (s) => {
|
|
3140
|
-
this.events.trigger(`stats:${t}`, s);
|
|
3141
|
-
});
|
|
3142
|
-
}), this.videoSendingBalancerManager.events.eachTriggers((e, t) => {
|
|
3143
|
-
this.videoSendingBalancerManager.on(t, (s) => {
|
|
3144
|
-
this.events.trigger(`video-balancer:${t}`, s);
|
|
3145
|
-
});
|
|
3146
|
-
}), this.apiManager.on("restart", this.handleRestart);
|
|
3221
|
+
this.bridgeEvents("connection", this.connectionManager), this.bridgeEvents("call", this.callManager), this.bridgeEvents("api", this.apiManager), this.bridgeEvents("incoming-call", this.incomingCallManager), this.bridgeEvents("presentation", this.presentationManager), this.bridgeEvents("stats", this.statsManager), this.bridgeEvents("video-balancer", this.videoSendingBalancerManager);
|
|
3147
3222
|
}
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3223
|
+
bridgeEvents = (e, t) => {
|
|
3224
|
+
t.events.eachTriggers((s, i) => {
|
|
3225
|
+
t.on(i, (r) => {
|
|
3226
|
+
this.events.trigger(`${e}:${i}`, r);
|
|
3227
|
+
});
|
|
3151
3228
|
});
|
|
3152
3229
|
};
|
|
3230
|
+
resolveHandleAddTransceiver = (e) => async (t, s, i) => {
|
|
3231
|
+
this.setCodecPreferences(t), await e?.(t, s, i);
|
|
3232
|
+
};
|
|
3153
3233
|
}
|
|
3154
3234
|
export {
|
|
3155
|
-
|
|
3156
|
-
|
|
3235
|
+
se as E,
|
|
3236
|
+
fe as O,
|
|
3157
3237
|
En as S,
|
|
3158
|
-
|
|
3159
|
-
|
|
3238
|
+
Xe as a,
|
|
3239
|
+
Pe as b,
|
|
3160
3240
|
C as c,
|
|
3161
3241
|
Sn as d,
|
|
3162
3242
|
Tn as e,
|
|
3163
|
-
|
|
3243
|
+
Rt as f,
|
|
3164
3244
|
Dt as g,
|
|
3165
3245
|
Cn as h,
|
|
3166
|
-
|
|
3246
|
+
E as l,
|
|
3167
3247
|
B as p,
|
|
3168
|
-
|
|
3248
|
+
ae as s
|
|
3169
3249
|
};
|