@vkontakte/calls-sdk 2.8.13-dev.05e6b21e.0 → 2.8.13-dev.06c783b8.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/calls-sdk.cjs.js +7 -7
- package/calls-sdk.esm.js +932 -825
- package/classes/AudioOutput.d.ts +1 -3
- package/classes/MediaSource.d.ts +1 -3
- package/classes/stat/ConversationStats.d.ts +0 -2
- package/classes/stat/NetworkAdaptationStats.d.ts +35 -0
- package/classes/stat/PeerConnectionStats.d.ts +22 -0
- package/classes/stat/Stat.testUtils.d.ts +10 -0
- package/classes/transport/DirectTransport.d.ts +6 -0
- package/classes/transport/PerfStatReporter.d.ts +2 -0
- package/classes/transport/ServerTransport.d.ts +1 -0
- package/default/SignalingTransport.d.ts +5 -1
- package/enums/Stat.d.ts +9 -3
- package/package.json +1 -1
- package/static/Params.d.ts +12 -0
- package/classes/stat/MediaStats.d.ts +0 -22
package/calls-sdk.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @vkontakte/calls-sdk v2.8.13-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/calls-sdk v2.8.13-dev.06c783b8.0
|
|
3
|
+
* Wed, 07 Oct 2026 16:53:48 GMT
|
|
4
4
|
* https://calls-sdk.cdn-vk.ru/doc/latest/index.html
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -121,7 +121,6 @@ var v = new class {
|
|
|
121
121
|
t.objectStore(g).clear(), t.objectStore(_).clear(), await this.txDone(t).catch((e) => console.warn("Failed to clear debug log storage", e));
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
this.close();
|
|
125
124
|
}
|
|
126
125
|
async getAllSessions() {
|
|
127
126
|
let e = await this.open();
|
|
@@ -1244,8 +1243,8 @@ var O = /* @__PURE__ */ function(e) {
|
|
|
1244
1243
|
}({}), Jt = /* @__PURE__ */ function(e) {
|
|
1245
1244
|
return e[e.CAMERA = 1] = "CAMERA", e[e.SCREEN = 2] = "SCREEN", e;
|
|
1246
1245
|
}({}), Yt = class extends b {
|
|
1247
|
-
constructor(e = z, t = null
|
|
1248
|
-
super(), h(this, "_stream", null), h(this, "_screenTrack", null), h(this, "_audioShareTrack", null), h(this, "_screenShareTrack", null), h(this, "_sendVideoTrack", null), h(this, "_cameraVideoTrack", null), h(this, "_micAudioTrack", null), h(this, "_audioEffectsTrack", null), h(this, "_mediaSettings", D()), h(this, "_lastMediaSettings", null), h(this, "_videoStatusOnScreenCapturingEnabled", !1), h(this, "_effect", null), h(this, "_audioEffectParams", null), h(this, "_onDeviceChange", void 0), h(this, "_animojiEnabled", !1), h(this, "_videoEffectsFpsLimiter", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "
|
|
1246
|
+
constructor(e = z, t = null) {
|
|
1247
|
+
super(), h(this, "_stream", null), h(this, "_screenTrack", null), h(this, "_audioShareTrack", null), h(this, "_screenShareTrack", null), h(this, "_sendVideoTrack", null), h(this, "_cameraVideoTrack", null), h(this, "_micAudioTrack", null), h(this, "_audioEffectsTrack", null), h(this, "_mediaSettings", D()), h(this, "_lastMediaSettings", null), h(this, "_videoStatusOnScreenCapturingEnabled", !1), h(this, "_effect", null), h(this, "_audioEffectParams", null), h(this, "_onDeviceChange", void 0), h(this, "_animojiEnabled", !1), h(this, "_videoEffectsFpsLimiter", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_cameraTrackSetAt", 0), h(this, "_cameraMuteRecoveredAt", 0), h(this, "_micTrackSetAt", 0), h(this, "_micMuteRecoveredAt", 0), h(this, "videoTrackMuteHandler", () => {
|
|
1249
1248
|
!this._mediaSettings.isVideoEnabled || this._cameraMuteRecoveredAt >= this._cameraTrackSetAt || E.browserName() !== "Safari" || (this._cameraMuteRecoveredAt = Date.now(), this._logger?.log(C.ERROR, "camera_mute_recover"), this._debug.log("[MediaSource] Safari camera mute recovery"), this.toggleVideo(!0).then(() => this._logger?.log(C.ERROR, "camera_mute_recover_success")).catch((e) => {
|
|
1250
1249
|
this._logger?.log(C.ERROR, "camera_mute_recover_fail"), this._debug.warn("[MediaSource] Camera mute recovery failed", e);
|
|
1251
1250
|
}));
|
|
@@ -1253,7 +1252,7 @@ var O = /* @__PURE__ */ function(e) {
|
|
|
1253
1252
|
!this._mediaSettings.isAudioEnabled || this._micMuteRecoveredAt >= this._micTrackSetAt || E.browserName() !== "Safari" || (this._micMuteRecoveredAt = Date.now(), this._logger?.log(C.ERROR, "mic_mute_recover"), this._debug.log("[MediaSource] Safari mic mute recovery"), this.toggleAudio(!0).then(() => this._logger?.log(C.ERROR, "mic_mute_recover_success")).catch((e) => {
|
|
1254
1253
|
this._logger?.log(C.ERROR, "mic_mute_recover_fail"), this._debug.warn("[MediaSource] Mic mute recovery failed", e);
|
|
1255
1254
|
}));
|
|
1256
|
-
}), this._debug = e, this._logger = t, this.
|
|
1255
|
+
}), this._debug = e, this._logger = t, this._initDeviceChangeListener(), N.audioShare && (this._audioShareTrack = this.getSilentAudioShareTrack()), N.enableVideoEffectsFpsDegradation && (this._videoEffectsFpsLimiter = new Kt(this._debug), this._videoEffectsFpsLimiter.addEventListener(Gt.FpsLimit, this.handleVideoEffectsLowFps.bind(this)));
|
|
1257
1256
|
}
|
|
1258
1257
|
get cameraVideoTrack() {
|
|
1259
1258
|
return this._cameraVideoTrack;
|
|
@@ -1272,7 +1271,7 @@ var O = /* @__PURE__ */ function(e) {
|
|
|
1272
1271
|
try {
|
|
1273
1272
|
this._stream = await E.getUserMedia(n, r, t, this._debug, this._logger), this.cameraVideoTrack?.stop(), this.cameraVideoTrack = this._stream.getVideoTracks()[0], this._micAudioTrack?.stop(), this._setMicAudioTrack(this._stream.getAudioTracks()[0]), this._audioEffectsTrack?.stop(), this._mediaSettings.isVideoEnabled = n && this._stream.getVideoTracks().filter((e) => e.enabled).length > 0 || !1, this._mediaSettings.isAudioEnabled = r && this._stream.getAudioTracks().filter((e) => e.enabled).length > 0 || !1, this._mediaSettings.isAnimojiEnabled = i && !this._mediaSettings.isVideoEnabled || !1, this._animojiEnabled = i, this._triggerEvent("SOURCE_READY");
|
|
1274
1273
|
} catch (e) {
|
|
1275
|
-
throw
|
|
1274
|
+
throw new k(e);
|
|
1276
1275
|
}
|
|
1277
1276
|
}
|
|
1278
1277
|
getStream() {
|
|
@@ -1358,7 +1357,7 @@ var O = /* @__PURE__ */ function(e) {
|
|
|
1358
1357
|
this._logger?.log(C.DEVICE_CHANGED, "audio"), this._debug.log("Audio stream changed", e), await this._replaceLocalTrack(e), this._mediaSettings.isAudioEnabled = !0, this._triggerEvent("SOURCE_CHANGED", { kind: "audio" });
|
|
1359
1358
|
}
|
|
1360
1359
|
} catch (e) {
|
|
1361
|
-
throw this._logger?.log(C.ERROR, "change_audio"), this.
|
|
1360
|
+
throw this._logger?.log(C.ERROR, "change_audio"), this._debug.error("Microphone change failed", e), e;
|
|
1362
1361
|
}
|
|
1363
1362
|
}
|
|
1364
1363
|
async _changeScreen(e, t, n) {
|
|
@@ -1389,15 +1388,7 @@ var O = /* @__PURE__ */ function(e) {
|
|
|
1389
1388
|
}
|
|
1390
1389
|
async _applyAudioEffect() {
|
|
1391
1390
|
if (!N.audioEffects || !this._audioEffectParams) return N.audioEffects?.pause(), this._micAudioTrack;
|
|
1392
|
-
|
|
1393
|
-
let e = Date.now();
|
|
1394
|
-
try {
|
|
1395
|
-
await N.audioEffects.init(), this._mediaStats?.logMlReady("audio_effects", Date.now() - e);
|
|
1396
|
-
} catch (e) {
|
|
1397
|
-
throw this._mediaStats?.logMlError("audio_effects", e), e;
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
N.audioEffects.resume(), N.audioEffects.setEffects(this._audioEffectParams.effects, this._audioEffectParams.isPreset), N.audioEffects.setSource(this._micAudioTrack);
|
|
1391
|
+
N.audioEffects.isInitialized || await N.audioEffects.init(), N.audioEffects.resume(), N.audioEffects.setEffects(this._audioEffectParams.effects, this._audioEffectParams.isPreset), N.audioEffects.setSource(this._micAudioTrack);
|
|
1401
1392
|
let e = N.audioEffects.outputStream.getAudioTracks()[0];
|
|
1402
1393
|
return (!this._audioEffectsTrack || this._audioEffectsTrack.id !== e.id) && (this._audioEffectsTrack = e), this._audioEffectsTrack;
|
|
1403
1394
|
}
|
|
@@ -1484,7 +1475,7 @@ var O = /* @__PURE__ */ function(e) {
|
|
|
1484
1475
|
let e = await E.getUserAudio(void 0, this._debug, this._logger);
|
|
1485
1476
|
this._setMicAudioTrack(e.getAudioTracks()[0]), await t(await this._applyAudioEffect(), !0);
|
|
1486
1477
|
} catch (e) {
|
|
1487
|
-
throw
|
|
1478
|
+
throw N.audioEffects?.pause(), await t(E.getSilentMediaTrack(), !1), typeof e == "string" ? Error(e) : e;
|
|
1488
1479
|
}
|
|
1489
1480
|
else N.audioEffects?.pause(), await t(E.getSilentMediaTrack(), !1);
|
|
1490
1481
|
}
|
|
@@ -2190,7 +2181,7 @@ var xn = bn.getInstance(), N = class e {
|
|
|
2190
2181
|
return 1.1;
|
|
2191
2182
|
}
|
|
2192
2183
|
static get sdkVersion() {
|
|
2193
|
-
return "2.8.13-dev.
|
|
2184
|
+
return "2.8.13-dev.06c783b8.0";
|
|
2194
2185
|
}
|
|
2195
2186
|
static get debug() {
|
|
2196
2187
|
return e._params.debug;
|
|
@@ -2318,6 +2309,9 @@ var xn = bn.getInstance(), N = class e {
|
|
|
2318
2309
|
static get signalingReconnectMaxCount() {
|
|
2319
2310
|
return e._params.signalingReconnectMaxCount;
|
|
2320
2311
|
}
|
|
2312
|
+
static get signalingReconnectMaxDuration() {
|
|
2313
|
+
return e._params.signalingReconnectMaxDuration;
|
|
2314
|
+
}
|
|
2321
2315
|
static get waitConnectionDelay() {
|
|
2322
2316
|
return e._params.waitConnectionDelay;
|
|
2323
2317
|
}
|
|
@@ -2456,6 +2450,9 @@ var xn = bn.getInstance(), N = class e {
|
|
|
2456
2450
|
static get callStatReportEnabled() {
|
|
2457
2451
|
return e._params.callStatReportEnabled;
|
|
2458
2452
|
}
|
|
2453
|
+
static get iceCandidateErrorStatEnabled() {
|
|
2454
|
+
return e._params.iceCandidateErrorStatEnabled;
|
|
2455
|
+
}
|
|
2459
2456
|
static get enableLogPerfStatReport() {
|
|
2460
2457
|
return e._params.enableLogPerfStatReport;
|
|
2461
2458
|
}
|
|
@@ -2620,6 +2617,7 @@ var xn = bn.getInstance(), N = class e {
|
|
|
2620
2617
|
videoSuspend: e._params.videoSuspend,
|
|
2621
2618
|
debugLog: e._params.debugLog,
|
|
2622
2619
|
callStatReportEnabled: e._params.callStatReportEnabled,
|
|
2620
|
+
iceCandidateErrorStatEnabled: e._params.iceCandidateErrorStatEnabled,
|
|
2623
2621
|
joinFromMultipleDevices: e._params.joinFromMultipleDevices,
|
|
2624
2622
|
movieShare: e._params.movieShare,
|
|
2625
2623
|
clientType: e._params.clientType,
|
|
@@ -2662,6 +2660,7 @@ h(N, "_params", {
|
|
|
2662
2660
|
signalingReconnectDelay: 1e3,
|
|
2663
2661
|
signalingReconnectMaxDelay: 5e3,
|
|
2664
2662
|
signalingReconnectMaxCount: 10,
|
|
2663
|
+
signalingReconnectMaxDuration: 6e4,
|
|
2665
2664
|
waitConnectionDelay: 1e4,
|
|
2666
2665
|
waitResponseDelay: 1e4,
|
|
2667
2666
|
waitMessageDelay: 15e3,
|
|
@@ -2695,6 +2694,7 @@ h(N, "_params", {
|
|
|
2695
2694
|
networkStatisticsInterval: 2e4,
|
|
2696
2695
|
perfStatReportEnabled: !0,
|
|
2697
2696
|
callStatReportEnabled: !1,
|
|
2697
|
+
iceCandidateErrorStatEnabled: !1,
|
|
2698
2698
|
enableLogPerfStatReport: !1,
|
|
2699
2699
|
voiceParams: {
|
|
2700
2700
|
smoothing: .8,
|
|
@@ -3642,7 +3642,7 @@ var Bn = 0, Vn = 1, Hn = 2, Un = 3, Wn = 4, Gn = 5, Kn = 6, qn = 7, Jn = 0, Yn =
|
|
|
3642
3642
|
};
|
|
3643
3643
|
}
|
|
3644
3644
|
}, U = /* @__PURE__ */ function(e) {
|
|
3645
|
-
return e.CALL_INIT = "call_init", e.CALL_START = "call_start", e.CALL_ACCEPTED_OUTGOING = "call_accepted_outgoing", e.CALL_ACCEPTED_INCOMING = "call_accepted_incoming", e.FIRST_MEDIA_SENT = "first_media_sent", e.CALL_FINISH = "call_finish", e.CODEC_USAGE = "codec_usage", e.SIGNALING_CONNECTED = "signaling_connected", e.SCREENSHARE_FIRST_FRAME = "screen_share_first_frame", e.FIRST_MEDIA_RECEIVED = "first_media_received", e.CALL_DECLINED_OR_HANGED_LOCALLY = "CallDeclinedOrHangedLocally", e.USER_FEEDBACK_RECEIVED = "UserFeedbackReceived", e.SIGNALING_PING_SUMMARY = "signaling_ping_summary", e.SIGNALING_COMMAND_SUMMARY = "signaling_command_summary", e.API_CALL = "api_call", e.SDP_CREATE_OFFER = "sdp_create_offer", e.SDP_CREATE_ANSWER = "sdp_create_answer", e.SDP_SET_LOCAL_OFFER = "sdp_set_local_offer", e.SDP_SET_LOCAL_PRANSWER = "sdp_set_local_pranswer", e.SDP_SET_LOCAL_ANSWER = "sdp_set_local_answer", e.SDP_SET_LOCAL_ROLLBACK = "sdp_set_local_rollback", e.SDP_SET_REMOTE_OFFER = "sdp_set_remote_offer", e.SDP_SET_REMOTE_PRANSWER = "sdp_set_remote_pranswer", e.SDP_SET_REMOTE_ANSWER = "sdp_set_remote_answer", e.SDP_SET_REMOTE_ROLLBACK = "sdp_set_remote_rollback", e.SDP_GENERATED = "sdp_generated", e.SDP_RECEIVED = "sdp_received", e.
|
|
3645
|
+
return e.CALL_INIT = "call_init", e.CALL_START = "call_start", e.CALL_ACCEPTED_OUTGOING = "call_accepted_outgoing", e.CALL_ACCEPTED_INCOMING = "call_accepted_incoming", e.FIRST_MEDIA_SENT = "first_media_sent", e.CALL_FINISH = "call_finish", e.CODEC_USAGE = "codec_usage", e.SIGNALING_CONNECTED = "signaling_connected", e.SCREENSHARE_FIRST_FRAME = "screen_share_first_frame", e.FIRST_MEDIA_RECEIVED = "first_media_received", e.CALL_DECLINED_OR_HANGED_LOCALLY = "CallDeclinedOrHangedLocally", e.USER_FEEDBACK_RECEIVED = "UserFeedbackReceived", e.SIGNALING_PING_SUMMARY = "signaling_ping_summary", e.SIGNALING_COMMAND_SUMMARY = "signaling_command_summary", e.API_CALL = "api_call", e.CONNECTION_STATE_CHANGED = "connection_state_changed", e.SIGNALING_STATE_CHANGED = "signaling_state_changed", e.GATHERING_STATE_CHANGED = "gathering_state_changed", e.ICE_RESTART = "ice_restart", e.ICE_CANDIDATES_CHANGED = "ice_candidates_changed", e.ICE_CANDIDATE_GATHERING_FAILED = "ice_candidate_gathering_failed", e.ICE_CANDIDATE_ADD_FAILED = "ice_candidate_add_failed", e.SDP_CREATE_OFFER = "sdp_create_offer", e.SDP_CREATE_ANSWER = "sdp_create_answer", e.SDP_SET_LOCAL_OFFER = "sdp_set_local_offer", e.SDP_SET_LOCAL_PRANSWER = "sdp_set_local_pranswer", e.SDP_SET_LOCAL_ANSWER = "sdp_set_local_answer", e.SDP_SET_LOCAL_ROLLBACK = "sdp_set_local_rollback", e.SDP_SET_REMOTE_OFFER = "sdp_set_remote_offer", e.SDP_SET_REMOTE_PRANSWER = "sdp_set_remote_pranswer", e.SDP_SET_REMOTE_ANSWER = "sdp_set_remote_answer", e.SDP_SET_REMOTE_ROLLBACK = "sdp_set_remote_rollback", e.SDP_GENERATED = "sdp_generated", e.SDP_RECEIVED = "sdp_received", e.CLIENT_REQUESTED_SERVER_TOPOLOGY = "client_requested_server_topology", e.VIDEO_ENCODER_CHANGED_BY_NETWORK_ADAPTER = "video_encoder_changed_by_network_adapter", e.WEBSOCKET_CONNECTED = "websocket_connected", e.WEBSOCKET_RECONNECTED = "websocket_reconnected", e.WEBSOCKET_FAILED_PINGS = "websocket_failed_pings", e.WEBSOCKET_FAILED_EXCEPTION = "websocket_failed_exception", e.WEBSOCKET_TIMEOUT = "websocket_timeout", e.WEBSOCKET_RESTART = "websocket_restart", e.WEBTRANSPORT_CONNECTED = "webtransport_connected", e.WEBTRANSPORT_RECONNECTED = "webtransport_reconnected", e.WEBTRANSPORT_FAILED_PINGS = "webtransport_failed_pings", e.WEBTRANSPORT_FAILED_EXCEPTION = "webtransport_failed_exception", e.WEBTRANSPORT_TIMEOUT = "webtransport_timeout", e.WEBTRANSPORT_RESTART = "webtransport_restart", e;
|
|
3646
3646
|
}(U || {}), nr = 1e3;
|
|
3647
3647
|
function W(e, t, n = 0) {
|
|
3648
3648
|
return t in e && e[t] ? e[t] : n;
|
|
@@ -4002,14 +4002,111 @@ function Hr(e) {
|
|
|
4002
4002
|
return Br.test(e) || e.includes(":") && Vr.test(e);
|
|
4003
4003
|
}
|
|
4004
4004
|
//#endregion
|
|
4005
|
-
//#region src/classes/stat/
|
|
4006
|
-
var Ur =
|
|
4007
|
-
|
|
4005
|
+
//#region src/classes/stat/PeerConnectionStats.ts
|
|
4006
|
+
var Ur = /[?&]transport=(tcp|udp)/i, Wr = {
|
|
4007
|
+
stable: "stable",
|
|
4008
|
+
"have-local-offer": "have.local.offer",
|
|
4009
|
+
"have-local-pranswer": "have.local.answer",
|
|
4010
|
+
"have-remote-offer": "have.remote.offer",
|
|
4011
|
+
"have-remote-pranswer": "have.remote.answer",
|
|
4012
|
+
closed: "closed"
|
|
4013
|
+
}, Gr = class {
|
|
4014
|
+
constructor(e) {
|
|
4015
|
+
h(this, "_statAggregator", void 0), h(this, "_pc", null), h(this, "_lastSignalingStateChange", 0), h(this, "_lastGatheringStateChange", 0), h(this, "_lastConnectionState", null), h(this, "_handleConnectionStateChange", () => {
|
|
4016
|
+
this._pc && this._logConnectionState(this._pc.connectionState);
|
|
4017
|
+
}), h(this, "_handleSignalingStateChange", () => {
|
|
4018
|
+
let e = this._pc?.signalingState;
|
|
4019
|
+
this._log({
|
|
4020
|
+
name: U.SIGNALING_STATE_CHANGED,
|
|
4021
|
+
value: this._sinceLastChange("_lastSignalingStateChange"),
|
|
4022
|
+
string_value: e ? Wr[e] : void 0
|
|
4023
|
+
});
|
|
4024
|
+
}), h(this, "_handleGatheringStateChange", () => {
|
|
4025
|
+
let e = this._pc?.iceGatheringState, t = this._sinceLastChange("_lastGatheringStateChange");
|
|
4026
|
+
this._log({
|
|
4027
|
+
name: U.GATHERING_STATE_CHANGED,
|
|
4028
|
+
value: e === "new" ? 0 : t,
|
|
4029
|
+
string_value: e
|
|
4030
|
+
});
|
|
4031
|
+
}), h(this, "_handleIceCandidateError", (e) => {
|
|
4032
|
+
if (!N.iceCandidateErrorStatEnabled) return;
|
|
4033
|
+
let t = e;
|
|
4034
|
+
this._log({
|
|
4035
|
+
name: U.ICE_CANDIDATE_GATHERING_FAILED,
|
|
4036
|
+
value: t.errorCode,
|
|
4037
|
+
string_value: t.errorText,
|
|
4038
|
+
local_address: t.address ?? "",
|
|
4039
|
+
remote_url: t.url,
|
|
4040
|
+
transport: Ur.exec(t.url ?? "")?.[1]?.toLowerCase() ?? null
|
|
4041
|
+
});
|
|
4042
|
+
}), this._statAggregator = e;
|
|
4043
|
+
}
|
|
4044
|
+
observe(e) {
|
|
4045
|
+
this.stop(), this._pc = e, this._lastSignalingStateChange = 0, this._lastGatheringStateChange = 0, this._lastConnectionState = null, e.addEventListener("connectionstatechange", this._handleConnectionStateChange), e.addEventListener("signalingstatechange", this._handleSignalingStateChange), e.addEventListener("icegatheringstatechange", this._handleGatheringStateChange), e.addEventListener("icecandidateerror", this._handleIceCandidateError);
|
|
4046
|
+
}
|
|
4047
|
+
stop() {
|
|
4048
|
+
this._pc && (this._pc.connectionState !== "new" && this._logConnectionState(this._pc.connectionState), this._logConnectionState("closed"), this._pc.removeEventListener("connectionstatechange", this._handleConnectionStateChange), this._pc.removeEventListener("signalingstatechange", this._handleSignalingStateChange), this._pc.removeEventListener("icegatheringstatechange", this._handleGatheringStateChange), this._pc.removeEventListener("icecandidateerror", this._handleIceCandidateError), this._pc = null);
|
|
4049
|
+
}
|
|
4050
|
+
logIceRestart() {
|
|
4051
|
+
this._log({ name: U.ICE_RESTART });
|
|
4052
|
+
}
|
|
4053
|
+
logIceCandidateAddFailed(e, t) {
|
|
4054
|
+
this._log({
|
|
4055
|
+
name: U.ICE_CANDIDATE_ADD_FAILED,
|
|
4056
|
+
value: t instanceof DOMException ? t.code : 0,
|
|
4057
|
+
string_value: t instanceof Error ? `${t.name}: ${t.message}` : String(t),
|
|
4058
|
+
remote_url: e.candidate
|
|
4059
|
+
});
|
|
4060
|
+
}
|
|
4061
|
+
_sinceLastChange(e) {
|
|
4062
|
+
let t = Date.now(), n = this[e] === 0 ? 0 : t - this[e];
|
|
4063
|
+
return this[e] = t, n;
|
|
4064
|
+
}
|
|
4065
|
+
_logConnectionState(e) {
|
|
4066
|
+
e !== this._lastConnectionState && (this._lastConnectionState = e, this._log({
|
|
4067
|
+
name: U.CONNECTION_STATE_CHANGED,
|
|
4068
|
+
connection_state: e
|
|
4069
|
+
}));
|
|
4070
|
+
}
|
|
4071
|
+
_log(e) {
|
|
4072
|
+
this._statAggregator?.logEventualStat(e);
|
|
4073
|
+
}
|
|
4074
|
+
}, Kr = /* @__PURE__ */ function(e) {
|
|
4075
|
+
return e.NO_CONNECTION_TIMEOUT = "no_connection_timeout", e.CONNECTION_FAILED = "connection_failed", e.SUCCESS_CONNECTION = "success_connection", e.NO_DATA_TIMEOUT = "no_data_timeout", e.SUCCESS_AUDIO = "success_audio", e.CONNECTION_ACCEPTED_FAILED = "connection_accepted_failed", e;
|
|
4076
|
+
}({}), qr = /* @__PURE__ */ function(e) {
|
|
4077
|
+
return e.GOOD = "good", e.BAD_1 = "bad_1", e.BAD_2 = "bad_2", e;
|
|
4078
|
+
}({}), Jr = class {
|
|
4079
|
+
constructor(e) {
|
|
4080
|
+
h(this, "_statAggregator", void 0), this._statAggregator = e;
|
|
4081
|
+
}
|
|
4082
|
+
logServerTopologyRequested(e, t) {
|
|
4083
|
+
this._statAggregator?.logEventualStat({
|
|
4084
|
+
name: U.CLIENT_REQUESTED_SERVER_TOPOLOGY,
|
|
4085
|
+
value: t,
|
|
4086
|
+
string_value: e
|
|
4087
|
+
});
|
|
4088
|
+
}
|
|
4089
|
+
logVideoEncoderChanged(e) {
|
|
4090
|
+
let t = e.mimeType?.replace("video/", "") ?? "";
|
|
4091
|
+
this._statAggregator?.logEventualStat({
|
|
4092
|
+
name: U.VIDEO_ENCODER_CHANGED_BY_NETWORK_ADAPTER,
|
|
4093
|
+
string_value: JSON.stringify({
|
|
4094
|
+
rtt: Math.round(e.rtt),
|
|
4095
|
+
loss: Math.round(e.loss),
|
|
4096
|
+
network_quality: e.networkQuality,
|
|
4097
|
+
codec_old: t,
|
|
4098
|
+
codec_new: t,
|
|
4099
|
+
source: e.source
|
|
4100
|
+
})
|
|
4101
|
+
});
|
|
4102
|
+
}
|
|
4103
|
+
}, Yr = 200;
|
|
4104
|
+
function Xr(e) {
|
|
4008
4105
|
for (let t of e.values()) if (t.type === "outbound-rtp" && (t.packetsSent ?? 0) > 0) return !0;
|
|
4009
4106
|
return !1;
|
|
4010
4107
|
}
|
|
4011
|
-
var
|
|
4012
|
-
constructor(e, t, n =
|
|
4108
|
+
var Zr = class {
|
|
4109
|
+
constructor(e, t, n = Yr) {
|
|
4013
4110
|
h(this, "_peerConnection", void 0), h(this, "_onFirstMediaSent", void 0), h(this, "_pollIntervalMs", void 0), h(this, "_timer", null), h(this, "_state", "idle"), this._peerConnection = e, this._onFirstMediaSent = t, this._pollIntervalMs = n;
|
|
4014
4111
|
}
|
|
4015
4112
|
start() {
|
|
@@ -4032,7 +4129,7 @@ var Gr = class {
|
|
|
4032
4129
|
try {
|
|
4033
4130
|
let e = await this._getStatsReports();
|
|
4034
4131
|
if (this._state !== "polling") return;
|
|
4035
|
-
if (e.some(
|
|
4132
|
+
if (e.some(Xr)) {
|
|
4036
4133
|
this._state = "stopped", this._onFirstMediaSent();
|
|
4037
4134
|
return;
|
|
4038
4135
|
}
|
|
@@ -4045,7 +4142,7 @@ var Gr = class {
|
|
|
4045
4142
|
this._timer = null, this._poll();
|
|
4046
4143
|
}, this._pollIntervalMs));
|
|
4047
4144
|
}
|
|
4048
|
-
},
|
|
4145
|
+
}, Qr = class extends b {
|
|
4049
4146
|
constructor(e, t, n = null) {
|
|
4050
4147
|
super(), h(this, "_signaling", void 0), h(this, "_mediaSource", void 0), h(this, "_state", q.IDLE), h(this, "_pc", null), h(this, "_onFirstMediaSent", void 0), h(this, "_firstMediaSentProbe", null), h(this, "_firstMediaSentProbeStopped", !1), this._signaling = e, this._mediaSource = t, this._onFirstMediaSent = n;
|
|
4051
4148
|
}
|
|
@@ -4056,12 +4153,12 @@ var Gr = class {
|
|
|
4056
4153
|
this._firstMediaSentProbeStopped = !0, this._disposeFirstMediaSentProbe();
|
|
4057
4154
|
}
|
|
4058
4155
|
_startFirstMediaSentProbe() {
|
|
4059
|
-
this._disposeFirstMediaSentProbe(), !(!this._pc || !this._onFirstMediaSent || this._firstMediaSentProbeStopped) && (this._firstMediaSentProbe = new
|
|
4156
|
+
this._disposeFirstMediaSentProbe(), !(!this._pc || !this._onFirstMediaSent || this._firstMediaSentProbeStopped) && (this._firstMediaSentProbe = new Zr(this._pc, this._onFirstMediaSent), this._firstMediaSentProbe.start());
|
|
4060
4157
|
}
|
|
4061
4158
|
_disposeFirstMediaSentProbe() {
|
|
4062
4159
|
this._firstMediaSentProbe?.destroy(), this._firstMediaSentProbe = null;
|
|
4063
4160
|
}
|
|
4064
|
-
},
|
|
4161
|
+
}, $r = class {
|
|
4065
4162
|
constructor(e, t = null) {
|
|
4066
4163
|
h(this, "weightUp", void 0), h(this, "weightDown", void 0), h(this, "value", NaN), this.weightUp = e, this.weightDown = t ?? e;
|
|
4067
4164
|
}
|
|
@@ -4079,7 +4176,7 @@ var Gr = class {
|
|
|
4079
4176
|
getValue() {
|
|
4080
4177
|
return this.value;
|
|
4081
4178
|
}
|
|
4082
|
-
},
|
|
4179
|
+
}, ei = .25, ti = .35, ni = 85, ri = .1, ii = 1.5, ai = .1, oi = 1, si = .6, ci = .3, li = class extends b {
|
|
4083
4180
|
constructor(e, t = z) {
|
|
4084
4181
|
super(), h(this, "_signaling", void 0), h(this, "_localNetworkStat", void 0), h(this, "_remoteNetworkStat", void 0), h(this, "_lastNetworkStat", void 0), h(this, "_networkLimits", {
|
|
4085
4182
|
badNet: {
|
|
@@ -4091,8 +4188,8 @@ var Gr = class {
|
|
|
4091
4188
|
rtt: 600
|
|
4092
4189
|
}
|
|
4093
4190
|
}), h(this, "_lastStatSentTimestamp", 0), h(this, "_currentState", "good"), h(this, "_debug", void 0), this._debug = t, this._signaling = e, this._localNetworkStat = {
|
|
4094
|
-
rtt: new
|
|
4095
|
-
loss: new
|
|
4191
|
+
rtt: new $r(ei, ei),
|
|
4192
|
+
loss: new $r(ti, ti),
|
|
4096
4193
|
bitrate: 0
|
|
4097
4194
|
}, this._remoteNetworkStat = {
|
|
4098
4195
|
rtt: 0,
|
|
@@ -4107,20 +4204,20 @@ var Gr = class {
|
|
|
4107
4204
|
_calcRttRating(e) {
|
|
4108
4205
|
let t = typeof e == "number" ? e : e.getValue(), n = 1;
|
|
4109
4206
|
if (isNaN(t)) return n;
|
|
4110
|
-
let r = Math.round((t - this._networkLimits.goodNet.rtt) /
|
|
4111
|
-
for (let e = 0; e < r; e++) n *= 1 -
|
|
4207
|
+
let r = Math.round((t - this._networkLimits.goodNet.rtt) / ni);
|
|
4208
|
+
for (let e = 0; e < r; e++) n *= 1 - ri;
|
|
4112
4209
|
return n;
|
|
4113
4210
|
}
|
|
4114
4211
|
_calcLossRating(e) {
|
|
4115
4212
|
let t = typeof e == "number" ? e : e.getValue(), n = 1;
|
|
4116
4213
|
if (isNaN(t)) return n;
|
|
4117
|
-
let r = Math.round((t - this._networkLimits.goodNet.loss) /
|
|
4118
|
-
for (let e = 0; e < r; e++) n *= 1 -
|
|
4214
|
+
let r = Math.round((t - this._networkLimits.goodNet.loss) / ii);
|
|
4215
|
+
for (let e = 0; e < r; e++) n *= 1 - ai;
|
|
4119
4216
|
return n;
|
|
4120
4217
|
}
|
|
4121
4218
|
_calcBitrateRating(e, t) {
|
|
4122
4219
|
if (!e || !t) return 1;
|
|
4123
|
-
let n = 1 - (1 - Math.min(e, t) / Math.max(e, t)) *
|
|
4220
|
+
let n = 1 - (1 - Math.min(e, t) / Math.max(e, t)) * oi;
|
|
4124
4221
|
return Math.min(n, 1);
|
|
4125
4222
|
}
|
|
4126
4223
|
_calcUDPRating({ rtt: e, loss: t }) {
|
|
@@ -4130,7 +4227,7 @@ var Gr = class {
|
|
|
4130
4227
|
return n ? this._calcBitrateRating(e.bitrate, t.bitrate) : this._calcUDPRating(e) * this._calcUDPRating(t);
|
|
4131
4228
|
}
|
|
4132
4229
|
_getNetworkState(e) {
|
|
4133
|
-
return isNaN(e) || e >=
|
|
4230
|
+
return isNaN(e) || e >= si ? "good" : e >= ci ? "medium" : "bad";
|
|
4134
4231
|
}
|
|
4135
4232
|
updateSettings(e) {
|
|
4136
4233
|
Object.assign(this._networkLimits.badNet, e?.badNet || {}), Object.assign(this._networkLimits.goodNet, e?.goodNet || {});
|
|
@@ -4154,9 +4251,9 @@ var Gr = class {
|
|
|
4154
4251
|
let { rtt: t, loss: n, bitrate: r } = e || {};
|
|
4155
4252
|
this._remoteNetworkStat.rtt = t || 0, this._remoteNetworkStat.loss = n || 0, this._remoteNetworkStat.bitrate = r || 0;
|
|
4156
4253
|
}
|
|
4157
|
-
},
|
|
4254
|
+
}, ui = 30 * 1e3, di = class e extends Qr {
|
|
4158
4255
|
constructor(e, t, n, r, i, a = z, o = null, s = null, c = null, l = null) {
|
|
4159
|
-
super(n, r, l), h(this, "_participantId", void 0), h(this, "_isMaster", void 0), h(this, "_remoteSDP", {}), h(this, "_remoteCandidates", {}), h(this, "_lastRemoteSDP", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_remoteAnimojiVersion", 1), h(this, "_isOpen", !1), h(this, "_remotePeerId", null), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_failedOnCreate", null), h(this, "_remoteStream", null), h(this, "_iceRestartTimeout", null), h(this, "_reconnectionTimeout", null), h(this, "_reconnectionPrevented", !1), h(this, "_remoteHold", !1), h(this, "_lastStat", null), h(this, "_fingerprint", null), h(this, "_neverConnected", !0), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_networkLimitsForVideo", {
|
|
4256
|
+
super(n, r, l), h(this, "_participantId", void 0), h(this, "_isMaster", void 0), h(this, "_remoteSDP", {}), h(this, "_remoteCandidates", {}), h(this, "_lastRemoteSDP", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_remoteAnimojiVersion", 1), h(this, "_isOpen", !1), h(this, "_remotePeerId", null), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_failedOnCreate", null), h(this, "_remoteStream", null), h(this, "_iceRestartTimeout", null), h(this, "_reconnectionTimeout", null), h(this, "_reconnectionPrevented", !1), h(this, "_remoteHold", !1), h(this, "_lastStat", null), h(this, "_fingerprint", null), h(this, "_neverConnected", !0), h(this, "_connectionStartedAt", 0), h(this, "_connectionLostAt", 0), h(this, "_serverRequestedOnNoConnection", !1), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_networkLimitsForVideo", {
|
|
4160
4257
|
bad: {
|
|
4161
4258
|
loss: 4,
|
|
4162
4259
|
rtt: 1e3
|
|
@@ -4169,7 +4266,7 @@ var Gr = class {
|
|
|
4169
4266
|
worst: 320,
|
|
4170
4267
|
bad: 640,
|
|
4171
4268
|
good: 1280
|
|
4172
|
-
}), h(this, "_lastVideoMaxDimension", this._videoMaxDimensionsForNet.good), h(this, "_lastBadConnection", 0), h(this, "_perfStatReporter", void 0), h(this, "_directStatReporter", void 0), h(this, "_sdpStats", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), this._participantId = e, this._isMaster = t, this._serverSettings = i, this._debug = a, this._logger = o, this._statAggregator = s, this._codecStatsAggregator = c, this._perfStatReporter = new
|
|
4269
|
+
}), h(this, "_lastVideoMaxDimension", this._videoMaxDimensionsForNet.good), h(this, "_lastBadConnection", 0), h(this, "_perfStatReporter", void 0), h(this, "_directStatReporter", void 0), h(this, "_sdpStats", void 0), h(this, "_peerConnectionStats", void 0), h(this, "_networkAdaptationStats", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), this._participantId = e, this._isMaster = t, this._serverSettings = i, this._debug = a, this._logger = o, this._statAggregator = s, this._codecStatsAggregator = c, this._perfStatReporter = new Na(this, n, this._statAggregator, !0, this._debug), this._directStatReporter = new li(n, this._debug), this._sdpStats = new Lr(this._statAggregator), this._peerConnectionStats = new Gr(this._statAggregator), this._networkAdaptationStats = new Jr(this._statAggregator), this.subscribe(this._signaling, xr.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, qt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, qt.SOURCE_CHANGED, this._applySettings.bind(this)), this.subscribe(this._directStatReporter, Y.NETWORK_STATUS, this._onNetworkStatus.bind(this));
|
|
4173
4270
|
try {
|
|
4174
4271
|
this._pc = this._createPeerConnection();
|
|
4175
4272
|
} catch (e) {
|
|
@@ -4211,7 +4308,7 @@ var Gr = class {
|
|
|
4211
4308
|
this._finishClose(this._failedOnCreate);
|
|
4212
4309
|
return;
|
|
4213
4310
|
}
|
|
4214
|
-
if (this._debug.debug("DirectTransport: Open transport", { participantId: this._participantId }), this._isOpen = !0, this._remotePeerId = e, !this._isMaster) try {
|
|
4311
|
+
if (this._debug.debug("DirectTransport: Open transport", { participantId: this._participantId }), this._isOpen = !0, this._remotePeerId = e, this._connectionStartedAt = Date.now(), !this._isMaster) try {
|
|
4215
4312
|
this._mediaSource.addTrackToPeerConnection(this._pc, !1, !0), this._applySettings();
|
|
4216
4313
|
} catch (e) {
|
|
4217
4314
|
this._logger?.log(C.ERROR, "addTrack-direct"), this._debug.error("DirectTransport: Unable to add media source tracks", e, { participantId: this._participantId }), this.close(e);
|
|
@@ -4257,7 +4354,7 @@ var Gr = class {
|
|
|
4257
4354
|
this._debug.error("Failed to recreate RTCPeerConnection:", e), this.close(e);
|
|
4258
4355
|
return;
|
|
4259
4356
|
}
|
|
4260
|
-
this._neverConnected = !0;
|
|
4357
|
+
this._neverConnected = !0, this._connectionStartedAt = Date.now(), this._serverRequestedOnNoConnection = !1;
|
|
4261
4358
|
try {
|
|
4262
4359
|
this._mediaSource.addTrackToPeerConnection(this._pc, !1, !0), this._applySettings();
|
|
4263
4360
|
} catch (e) {
|
|
@@ -4273,12 +4370,12 @@ var Gr = class {
|
|
|
4273
4370
|
iceServers: N.iceServers,
|
|
4274
4371
|
iceTransportPolicy: N.forceRelayPolicy ? "relay" : "all"
|
|
4275
4372
|
});
|
|
4276
|
-
return e.onicecandidate = this._handleIceCandidate.bind(this), e.ontrack = this._onAddTrack.bind(this), e.oniceconnectionstatechange = this._onIceConnectionStateChange.bind(this), e.onconnectionstatechange = this._onConnectionStateChange.bind(this), e.onsignalingstatechange = this._onSignalingStateChange.bind(this), this._sdpStats.observe(e), this._prevConsumerSettings = {}, N.vmoji && this._createDataChannel(e, Tr.animoji, (e) => {
|
|
4373
|
+
return e.onicecandidate = this._handleIceCandidate.bind(this), e.ontrack = this._onAddTrack.bind(this), e.oniceconnectionstatechange = this._onIceConnectionStateChange.bind(this), e.onconnectionstatechange = this._onConnectionStateChange.bind(this), e.onsignalingstatechange = this._onSignalingStateChange.bind(this), this._sdpStats.observe(e), this._peerConnectionStats.observe(e), this._prevConsumerSettings = {}, N.vmoji && this._createDataChannel(e, Tr.animoji, (e) => {
|
|
4277
4374
|
this._animojiDataChannel = e, this._animojiDataChannel.binaryType = "arraybuffer", this._animojiReceiver?.setDataChannel(this._animojiDataChannel), this._animojiSender?.setDataChannel(this._animojiDataChannel);
|
|
4278
4375
|
}), e;
|
|
4279
4376
|
}
|
|
4280
4377
|
_disposePeerConnection() {
|
|
4281
|
-
if (this._disposeFirstMediaSentProbe(), this._sdpStats.stop(), this._lastStat = null, this._remoteStream) {
|
|
4378
|
+
if (this._disposeFirstMediaSentProbe(), this._sdpStats.stop(), this._peerConnectionStats.stop(), this._lastStat = null, this._remoteStream) {
|
|
4282
4379
|
let e = this._remoteStream;
|
|
4283
4380
|
e.getTracks().forEach((t) => {
|
|
4284
4381
|
t.stop(), this._triggerEvent(Y.REMOTE_TRACK_REMOVED, e, t);
|
|
@@ -4327,7 +4424,7 @@ var Gr = class {
|
|
|
4327
4424
|
try {
|
|
4328
4425
|
await this._pc.addIceCandidate(new RTCIceCandidate(t));
|
|
4329
4426
|
} catch (e) {
|
|
4330
|
-
throw this._logger?.log(C.ERROR, "addIceCandidate-direct"), this._debug.error("Unable to add remote ice candidate", e, {
|
|
4427
|
+
throw this._logger?.log(C.ERROR, "addIceCandidate-direct"), this._peerConnectionStats.logIceCandidateAddFailed(t, e), this._debug.error("Unable to add remote ice candidate", e, {
|
|
4331
4428
|
participantId: this._participantId,
|
|
4332
4429
|
candidate: t
|
|
4333
4430
|
}), e;
|
|
@@ -4414,7 +4511,7 @@ var Gr = class {
|
|
|
4414
4511
|
}
|
|
4415
4512
|
}
|
|
4416
4513
|
_markConnected() {
|
|
4417
|
-
this._neverConnected = !1, this._setState(q.CONNECTED), this._stopReconnection(), this._pc && M.getPeerConnectionHostInfo(this._pc).then((e) => {
|
|
4514
|
+
this._serverRequestedOnNoConnection && (this._networkAdaptationStats.logServerTopologyRequested(Kr.SUCCESS_CONNECTION, Date.now() - this._connectionStartedAt), this._serverRequestedOnNoConnection = !1), this._neverConnected = !1, this._setState(q.CONNECTED), this._stopReconnection(), this._pc && M.getPeerConnectionHostInfo(this._pc).then((e) => {
|
|
4418
4515
|
e?.local && (this._logger?.log(C.ICE_CONNECTION_TYPE, e.local.type), this._debug.debug("Selected ICE candidates", e));
|
|
4419
4516
|
}), this._startStatInterval();
|
|
4420
4517
|
}
|
|
@@ -4433,21 +4530,28 @@ var Gr = class {
|
|
|
4433
4530
|
}
|
|
4434
4531
|
}
|
|
4435
4532
|
_startReconnection() {
|
|
4436
|
-
this._reconnectionTimeout || this._iceRestartTimeout || (this._debug.log("Waiting for reconnection...", { participantId: this._participantId }), this._reconnectionTimeout = window.setTimeout(() => {
|
|
4437
|
-
this._reconnectionTimeout = null, this._neverConnected ? this._requestTopologySwitch() : this._startIceRestart();
|
|
4533
|
+
this._reconnectionTimeout || this._iceRestartTimeout || (this._debug.log("Waiting for reconnection...", { participantId: this._participantId }), this._connectionLostAt = Date.now(), this._reconnectionTimeout = window.setTimeout(() => {
|
|
4534
|
+
this._reconnectionTimeout = null, this._neverConnected ? this._requestTopologySwitch({ reason: Kr.NO_CONNECTION_TIMEOUT }) : this._startIceRestart();
|
|
4438
4535
|
}, N.transportConnectionWaitTime));
|
|
4439
4536
|
}
|
|
4440
|
-
_requestTopologySwitch(e = !1) {
|
|
4441
|
-
(this._isMaster ||
|
|
4442
|
-
|
|
4443
|
-
|
|
4537
|
+
_requestTopologySwitch({ reason: e, fromAnySide: t = !1 }) {
|
|
4538
|
+
if ((this._isMaster || t) && this._signaling.ready) {
|
|
4539
|
+
this._debug.log("Switch topology DIRECT to SERVER", { participantId: this._participantId });
|
|
4540
|
+
let t = e === Kr.CONNECTION_FAILED ? this._connectionLostAt : this._connectionStartedAt;
|
|
4541
|
+
this._networkAdaptationStats.logServerTopologyRequested(e, Date.now() - t), e === Kr.NO_CONNECTION_TIMEOUT && (this._serverRequestedOnNoConnection = !0), this._signaling.switchTopology(J.SERVER).catch((e) => {
|
|
4542
|
+
e instanceof En || this._debug.warn("Unable to switch topology DIRECT to SERVER", e);
|
|
4543
|
+
});
|
|
4544
|
+
}
|
|
4444
4545
|
}
|
|
4445
4546
|
_stopReconnection() {
|
|
4446
4547
|
this._reconnectionTimeout && (clearTimeout(this._reconnectionTimeout), this._reconnectionTimeout = null), this._iceRestartTimeout && (clearTimeout(this._iceRestartTimeout), this._iceRestartTimeout = null);
|
|
4447
4548
|
}
|
|
4448
4549
|
_startIceRestart() {
|
|
4449
|
-
this._isMaster ? (this._logger?.log(C.ICE_RESTART), this._debug.log("Ice restart", { participantId: this._participantId }), this._createOffer(!0).catch(this.close.bind(this))) : this._debug.debug("Waiting for ice restart...", { participantId: this._participantId }), this._iceRestartTimeout = window.setTimeout(() => {
|
|
4450
|
-
this._iceRestartTimeout = null, this._debug.error("Ice restart failed", { participantId: this._participantId }), this._logger?.log(C.ERROR, "iceRestart-direct"), this._requestTopologySwitch(
|
|
4550
|
+
this._isMaster ? (this._peerConnectionStats.logIceRestart(), this._logger?.log(C.ICE_RESTART), this._debug.log("Ice restart", { participantId: this._participantId }), this._createOffer(!0).catch(this.close.bind(this))) : this._debug.debug("Waiting for ice restart...", { participantId: this._participantId }), this._iceRestartTimeout = window.setTimeout(() => {
|
|
4551
|
+
this._iceRestartTimeout = null, this._debug.error("Ice restart failed", { participantId: this._participantId }), this._logger?.log(C.ERROR, "iceRestart-direct"), this._requestTopologySwitch({
|
|
4552
|
+
reason: Kr.CONNECTION_FAILED,
|
|
4553
|
+
fromAnySide: N.switchTopologyOnReconnectFromAnySide
|
|
4554
|
+
});
|
|
4451
4555
|
}, N.iceRestartWaitTime);
|
|
4452
4556
|
}
|
|
4453
4557
|
async _createOffer(t) {
|
|
@@ -4567,24 +4671,32 @@ var Gr = class {
|
|
|
4567
4671
|
}
|
|
4568
4672
|
async _checkPPTNetwork(e) {
|
|
4569
4673
|
if (!N.switchVideoAtBadNetwork || !e.inbound.transport.averageNetStat) return;
|
|
4570
|
-
let { averageNetStat: t } = e.inbound.transport, n = t.currentRoundTripTime <= this._networkLimitsForVideo.good.rtt && t.lostPercent <= this._networkLimitsForVideo.good.loss, r = t.currentRoundTripTime >= this._networkLimitsForVideo.bad.rtt || t.lostPercent >= this._networkLimitsForVideo.bad.loss, i = t.currentRoundTripTime < this._networkLimitsForVideo.bad.rtt, a = this._videoMaxDimensionsForNet.good, o = kr.L1T1;
|
|
4571
|
-
if (r ? (this._lastBadConnection = Date.now(), i ? (a = this._videoMaxDimensionsForNet.bad, o = kr.L1T2) : (a = this._videoMaxDimensionsForNet.worst, o = kr.L1T3)) : n && (a = this._videoMaxDimensionsForNet.good, o = kr.L1T1), !(a < this._lastVideoMaxDimension || Date.now() - this._lastBadConnection >
|
|
4572
|
-
let
|
|
4573
|
-
if (!
|
|
4674
|
+
let { averageNetStat: t } = e.inbound.transport, n = t.currentRoundTripTime <= this._networkLimitsForVideo.good.rtt && t.lostPercent <= this._networkLimitsForVideo.good.loss, r = t.currentRoundTripTime >= this._networkLimitsForVideo.bad.rtt || t.lostPercent >= this._networkLimitsForVideo.bad.loss, i = t.currentRoundTripTime < this._networkLimitsForVideo.bad.rtt, a = this._videoMaxDimensionsForNet.good, o = kr.L1T1, s = qr.GOOD;
|
|
4675
|
+
if (r ? (this._lastBadConnection = Date.now(), i ? (s = qr.BAD_1, a = this._videoMaxDimensionsForNet.bad, o = kr.L1T2) : (s = qr.BAD_2, a = this._videoMaxDimensionsForNet.worst, o = kr.L1T3)) : n && (a = this._videoMaxDimensionsForNet.good, o = kr.L1T1), !(a < this._lastVideoMaxDimension || Date.now() - this._lastBadConnection > ui) || this._lastVideoMaxDimension === a) return;
|
|
4676
|
+
let c = this._serverSettings.camera;
|
|
4677
|
+
if (!c || !await this._isSVCSupported(e, o)) return;
|
|
4574
4678
|
this._debug.debug("Switch outbound video frame size and scalabilityMode", {
|
|
4575
4679
|
scalabilityMode: o,
|
|
4576
4680
|
averageNetStat: t,
|
|
4577
4681
|
nextVideoMaxDimension: a
|
|
4682
|
+
});
|
|
4683
|
+
let l = e.outbound.rtps.find((e) => e.kind === "video");
|
|
4684
|
+
this._networkAdaptationStats.logVideoEncoderChanged({
|
|
4685
|
+
rtt: t.currentRoundTripTime,
|
|
4686
|
+
loss: t.lostPercent,
|
|
4687
|
+
networkQuality: s,
|
|
4688
|
+
mimeType: l?.mimeType,
|
|
4689
|
+
source: "camera"
|
|
4578
4690
|
}), this._lastVideoMaxDimension = a;
|
|
4579
|
-
let
|
|
4691
|
+
let u = {
|
|
4580
4692
|
...this._serverSettings,
|
|
4581
4693
|
camera: {
|
|
4582
|
-
...
|
|
4694
|
+
...c,
|
|
4583
4695
|
scalabilityMode: o,
|
|
4584
4696
|
maxDimension: this._lastVideoMaxDimension
|
|
4585
4697
|
}
|
|
4586
4698
|
};
|
|
4587
|
-
this.updateSettings(
|
|
4699
|
+
this.updateSettings(u);
|
|
4588
4700
|
}
|
|
4589
4701
|
_stopStatInterval() {
|
|
4590
4702
|
this._statInterval && (window.clearTimeout(this._statInterval), this._statInterval = null);
|
|
@@ -4633,9 +4745,9 @@ var Gr = class {
|
|
|
4633
4745
|
}, n(r)) : this._debug.error(`[${t}] data channel open failed, state [${e}]`);
|
|
4634
4746
|
};
|
|
4635
4747
|
}
|
|
4636
|
-
},
|
|
4748
|
+
}, fi = /* @__PURE__ */ function(e) {
|
|
4637
4749
|
return e.AUDIO_MIX = "audio-mix", e.PARTICIPANT_AGNOSTIC_TRACK_PREFIX = "pat", e.TRANSPARENT_AUDIO_TRACK_PREFIX = "ta", e;
|
|
4638
|
-
}({}),
|
|
4750
|
+
}({}), pi = 16, mi = class e {
|
|
4639
4751
|
constructor(e, t, n, r = z) {
|
|
4640
4752
|
h(this, "_datachannel", void 0), h(this, "_participantIdRegistry", void 0), h(this, "_asrCallback", void 0), h(this, "_textDecoder", void 0), h(this, "_debug", void 0), this._debug = r, this._debug.debug("AsrReceiver started"), this._datachannel = e, this._participantIdRegistry = t, this._asrCallback = n, this._textDecoder = new TextDecoder(), this._datachannel.onmessage = (e) => this._onDataChannelMessage(e.data);
|
|
4641
4753
|
}
|
|
@@ -4649,7 +4761,7 @@ var Gr = class {
|
|
|
4649
4761
|
ssrc: a,
|
|
4650
4762
|
timestamp: o,
|
|
4651
4763
|
duration: s,
|
|
4652
|
-
data: e.slice(
|
|
4764
|
+
data: e.slice(pi)
|
|
4653
4765
|
};
|
|
4654
4766
|
}
|
|
4655
4767
|
_onDataChannelMessage(t) {
|
|
@@ -4669,7 +4781,7 @@ var Gr = class {
|
|
|
4669
4781
|
destroy() {
|
|
4670
4782
|
this._datachannel.onmessage = null;
|
|
4671
4783
|
}
|
|
4672
|
-
},
|
|
4784
|
+
}, hi, gi = class {
|
|
4673
4785
|
constructor() {
|
|
4674
4786
|
h(this, "_value", 1);
|
|
4675
4787
|
}
|
|
@@ -4680,10 +4792,10 @@ var Gr = class {
|
|
|
4680
4792
|
this._value = e;
|
|
4681
4793
|
}
|
|
4682
4794
|
};
|
|
4683
|
-
|
|
4795
|
+
hi = gi, h(gi, "_instance", null), h(gi, "getInstance", () => (hi._instance || (hi._instance = new hi()), hi._instance));
|
|
4684
4796
|
//#endregion
|
|
4685
4797
|
//#region src/classes/ParticipantIdRegistry.ts
|
|
4686
|
-
var
|
|
4798
|
+
var _i = class {
|
|
4687
4799
|
constructor(e = z) {
|
|
4688
4800
|
h(this, "streamDescriptionByCompactId", /* @__PURE__ */ new Map()), h(this, "compactIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_debug", void 0), this._debug = e;
|
|
4689
4801
|
}
|
|
@@ -4799,7 +4911,7 @@ var di = class {
|
|
|
4799
4911
|
this._debug.error("unexpected null sequenceNumber", e, r);
|
|
4800
4912
|
continue;
|
|
4801
4913
|
}
|
|
4802
|
-
let l =
|
|
4914
|
+
let l = fi.PARTICIPANT_AGNOSTIC_TRACK_PREFIX + "-" + e, u = i ? i >>> 0 : null;
|
|
4803
4915
|
n.push({
|
|
4804
4916
|
participantStreamDescription: c,
|
|
4805
4917
|
streamId: l,
|
|
@@ -4815,9 +4927,9 @@ var di = class {
|
|
|
4815
4927
|
participantUpdateInfos: n
|
|
4816
4928
|
};
|
|
4817
4929
|
}
|
|
4818
|
-
},
|
|
4930
|
+
}, vi = /* @__PURE__ */ function(e) {
|
|
4819
4931
|
return e.INIT = "init", e.READY = "ready", e.FRAME = "frame", e.SET_BITRATE = "set_bitrate", e.ERROR = "error", e.DEBUG = "debug", e.LOG_ERROR = "log_error", e;
|
|
4820
|
-
}({}),
|
|
4932
|
+
}({}), yi = class {
|
|
4821
4933
|
constructor(e = z, t = null) {
|
|
4822
4934
|
h(this, "_worker", null), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = e, this._logger = t;
|
|
4823
4935
|
}
|
|
@@ -4833,7 +4945,7 @@ var di = class {
|
|
|
4833
4945
|
return;
|
|
4834
4946
|
}
|
|
4835
4947
|
t({
|
|
4836
|
-
type:
|
|
4948
|
+
type: vi.FRAME,
|
|
4837
4949
|
error: e
|
|
4838
4950
|
});
|
|
4839
4951
|
};
|
|
@@ -4843,23 +4955,23 @@ var di = class {
|
|
|
4843
4955
|
e.preventDefault?.(), m(this._formatWorkerMessageError(e));
|
|
4844
4956
|
}, f.onmessage = (e) => {
|
|
4845
4957
|
switch (e.data.type) {
|
|
4846
|
-
case
|
|
4958
|
+
case vi.READY:
|
|
4847
4959
|
s = !0, c || (c = !0, a());
|
|
4848
4960
|
break;
|
|
4849
|
-
case
|
|
4961
|
+
case vi.ERROR:
|
|
4850
4962
|
s ? m(e.data.error) : p(e.data.error);
|
|
4851
4963
|
break;
|
|
4852
|
-
case
|
|
4964
|
+
case vi.FRAME:
|
|
4853
4965
|
t(e.data);
|
|
4854
4966
|
break;
|
|
4855
|
-
case
|
|
4967
|
+
case vi.DEBUG:
|
|
4856
4968
|
this._debug.debug(e.data.message);
|
|
4857
4969
|
break;
|
|
4858
|
-
case
|
|
4970
|
+
case vi.LOG_ERROR:
|
|
4859
4971
|
this._logger?.log(C.ERROR, e.data.message);
|
|
4860
4972
|
break;
|
|
4861
4973
|
}
|
|
4862
|
-
}, this._sendToWorker(
|
|
4974
|
+
}, this._sendToWorker(vi.INIT, r, i);
|
|
4863
4975
|
});
|
|
4864
4976
|
}
|
|
4865
4977
|
_removeWorker() {
|
|
@@ -4882,7 +4994,7 @@ var di = class {
|
|
|
4882
4994
|
static isBrowserSupported() {
|
|
4883
4995
|
throw Error("Not implemented");
|
|
4884
4996
|
}
|
|
4885
|
-
},
|
|
4997
|
+
}, bi = class extends yi {
|
|
4886
4998
|
constructor(e = z, t = null) {
|
|
4887
4999
|
super(e, t);
|
|
4888
5000
|
}
|
|
@@ -4892,7 +5004,7 @@ var di = class {
|
|
|
4892
5004
|
}, [c, c.getUrl]);
|
|
4893
5005
|
}
|
|
4894
5006
|
decodeFrame(e, t, n, r) {
|
|
4895
|
-
this._sendToWorker(
|
|
5007
|
+
this._sendToWorker(vi.FRAME, {
|
|
4896
5008
|
timestamp: e,
|
|
4897
5009
|
data: t.buffer,
|
|
4898
5010
|
isVP9: n,
|
|
@@ -4906,7 +5018,7 @@ var di = class {
|
|
|
4906
5018
|
static isBrowserSupported() {
|
|
4907
5019
|
return "WebAssembly" in window && "Worker" in window;
|
|
4908
5020
|
}
|
|
4909
|
-
},
|
|
5021
|
+
}, xi = class extends yi {
|
|
4910
5022
|
constructor(e = z, t = null) {
|
|
4911
5023
|
super(e, t);
|
|
4912
5024
|
}
|
|
@@ -4916,7 +5028,7 @@ var di = class {
|
|
|
4916
5028
|
}, [!0]);
|
|
4917
5029
|
}
|
|
4918
5030
|
decodeFrame(e, t, n, r = !1) {
|
|
4919
|
-
this._sendToWorker(
|
|
5031
|
+
this._sendToWorker(vi.FRAME, {
|
|
4920
5032
|
timestamp: e,
|
|
4921
5033
|
data: t.buffer,
|
|
4922
5034
|
isVP9: n,
|
|
@@ -4929,7 +5041,7 @@ var di = class {
|
|
|
4929
5041
|
static isBrowserSupported() {
|
|
4930
5042
|
return "VideoDecoder" in window && "Worker" in window && "VideoFrame" in window && !E.isBrokenVP9Decoder() && E.browserName() !== "Firefox";
|
|
4931
5043
|
}
|
|
4932
|
-
},
|
|
5044
|
+
}, Si = class {
|
|
4933
5045
|
constructor(e = null, t = 0) {
|
|
4934
5046
|
h(this, "_counter", 0), h(this, "_interval", 0), h(this, "_lastCalculationTime", Date.now()), h(this, "_onCalculated", null), this._onCalculated = e, t && (this._interval = window.setInterval(() => this.calculate(), t));
|
|
4935
5047
|
}
|
|
@@ -4943,7 +5055,7 @@ var di = class {
|
|
|
4943
5055
|
destroy() {
|
|
4944
5056
|
window.clearInterval(this._interval), this._interval = 0;
|
|
4945
5057
|
}
|
|
4946
|
-
},
|
|
5058
|
+
}, Ci = class {
|
|
4947
5059
|
constructor(e, t) {
|
|
4948
5060
|
h(this, "_participantId", void 0), h(this, "_statAggregator", void 0), h(this, "_firstFrameReceived", !1), this._participantId = e, this._statAggregator = t;
|
|
4949
5061
|
}
|
|
@@ -4958,14 +5070,14 @@ var di = class {
|
|
|
4958
5070
|
height: t
|
|
4959
5071
|
});
|
|
4960
5072
|
}
|
|
4961
|
-
},
|
|
5073
|
+
}, wi = 65536, Ti = "MARK_SCREENSHARE_FREEZE_DURATION", Ei = class e {
|
|
4962
5074
|
constructor(e, t, n, r, i, a = z) {
|
|
4963
|
-
h(this, "_participantId", void 0), h(this, "_onStream", void 0), h(this, "_onStat", void 0), h(this, "_onKeyFrameRequested", void 0), h(this, "_statScreenShareFirstFrame", void 0), h(this, "_debug", void 0), h(this, "_chunks", []), this._participantId = e, this._onStream = t, this._onStat = n, this._onKeyFrameRequested = i, this._statScreenShareFirstFrame = new
|
|
5075
|
+
h(this, "_participantId", void 0), h(this, "_onStream", void 0), h(this, "_onStat", void 0), h(this, "_onKeyFrameRequested", void 0), h(this, "_statScreenShareFirstFrame", void 0), h(this, "_debug", void 0), h(this, "_chunks", []), this._participantId = e, this._onStream = t, this._onStat = n, this._onKeyFrameRequested = i, this._statScreenShareFirstFrame = new Ci(e, r), this._debug = a;
|
|
4964
5076
|
}
|
|
4965
5077
|
appendChunk(t) {
|
|
4966
5078
|
let n = this._chunks.length;
|
|
4967
5079
|
if (t.start) this._measureFreezeDuration(!1), this._measureFreezeDuration(!0), n && (this._debug.warn("[FrameBuilder] Cleanup buffer", Array.prototype.slice.call(this._chunks)), this._chunks = []);
|
|
4968
|
-
else if (!n || (this._chunks[n - 1].sequence + 1) %
|
|
5080
|
+
else if (!n || (this._chunks[n - 1].sequence + 1) % wi !== t.sequence) {
|
|
4969
5081
|
this._debug.warn("[FrameBuilder] Got incorrect chunk");
|
|
4970
5082
|
return;
|
|
4971
5083
|
}
|
|
@@ -4982,7 +5094,7 @@ var di = class {
|
|
|
4982
5094
|
}
|
|
4983
5095
|
}
|
|
4984
5096
|
destroy() {
|
|
4985
|
-
G.clearMark(
|
|
5097
|
+
G.clearMark(Ti), G.clearMark(G.getMarkNameScreenshareFirstFrame(this._participantId)), this._chunks = [];
|
|
4986
5098
|
}
|
|
4987
5099
|
_processFrameData() {
|
|
4988
5100
|
let e = this._chunks;
|
|
@@ -5005,13 +5117,13 @@ var di = class {
|
|
|
5005
5117
|
}
|
|
5006
5118
|
_measureFreezeDuration(e) {
|
|
5007
5119
|
if (e) {
|
|
5008
|
-
G.setMark(
|
|
5120
|
+
G.setMark(Ti);
|
|
5009
5121
|
return;
|
|
5010
5122
|
}
|
|
5011
|
-
let t = G.measureMark(
|
|
5123
|
+
let t = G.measureMark(Ti);
|
|
5012
5124
|
t !== null && t > 1e3 && this._onStat({ freeze_duration: t });
|
|
5013
5125
|
}
|
|
5014
|
-
},
|
|
5126
|
+
}, Di = class {
|
|
5015
5127
|
constructor(e) {
|
|
5016
5128
|
h(this, "_onStream", void 0), this._onStream = e;
|
|
5017
5129
|
}
|
|
@@ -5024,7 +5136,7 @@ var di = class {
|
|
|
5024
5136
|
static isBrowserSupported() {
|
|
5025
5137
|
throw Error("Method `isBrowserSupported` is not implemented");
|
|
5026
5138
|
}
|
|
5027
|
-
},
|
|
5139
|
+
}, Oi = class extends Di {
|
|
5028
5140
|
constructor(e, t = z) {
|
|
5029
5141
|
super(e), h(this, "_useImageBitmap", void 0), h(this, "_canvas", null), h(this, "_canvasContext", null), h(this, "_stream", null), h(this, "_track", null), h(this, "_debug", void 0), this._debug = t, this._debug.debug("CanvasRenderer started"), this._useImageBitmap = "ImageBitmap" in window;
|
|
5030
5142
|
}
|
|
@@ -5084,7 +5196,7 @@ var di = class {
|
|
|
5084
5196
|
static isBrowserSupported() {
|
|
5085
5197
|
return ("CanvasCaptureMediaStream" in window || "CanvasCaptureMediaStreamTrack" in window) && !(E.browserName() === "Safari" && Number(E.browserVersion()) === 15);
|
|
5086
5198
|
}
|
|
5087
|
-
},
|
|
5199
|
+
}, ki = class extends Di {
|
|
5088
5200
|
constructor(e, t = z) {
|
|
5089
5201
|
super(e), h(this, "_generator", void 0), h(this, "_writer", void 0), h(this, "_stream", void 0), h(this, "_debug", void 0), this._debug = t, this._debug.debug("TrackGeneratorRenderer started"), this._generator = new MediaStreamTrackGenerator({ kind: A.video }), this._writer = this._generator.writable.getWriter(), this._stream = new MediaStream([this._generator]), this._onStream(this._stream);
|
|
5090
5202
|
}
|
|
@@ -5095,9 +5207,9 @@ var di = class {
|
|
|
5095
5207
|
this._writer.releaseLock(), this._generator.writable.close().then(() => this._generator.stop()), this._debug.debug("TrackGeneratorRenderer destroyed");
|
|
5096
5208
|
}
|
|
5097
5209
|
static isBrowserSupported() {
|
|
5098
|
-
return "VideoFrame" in window && "MediaStreamTrackGenerator" in window &&
|
|
5210
|
+
return "VideoFrame" in window && "MediaStreamTrackGenerator" in window && xi.isBrowserSupported();
|
|
5099
5211
|
}
|
|
5100
|
-
},
|
|
5212
|
+
}, Ai = class extends Ei {
|
|
5101
5213
|
constructor(e, t, n, r, i, a = z, o = null) {
|
|
5102
5214
|
super(e, t, n, r, i, a), h(this, "_renderer", void 0), h(this, "_decoder", void 0), h(this, "_decoderReady", !1), h(this, "_decoderBusy", !1), h(this, "_decoderQueue", []), h(this, "_webCodecsRetryAttempted", !1), h(this, "_fpsMeter", void 0), h(this, "_logger", void 0), this._logger = o, this._debug.debug(`StreamBuilder started for participant [${e}]`), this._initFpsMeter(), this._initRenderer(), this._initDecoder();
|
|
5103
5215
|
}
|
|
@@ -5105,16 +5217,16 @@ var di = class {
|
|
|
5105
5217
|
e.keyframe && (this._decoderQueue = []), this._decoderQueue.push(e), this._decodeQueue();
|
|
5106
5218
|
}
|
|
5107
5219
|
_initFpsMeter() {
|
|
5108
|
-
this._fpsMeter = new
|
|
5220
|
+
this._fpsMeter = new Si((e) => this._debug.log(`[StreamBuilder][${this._participantId}] fps: ${e}`), 2e4);
|
|
5109
5221
|
}
|
|
5110
5222
|
_initRenderer(e = !1) {
|
|
5111
|
-
e || !
|
|
5223
|
+
e || !ki.isBrowserSupported() ? this._renderer = new Oi(this._onStream, this._debug) : this._renderer = new ki(this._onStream, this._debug);
|
|
5112
5224
|
}
|
|
5113
5225
|
_initDecoder(e = !1) {
|
|
5114
|
-
e || !
|
|
5226
|
+
e || !xi.isBrowserSupported() ? this._decoder = new bi(this._debug, this._logger) : this._decoder = new xi(this._debug, this._logger), this._decoder.init(async (e) => {
|
|
5115
5227
|
this._decoderBusy = !1, "VideoFrame" in window && e instanceof VideoFrame ? await this._renderer.drawFrame(e) : await this._renderer.drawImage(e), this._fpsMeter.increment(), this._decodeQueue();
|
|
5116
5228
|
}, (e) => {
|
|
5117
|
-
if (this._decoderBusy = !1, this._decoder instanceof
|
|
5229
|
+
if (this._decoderBusy = !1, this._decoder instanceof xi && typeof e == "string" && e.includes("EncodingError")) {
|
|
5118
5230
|
this._decoderQueue = [], !this._webCodecsRetryAttempted && e.includes("reset because error during decoding") ? (this._webCodecsRetryAttempted = !0, this._debug.warn("StreamBuilder retry WebCodecs with software decoder"), this._onKeyFrameRequested?.()) : this._switchToLibVPXDecoder();
|
|
5119
5231
|
return;
|
|
5120
5232
|
}
|
|
@@ -5122,7 +5234,7 @@ var di = class {
|
|
|
5122
5234
|
}, this._onKeyFrameRequested).then(() => {
|
|
5123
5235
|
this._decoderReady = !0, this._decodeQueue();
|
|
5124
5236
|
}).catch((e) => {
|
|
5125
|
-
this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof
|
|
5237
|
+
this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof xi && this._switchToLibVPXDecoder();
|
|
5126
5238
|
});
|
|
5127
5239
|
}
|
|
5128
5240
|
_switchToLibVPXDecoder() {
|
|
@@ -5137,20 +5249,20 @@ var di = class {
|
|
|
5137
5249
|
super.destroy(), this._fpsMeter.destroy(), this._decoder.destroy(), this._renderer.destroy(), this._debug.debug(`StreamBuilder destroyed for participant ${this._participantId}`);
|
|
5138
5250
|
}
|
|
5139
5251
|
static isBrowserSupported() {
|
|
5140
|
-
return
|
|
5252
|
+
return Oi.isBrowserSupported() || ki.isBrowserSupported();
|
|
5141
5253
|
}
|
|
5142
|
-
},
|
|
5143
|
-
function
|
|
5254
|
+
}, ji = 1, Mi = 1, Ni = 2, Pi = 0, Fi = 1, Ii = 2, Li = 4, Ri = 8;
|
|
5255
|
+
function zi(e, t, n, r, i, a, o) {
|
|
5144
5256
|
let s = 0;
|
|
5145
|
-
t && (s |=
|
|
5257
|
+
t && (s |= Fi), n && (s |= Ii), r && (s |= Li), o || (s |= Ri);
|
|
5146
5258
|
let c = /* @__PURE__ */ new ArrayBuffer(11), l = new DataView(c);
|
|
5147
|
-
if (l.setUint8(0,
|
|
5259
|
+
if (l.setUint8(0, ji), l.setUint16(1, i), l.setUint32(3, e), l.setUint8(7, +!!a), l.setUint16(8, Pi), l.setUint8(10, s), !o) return c;
|
|
5148
5260
|
let u = new Uint8Array(c.byteLength + o.byteLength);
|
|
5149
5261
|
return u.set(new Uint8Array(c), 0), u.set(new Uint8Array(o), c.byteLength), u.buffer;
|
|
5150
5262
|
}
|
|
5151
|
-
function
|
|
5152
|
-
let t = new DataView(e), n = t.getUint8(0), r = t.getUint16(1), i = t.getUint32(3), a = t.getUint8(7) === 1, o = t.getUint16(8), s = t.getUint8(10), c = !!(s &
|
|
5153
|
-
if (n !==
|
|
5263
|
+
function Bi(e) {
|
|
5264
|
+
let t = new DataView(e), n = t.getUint8(0), r = t.getUint16(1), i = t.getUint32(3), a = t.getUint8(7) === 1, o = t.getUint16(8), s = t.getUint8(10), c = !!(s & Fi), l = !!(s & Ii), u = !!(s & Li), d = !!(s & Ri);
|
|
5265
|
+
if (n !== ji) throw Error(`Unexpected protocol version. Got ${n}, expected ${ji}`);
|
|
5154
5266
|
return {
|
|
5155
5267
|
timestamp: i,
|
|
5156
5268
|
start: c,
|
|
@@ -5163,26 +5275,26 @@ function Pi(e) {
|
|
|
5163
5275
|
data: e.slice(11)
|
|
5164
5276
|
};
|
|
5165
5277
|
}
|
|
5166
|
-
function
|
|
5278
|
+
function Vi(e) {
|
|
5167
5279
|
if (!e || !e.byteLength || e.byteLength !== 4) return !1;
|
|
5168
5280
|
let t = new DataView(e);
|
|
5169
|
-
return !(t.getUint8(0) !==
|
|
5281
|
+
return !(t.getUint8(0) !== ji || t.getUint8(1) !== Mi || t.getUint16(2) !== Pi);
|
|
5170
5282
|
}
|
|
5171
|
-
function
|
|
5283
|
+
function Hi(e) {
|
|
5172
5284
|
if (!e || !e.byteLength || e.byteLength !== 10) return null;
|
|
5173
5285
|
let t = new DataView(e);
|
|
5174
|
-
return t.getUint8(0) !==
|
|
5286
|
+
return t.getUint8(0) !== ji || t.getUint8(1) !== Ni || t.getUint16(2) !== Pi ? null : {
|
|
5175
5287
|
seq: t.getUint16(4),
|
|
5176
5288
|
ts2: t.getUint32(6)
|
|
5177
5289
|
};
|
|
5178
5290
|
}
|
|
5179
|
-
function
|
|
5291
|
+
function Ui(e) {
|
|
5180
5292
|
let t = /* @__PURE__ */ new ArrayBuffer(4), n = new DataView(t);
|
|
5181
|
-
return n.setUint8(0,
|
|
5293
|
+
return n.setUint8(0, ji), n.setUint8(1, Mi), n.setUint16(2, e), t;
|
|
5182
5294
|
}
|
|
5183
5295
|
//#endregion
|
|
5184
5296
|
//#region src/classes/screenshare/WebmBuilder.ts
|
|
5185
|
-
var
|
|
5297
|
+
var Wi = 2 ** 15 - 1, Gi = 1, Ki = 5, qi = 5, Ji = class e {
|
|
5186
5298
|
constructor(e, t = z) {
|
|
5187
5299
|
h(this, "_mediaSource", void 0), h(this, "_codec", void 0), h(this, "_sourceBuffer", null), h(this, "_queue", []), h(this, "_clearBufferTill", 0), h(this, "_debug", void 0), this._mediaSource = new MediaSource(), this._codec = e, this._debug = t;
|
|
5188
5300
|
let n = () => {
|
|
@@ -5225,8 +5337,8 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5225
5337
|
this._mediaSource?.readyState === "open" && this._sourceBuffer?.abort();
|
|
5226
5338
|
let e = this._sourceBuffer?.buffered, t = e?.length;
|
|
5227
5339
|
if (!t) return;
|
|
5228
|
-
let n = e.start(0), r = Math.max(0, e.end(t - 1) -
|
|
5229
|
-
r - n >
|
|
5340
|
+
let n = e.start(0), r = Math.max(0, e.end(t - 1) - Ki);
|
|
5341
|
+
r - n > qi && (this._clearBufferTill = r);
|
|
5230
5342
|
}
|
|
5231
5343
|
destroy() {
|
|
5232
5344
|
this._queue = [], this._mediaSource.readyState === "open" && (this._sourceBuffer?.abort(), this._mediaSource.endOfStream()), this._sourceBuffer = null, this._clearBufferTill = 0;
|
|
@@ -5240,7 +5352,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5240
5352
|
get buffered() {
|
|
5241
5353
|
return this._sourceBuffer?.buffered;
|
|
5242
5354
|
}
|
|
5243
|
-
},
|
|
5355
|
+
}, Yi = class e extends Ei {
|
|
5244
5356
|
constructor(e, t, n, r, i = z) {
|
|
5245
5357
|
super(e, t, n, r, void 0, i), h(this, "_mediaBuffer", null), h(this, "_video", null), h(this, "_stream", null), h(this, "_earliestTimestamp", 0), h(this, "_clusterStartTime", 0), h(this, "_lastFrameTimestamp", 0), this._debug.debug(`[WebmBuilder] started for participant [${e}]`);
|
|
5246
5358
|
}
|
|
@@ -5264,8 +5376,8 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5264
5376
|
u.element(u.ID.MuxingApp, u.string("vk-webm-builder")),
|
|
5265
5377
|
u.element(u.ID.WritingApp, u.string("vk-webm-builder"))
|
|
5266
5378
|
]), i = [u.element(u.ID.PixelWidth, u.number(e)), u.element(u.ID.PixelHeight, u.number(t))], a = u.element(u.ID.Tracks, u.element(u.ID.TrackEntry, [
|
|
5267
|
-
u.element(u.ID.TrackNumber, u.number(
|
|
5268
|
-
u.element(u.ID.TrackUID, u.number(
|
|
5379
|
+
u.element(u.ID.TrackNumber, u.number(Gi)),
|
|
5380
|
+
u.element(u.ID.TrackUID, u.number(Gi)),
|
|
5269
5381
|
u.element(u.ID.TrackType, u.number(1)),
|
|
5270
5382
|
u.element(u.ID.FlagLacing, u.number(0)),
|
|
5271
5383
|
u.element(u.ID.DefaultDuration, u.number(1e9)),
|
|
@@ -5278,7 +5390,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5278
5390
|
return u.unknownSizeElement(u.ID.Cluster, [u.element(u.ID.Timecode, u.number(Math.round(e)))]);
|
|
5279
5391
|
}
|
|
5280
5392
|
_createVideo(e) {
|
|
5281
|
-
this._mediaBuffer = new
|
|
5393
|
+
this._mediaBuffer = new Ji(e, this._debug), this._video = document.createElement("video"), this._video.autoplay = !0, this._video.controls = !1, this._video.muted = !0, this._video.style.pointerEvents = "none", this._video.style.visibility = "hidden", this._video.style.position = "absolute", this._video.style.width = "160px", this._video.style.height = "90px", this._video.style.bottom = "0", this._video.style.right = "0", this._video.style.zIndex = "5000", this._video.src = URL.createObjectURL(this._mediaBuffer.mediaSource), document.body.appendChild(this._video);
|
|
5282
5394
|
let t = () => {
|
|
5283
5395
|
if (this._video?.src) {
|
|
5284
5396
|
this._debug.warn(`[WebmBuilder] Video paused for participant [${this._participantId}], try to play again`);
|
|
@@ -5305,13 +5417,13 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5305
5417
|
this._mediaBuffer?.append(a);
|
|
5306
5418
|
}
|
|
5307
5419
|
let i = Math.round(r - this._clusterStartTime);
|
|
5308
|
-
if (i >
|
|
5420
|
+
if (i > Wi && (this._clusterStartTime = r, i = 0), i === 0) {
|
|
5309
5421
|
this._debug.debug(`[WebmBuilder] Cluster header for participant [${this._participantId}]`);
|
|
5310
5422
|
let t = e._genClusterHeader(this._clusterStartTime);
|
|
5311
5423
|
this._mediaBuffer?.append(t);
|
|
5312
5424
|
}
|
|
5313
5425
|
let a = u.element(u.ID.SimpleBlock, [
|
|
5314
|
-
u.vintEncodedNumber(
|
|
5426
|
+
u.vintEncodedNumber(Gi),
|
|
5315
5427
|
u.bytes(e._intToU16BE(i)),
|
|
5316
5428
|
u.number(!!t.keyframe << 7),
|
|
5317
5429
|
u.bytes(t.frameData)
|
|
@@ -5324,12 +5436,12 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5324
5436
|
static isBrowserSupported() {
|
|
5325
5437
|
return "captureStream" in window.HTMLVideoElement?.prototype && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp8\"") && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp9\"");
|
|
5326
5438
|
}
|
|
5327
|
-
},
|
|
5439
|
+
}, Xi = class {
|
|
5328
5440
|
constructor(e, t, n, r, i, a = null, o = z, s = null) {
|
|
5329
5441
|
h(this, "_datachannel", void 0), h(this, "_participantIdRegistry", null), h(this, "_streamBuilders", {}), h(this, "_onStream", () => {}), h(this, "_onEos", () => {}), h(this, "_onStat", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), this._debug = o, this._logger = s, this._statAggregator = a, this._debug.debug("ScreenCaptureReceiver started"), this._datachannel = e, this._participantIdRegistry = t, this._onStream = n, this._onEos = r, this._onStat = i, this._datachannel.onmessage = (e) => this._onDataChannelMessage(e.data);
|
|
5330
5442
|
}
|
|
5331
5443
|
_onDataChannelMessage(e) {
|
|
5332
|
-
let t =
|
|
5444
|
+
let t = Bi(e), n = this._participantIdRegistry?.getStreamDescription(t.ssrc)?.participantId;
|
|
5333
5445
|
if (!n) {
|
|
5334
5446
|
this._debug.warn(`Participant id for ssrc ${t.ssrc} not found in registry`);
|
|
5335
5447
|
return;
|
|
@@ -5341,7 +5453,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5341
5453
|
let r = this._streamBuilders[n];
|
|
5342
5454
|
if (!r) {
|
|
5343
5455
|
let e = (e) => this._onStream(n, e);
|
|
5344
|
-
r = N.screenShareWebmBuilder &&
|
|
5456
|
+
r = N.screenShareWebmBuilder && Yi.isBrowserSupported() ? new Yi(n, e, this._onStat, this._statAggregator, this._debug) : new Ai(n, e, this._onStat, this._statAggregator, () => {
|
|
5345
5457
|
this._requestKeyFrame(t.ssrc);
|
|
5346
5458
|
}, this._debug, this._logger), this._streamBuilders[n] = r;
|
|
5347
5459
|
}
|
|
@@ -5349,7 +5461,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5349
5461
|
}
|
|
5350
5462
|
_requestKeyFrame(e) {
|
|
5351
5463
|
if (!(!this._datachannel || this._datachannel.readyState !== "open")) try {
|
|
5352
|
-
let t =
|
|
5464
|
+
let t = Ui(e);
|
|
5353
5465
|
this._datachannel.send(t), this._debug.debug(`ScreenCaptureReceiver request for keyframe for ssrc ${e}`);
|
|
5354
5466
|
} catch (e) {
|
|
5355
5467
|
this._debug.warn("Failed to send keyframe request", e);
|
|
@@ -5362,7 +5474,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5362
5474
|
destroy() {
|
|
5363
5475
|
this._datachannel.onbufferedamountlow = null, this._datachannel.onmessage = null, this._onStream = () => {}, Object.values(this._streamBuilders).forEach((e) => e.destroy()), this._streamBuilders = {}, this._participantIdRegistry = null, this._debug.debug("ScreenCaptureReceiver destroyed");
|
|
5364
5476
|
}
|
|
5365
|
-
},
|
|
5477
|
+
}, Zi = class {
|
|
5366
5478
|
constructor(e, t, n) {
|
|
5367
5479
|
h(this, "_prev", void 0), h(this, "_next", void 0), h(this, "_data", void 0), this._next = n, n && (n.prev = this), this._prev = t, t && (t.next = this), this._data = e;
|
|
5368
5480
|
}
|
|
@@ -5381,7 +5493,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5381
5493
|
get data() {
|
|
5382
5494
|
return this._data;
|
|
5383
5495
|
}
|
|
5384
|
-
},
|
|
5496
|
+
}, Qi = class {
|
|
5385
5497
|
constructor() {
|
|
5386
5498
|
h(this, "_head", null), h(this, "_tail", null), h(this, "_length", 0);
|
|
5387
5499
|
}
|
|
@@ -5389,7 +5501,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5389
5501
|
return this._length;
|
|
5390
5502
|
}
|
|
5391
5503
|
push(...e) {
|
|
5392
|
-
for (let t of e) this._tail = new
|
|
5504
|
+
for (let t of e) this._tail = new Zi(t, this._tail, null), this._head || (this._head = this._tail), this._length++;
|
|
5393
5505
|
}
|
|
5394
5506
|
merge(e) {
|
|
5395
5507
|
this._tail && (this._tail.next = e._head), this._head || (this._head = e._head), this._tail = e._tail, this._length += e._length, e.clear();
|
|
@@ -5419,7 +5531,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5419
5531
|
for (; t !== null;) e.push(t.data), t = t.next;
|
|
5420
5532
|
return e.length ? JSON.stringify(e, (e, t) => t instanceof Error ? String(t) : t) : "";
|
|
5421
5533
|
}
|
|
5422
|
-
},
|
|
5534
|
+
}, $i = 1e3, ea = class extends yi {
|
|
5423
5535
|
constructor(e, t, n, r, i = z, a = null) {
|
|
5424
5536
|
super(i, a), h(this, "_sourceTrack", void 0), h(this, "_onFrame", void 0), h(this, "_useCongestionControl", void 0), h(this, "_maxBitrate", void 0), h(this, "_useImageCapture", void 0), h(this, "_video", null), h(this, "_imageCapture", null), h(this, "_canvas", null), h(this, "_canvasCtx", null), h(this, "_frameReadTimeout", 0), h(this, "_lastFrame", null), this._sourceTrack = e, this._onFrame = t, this._useCongestionControl = n, this._maxBitrate = r, this._useImageCapture = "ImageCapture" in window && ImageCapture.prototype.grabFrame !== void 0 && "ImageBitmap" in window, (e.readyState !== "live" || !e.enabled || e.muted) && (this._useImageCapture = !1);
|
|
5425
5537
|
}
|
|
@@ -5488,7 +5600,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5488
5600
|
}
|
|
5489
5601
|
_encode(e, t) {
|
|
5490
5602
|
let n = e.data.buffer;
|
|
5491
|
-
this._sendToWorker(
|
|
5603
|
+
this._sendToWorker(vi.FRAME, {
|
|
5492
5604
|
width: e.width,
|
|
5493
5605
|
height: e.height,
|
|
5494
5606
|
imageData: n,
|
|
@@ -5505,7 +5617,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5505
5617
|
let t = this._drawFrameData(this._lastFrame);
|
|
5506
5618
|
this._encode(t, e);
|
|
5507
5619
|
} else this._onFrame(null);
|
|
5508
|
-
},
|
|
5620
|
+
}, $i), this._getFrameBitmap().then((t) => {
|
|
5509
5621
|
window.clearTimeout(this._frameReadTimeout), this._lastFrame?.close(), this._lastFrame = t;
|
|
5510
5622
|
let n = this._drawFrameData(t);
|
|
5511
5623
|
this._encode(n, e);
|
|
@@ -5515,7 +5627,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5515
5627
|
this._useImageCapture ? this._requestFrameBitmap(e) : this._requestFrameVideo(e);
|
|
5516
5628
|
}
|
|
5517
5629
|
setBitrate(e, t, n) {
|
|
5518
|
-
this._sendToWorker(
|
|
5630
|
+
this._sendToWorker(vi.SET_BITRATE, {
|
|
5519
5631
|
bitrate: e,
|
|
5520
5632
|
useCbr: t
|
|
5521
5633
|
});
|
|
@@ -5526,7 +5638,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5526
5638
|
destroy() {
|
|
5527
5639
|
this._removeWorker(), this._removeStream(), this._removeDom(), this._debug.debug("LibVPxEncoder destroyed");
|
|
5528
5640
|
}
|
|
5529
|
-
},
|
|
5641
|
+
}, ta = class extends yi {
|
|
5530
5642
|
constructor(e, t, n, r, i, a, o = z, s = null) {
|
|
5531
5643
|
super(o, s), h(this, "_sourceTrack", void 0), h(this, "_trackProcessor", void 0), h(this, "_onFrame", void 0), h(this, "_useCongestionControl", void 0), h(this, "_maxBitrate", void 0), h(this, "_useCbr", void 0), h(this, "_frameRate", void 0), this._sourceTrack = e, this._onFrame = t, this._useCongestionControl = n, this._maxBitrate = r, this._useCbr = i, this._frameRate = a, this._trackProcessor = new MediaStreamTrackProcessor({ track: e });
|
|
5532
5644
|
}
|
|
@@ -5554,10 +5666,10 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5554
5666
|
}, [n]);
|
|
5555
5667
|
}
|
|
5556
5668
|
requestFrame(e = !1) {
|
|
5557
|
-
this._sendToWorker(
|
|
5669
|
+
this._sendToWorker(vi.FRAME, { keyFrame: e });
|
|
5558
5670
|
}
|
|
5559
5671
|
setBitrate(e, t, n) {
|
|
5560
|
-
this._sendToWorker(
|
|
5672
|
+
this._sendToWorker(vi.SET_BITRATE, {
|
|
5561
5673
|
bitrate: e,
|
|
5562
5674
|
useCbr: t,
|
|
5563
5675
|
fps: n
|
|
@@ -5572,11 +5684,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5572
5684
|
static isBrowserSupported() {
|
|
5573
5685
|
return "VideoEncoder" in window && "Worker" in window && "EncodedVideoChunk" in window && "MediaStreamTrackProcessor" in window;
|
|
5574
5686
|
}
|
|
5575
|
-
},
|
|
5687
|
+
}, na = 2100, ra = 600, ia = 1.2, aa = .8, oa = 2e3, sa = 8e3, ca = 8e3, la = 16e3, ua = 4, da = 2e3, fa = /* @__PURE__ */ function(e) {
|
|
5576
5688
|
return e[e.NONE = 0] = "NONE", e[e.UP = 1] = "UP", e[e.DOWN = 2] = "DOWN", e;
|
|
5577
|
-
}(
|
|
5689
|
+
}(fa || {}), pa = class {
|
|
5578
5690
|
constructor(e, t, n, r, i, a, o, s = z) {
|
|
5579
|
-
h(this, "_onCongestion", void 0), h(this, "_ccEnabled", void 0), h(this, "_fastSharing", void 0), h(this, "_trendDelayThreshold", void 0), h(this, "_highDelayThreshold", void 0), h(this, "_targetFps", void 0), h(this, "_minBitrate", void 0), h(this, "_maxBitrate", void 0), h(this, "_targetBitrate", void 0), h(this, "_lastDown", void 0), h(this, "_lastUp", void 0), h(this, "_lastProbing", void 0), h(this, "_lastCheckDelay", void 0), h(this, "_upPenalty", 0), h(this, "_probing", void 0), h(this, "_delayAvgShort", -1), h(this, "_delayAvgLong", -1), h(this, "_minDelay", Number.MAX_VALUE), h(this, "_maxDelay", 0), h(this, "_largeDelayDuration", 0), h(this, "_lastFpsCalcMs", void 0), h(this, "_frames", 0), h(this, "_fps", 0), h(this, "_debug", void 0), this._onCongestion = e, this._ccEnabled = r, this._debug = s, this._minBitrate = t, this._maxBitrate = n, this._fastSharing = i, this._targetFps = o, a > 0 ? this._highDelayThreshold = a : this._highDelayThreshold =
|
|
5691
|
+
h(this, "_onCongestion", void 0), h(this, "_ccEnabled", void 0), h(this, "_fastSharing", void 0), h(this, "_trendDelayThreshold", void 0), h(this, "_highDelayThreshold", void 0), h(this, "_targetFps", void 0), h(this, "_minBitrate", void 0), h(this, "_maxBitrate", void 0), h(this, "_targetBitrate", void 0), h(this, "_lastDown", void 0), h(this, "_lastUp", void 0), h(this, "_lastProbing", void 0), h(this, "_lastCheckDelay", void 0), h(this, "_upPenalty", 0), h(this, "_probing", void 0), h(this, "_delayAvgShort", -1), h(this, "_delayAvgLong", -1), h(this, "_minDelay", Number.MAX_VALUE), h(this, "_maxDelay", 0), h(this, "_largeDelayDuration", 0), h(this, "_lastFpsCalcMs", void 0), h(this, "_frames", 0), h(this, "_fps", 0), h(this, "_debug", void 0), this._onCongestion = e, this._ccEnabled = r, this._debug = s, this._minBitrate = t, this._maxBitrate = n, this._fastSharing = i, this._targetFps = o, a > 0 ? this._highDelayThreshold = a : this._highDelayThreshold = na, i && (this._highDelayThreshold = ra), this._trendDelayThreshold = Math.round(this._highDelayThreshold / 3), this._targetBitrate = this._maxBitrate, this._probing = !1;
|
|
5580
5692
|
let c = Date.now();
|
|
5581
5693
|
this._lastDown = 0, this._lastUp = c, this._lastProbing = c, this._lastCheckDelay = 0, this._lastFpsCalcMs = 0;
|
|
5582
5694
|
}
|
|
@@ -5586,27 +5698,27 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5586
5698
|
let i = 0, a = this._delayAvgShort - this._delayAvgLong, o = Math.round(Math.abs(a) * 100 / this._delayAvgLong), s = a > 40 && o > 30 && this._delayAvgShort > this._trendDelayThreshold, c = this._delayAvgShort > this._highDelayThreshold;
|
|
5587
5699
|
s || c ? i = 2 : Math.abs(a) < 40 && o < 10 && !c && (i = 1);
|
|
5588
5700
|
let l = Math.round(this._targetBitrate / 1e3), u = n;
|
|
5589
|
-
e % 20 == 0 && this._debug.debug(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${
|
|
5701
|
+
e % 20 == 0 && this._debug.debug(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${fa[i]} tr=${l} br=${n}`);
|
|
5590
5702
|
let d = r - this._lastDown;
|
|
5591
|
-
if (i === 2 && d >
|
|
5592
|
-
this._probing && (this._upPenalty = Math.min(++this._upPenalty,
|
|
5593
|
-
let n =
|
|
5594
|
-
if (n >= this._targetBitrate && (n = this._targetBitrate *
|
|
5595
|
-
let r = Math.round(n / 1e3), s = Math.round(this._upPenalty *
|
|
5596
|
-
this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${
|
|
5703
|
+
if (i === 2 && d > oa) {
|
|
5704
|
+
this._probing && (this._upPenalty = Math.min(++this._upPenalty, ua), this._probing = !1);
|
|
5705
|
+
let n = aa * u * 1e3;
|
|
5706
|
+
if (n >= this._targetBitrate && (n = this._targetBitrate * aa), n = Math.max(n, this._minBitrate), n < this._targetBitrate) {
|
|
5707
|
+
let r = Math.round(n / 1e3), s = Math.round(this._upPenalty * ca / 1e3);
|
|
5708
|
+
this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${fa[i]}`), this._debug.log(`#${e}: cc: DOWN delay=${t} bitrate=${u} target=${l} -> newBitrate=${r} penalty=${s}s`), this._setBitrate(n, !0), this._targetBitrate = n;
|
|
5597
5709
|
}
|
|
5598
5710
|
this._lastDown = r;
|
|
5599
5711
|
}
|
|
5600
|
-
let f = r - this._lastUp, p =
|
|
5712
|
+
let f = r - this._lastUp, p = sa + this._upPenalty * ca;
|
|
5601
5713
|
if (i === 1 && f > p && d > p) {
|
|
5602
|
-
let n = Math.min(this._targetBitrate *
|
|
5714
|
+
let n = Math.min(this._targetBitrate * ia, this._maxBitrate);
|
|
5603
5715
|
if (n > this._targetBitrate) {
|
|
5604
|
-
let s = Math.round(n / 1e3), c = Math.round(this._targetBitrate / 1e3), l = Math.round(this._upPenalty *
|
|
5605
|
-
this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${
|
|
5716
|
+
let s = Math.round(n / 1e3), c = Math.round(this._targetBitrate / 1e3), l = Math.round(this._upPenalty * ca / 1e3);
|
|
5717
|
+
this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${fa[i]}`), this._debug.log(`#${e}: cc: UP bitrate=${u} target=${c} -> newBitrate=${s} penalty=${l}s`), this._setBitrate(n, !1), this._targetBitrate = n, this._probing = !0, this._lastProbing = r, this._lastUp = r;
|
|
5606
5718
|
}
|
|
5607
5719
|
}
|
|
5608
5720
|
let m = r - this._lastProbing;
|
|
5609
|
-
this._probing && m >
|
|
5721
|
+
this._probing && m > la && (this._probing = !1);
|
|
5610
5722
|
let ee = r - this._lastDown;
|
|
5611
5723
|
this._upPenalty > 0 && ee > 3 * p && (this._debug.log(`#${e}: cc: UP reset penalty: oldPenalty=${this._upPenalty}`), this._upPenalty = 0);
|
|
5612
5724
|
}
|
|
@@ -5617,7 +5729,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5617
5729
|
}
|
|
5618
5730
|
_calcDelay(e, t) {
|
|
5619
5731
|
if (!(e <= 0)) {
|
|
5620
|
-
if (this._delayAvgShort === -1 && (this._delayAvgShort = e, this._delayAvgLong = e), this._delayAvgShort = Math.round((this._delayAvgShort * 3 + e) / 4), this._delayAvgLong = Math.round((this._delayAvgLong * 23 + e) / 24), e > 0 && e < this._minDelay ? this._minDelay = e : e > this._maxDelay && (this._maxDelay = e), this._lastCheckDelay === 0 && (this._lastCheckDelay = t), e >
|
|
5732
|
+
if (this._delayAvgShort === -1 && (this._delayAvgShort = e, this._delayAvgLong = e), this._delayAvgShort = Math.round((this._delayAvgShort * 3 + e) / 4), this._delayAvgLong = Math.round((this._delayAvgLong * 23 + e) / 24), e > 0 && e < this._minDelay ? this._minDelay = e : e > this._maxDelay && (this._maxDelay = e), this._lastCheckDelay === 0 && (this._lastCheckDelay = t), e > da) {
|
|
5621
5733
|
let e = t - this._lastCheckDelay;
|
|
5622
5734
|
this._largeDelayDuration += e;
|
|
5623
5735
|
}
|
|
@@ -5646,7 +5758,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5646
5758
|
this._fps === 0 ? this._fps = Math.round(r) : this._fps = Math.round((this._fps * 3 + r) / 4), this._frames = 0, this._fps !== n && this._debug.log(`cc: fps=${this._fps}`);
|
|
5647
5759
|
}
|
|
5648
5760
|
}
|
|
5649
|
-
},
|
|
5761
|
+
}, ma = class {
|
|
5650
5762
|
constructor(e) {
|
|
5651
5763
|
h(this, "_maxSize", void 0), h(this, "_size", 0), h(this, "_buffer", void 0), h(this, "_head", 0), h(this, "_tail", 0), this._maxSize = e, this._buffer = Array(e);
|
|
5652
5764
|
}
|
|
@@ -5720,11 +5832,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5720
5832
|
clear() {
|
|
5721
5833
|
this._buffer.fill(void 0), this._size = 0, this._head = 0, this._tail = 0;
|
|
5722
5834
|
}
|
|
5723
|
-
},
|
|
5835
|
+
}, ha = 65536, ga = 50, _a = 400, va = 1e6, ya = 3e5, ba = 3e4, xa = 2e3, Sa = 5, Ca = 0, wa = class {
|
|
5724
5836
|
constructor(e, t, n, r, i = z, a = null) {
|
|
5725
|
-
h(this, "_encoder", void 0), h(this, "_datachannel", void 0), h(this, "_signaling", void 0), h(this, "_fastSharing", void 0), h(this, "_destroyed", !1), h(this, "_needKeyframe", !0), h(this, "DATA_SIZE", void 0), h(this, "_congestionControl", void 0), h(this, "_frameNum", 0), h(this, "_width", void 0), h(this, "_height", void 0), h(this, "_feedback", new
|
|
5837
|
+
h(this, "_encoder", void 0), h(this, "_datachannel", void 0), h(this, "_signaling", void 0), h(this, "_fastSharing", void 0), h(this, "_destroyed", !1), h(this, "_needKeyframe", !0), h(this, "DATA_SIZE", void 0), h(this, "_congestionControl", void 0), h(this, "_frameNum", 0), h(this, "_width", void 0), h(this, "_height", void 0), h(this, "_feedback", new ma(1024)), h(this, "_lastSentFrameSeq", 0), h(this, "_lastDeliveredFrameSeq", 0), h(this, "_lastFrameDelay", 0), h(this, "_lastFramerateReduced", Date.now()), h(this, "_lastSharingStat", Date.now()), h(this, "_congestionControlEnabled", void 0), h(this, "_queue", new Qi()), h(this, "_fpsMeter", void 0), h(this, "_maxFrameDelay", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = i, this._logger = a, this._debug.debug("ScreenCaptureSender started"), this.DATA_SIZE = N.consumerScreenDataChannelPacketSize - 11, this._datachannel = t, this._signaling = n, this._fastSharing = r, this._congestionControlEnabled = N.screenShareCongestionControl || this._fastSharing, this._width = e.getSettings().width, this._height = e.getSettings().height, this._maxFrameDelay = this._fastSharing ? N.screenShareCongestionControlThreshold : N.screenShareCongestionControlThreshold * 2;
|
|
5726
5838
|
let o = N.getScreenFrameRate(this._fastSharing), { minBitrate: s, maxBitrate: c } = this._calcMinMaxBitrate(this._width, this._height), l = this._onCongestionCallback.bind(this);
|
|
5727
|
-
this._debug.log(`ScreenCaptureSender: CongestionControl: enabled=${this._congestionControlEnabled} minBitrate=${Math.round(s / 1e3)}k maxBitrate=${Math.round(c / 1e3)}k delayThreshold=${N.screenShareCongestionControlThreshold}`), this._congestionControl = new
|
|
5839
|
+
this._debug.log(`ScreenCaptureSender: CongestionControl: enabled=${this._congestionControlEnabled} minBitrate=${Math.round(s / 1e3)}k maxBitrate=${Math.round(c / 1e3)}k delayThreshold=${N.screenShareCongestionControlThreshold}`), this._congestionControl = new pa(l, s, c, this._congestionControlEnabled, this._fastSharing, N.screenShareCongestionControlThreshold, o, this._debug);
|
|
5728
5840
|
let u = (e, t) => {
|
|
5729
5841
|
if (this._destroyed) return;
|
|
5730
5842
|
if (!e) {
|
|
@@ -5735,23 +5847,23 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5735
5847
|
let n = this._sliceFrame(e);
|
|
5736
5848
|
this._queue.merge(n), this._handleQueue(), this._sendSharingStat();
|
|
5737
5849
|
};
|
|
5738
|
-
if (
|
|
5850
|
+
if (ta.isBrowserSupported()) {
|
|
5739
5851
|
let t = this._fastSharing;
|
|
5740
|
-
this._encoder = new
|
|
5741
|
-
} else this._encoder = new
|
|
5852
|
+
this._encoder = new ta(e, u, this._congestionControlEnabled, c, t, o, this._debug, this._logger);
|
|
5853
|
+
} else this._encoder = new ea(e, u, this._congestionControlEnabled, c, this._debug, this._logger);
|
|
5742
5854
|
this._datachannel.onmessage = (e) => {
|
|
5743
|
-
|
|
5744
|
-
let t =
|
|
5855
|
+
Vi(e.data) && (this._debug.debug(`[${this._datachannel.label}] Requested keyframe`), this._needKeyframe = !0);
|
|
5856
|
+
let t = Hi(e.data);
|
|
5745
5857
|
t !== null && this._checkCcFeedback(t);
|
|
5746
|
-
}, this._encoder.init().then(() => this._handleQueue()).catch((e) => this._debug.warn("ScreenCaptureSender init failed", e)), this._fpsMeter = new
|
|
5858
|
+
}, this._encoder.init().then(() => this._handleQueue()).catch((e) => this._debug.warn("ScreenCaptureSender init failed", e)), this._fpsMeter = new Si((e) => this._debug.log(`[ScreenCaptureSender] fps: ${e}`), 5e3);
|
|
5747
5859
|
}
|
|
5748
5860
|
_handleQueue() {
|
|
5749
5861
|
if (this._destroyed) return;
|
|
5750
5862
|
let e = this._queue.shift();
|
|
5751
5863
|
if (!e) {
|
|
5752
|
-
if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq +
|
|
5864
|
+
if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq + ha) % ha > Sa && this._lastFrameDelay > this._maxFrameDelay) {
|
|
5753
5865
|
let e = Date.now();
|
|
5754
|
-
e - this._lastFramerateReduced >
|
|
5866
|
+
e - this._lastFramerateReduced > xa && (this._lastFramerateReduced = e, this._debug.debug(`[ScreenCaptureSender] reduce framerate: delay=${this._lastFrameDelay} maxDelay=${this._maxFrameDelay}`));
|
|
5755
5867
|
} else this._requestFrame();
|
|
5756
5868
|
return;
|
|
5757
5869
|
}
|
|
@@ -5777,7 +5889,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5777
5889
|
this._destroyed || (this._encoder.requestFrame(this._needKeyframe), this._needKeyframe = !1);
|
|
5778
5890
|
}
|
|
5779
5891
|
_sliceFrame(e) {
|
|
5780
|
-
let t = e.type === "key", n = e.data.byteLength, r = new
|
|
5892
|
+
let t = e.type === "key", n = e.data.byteLength, r = new Qi();
|
|
5781
5893
|
for (let i = 0; i < n; i += this.DATA_SIZE) {
|
|
5782
5894
|
let a = e.data.slice(i, i + this.DATA_SIZE), o = i === 0, s = n <= i + a.byteLength, c = this._wrapHeader(e.timestamp, o, s, t, a);
|
|
5783
5895
|
r.push({
|
|
@@ -5793,11 +5905,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5793
5905
|
return r;
|
|
5794
5906
|
}
|
|
5795
5907
|
_wrapHeader(e, t, n, r, i) {
|
|
5796
|
-
let a =
|
|
5797
|
-
sequence:
|
|
5908
|
+
let a = zi(e, t, n, r, Ca, this._encoder.isVP9(), i), o = {
|
|
5909
|
+
sequence: Ca,
|
|
5798
5910
|
data: a
|
|
5799
5911
|
};
|
|
5800
|
-
return
|
|
5912
|
+
return Ca = (Ca + 1) % ha, o;
|
|
5801
5913
|
}
|
|
5802
5914
|
_stopPacket() {
|
|
5803
5915
|
return this._wrapHeader(Date.now(), !1, !1, !1, null).data;
|
|
@@ -5814,7 +5926,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5814
5926
|
this._queue.clear(), this._fpsMeter.destroy(), this._datachannel.onmessage = null, this._feedback.clear(), this._datachannel.readyState === "open" && this._datachannel.send(this._stopPacket()), this._destroyed = !0, this._encoder.destroy(), this._debug.debug("ScreenCaptureSender destroyed");
|
|
5815
5927
|
}
|
|
5816
5928
|
static isBrowserSupported() {
|
|
5817
|
-
return
|
|
5929
|
+
return ta.isBrowserSupported() || ea.isBrowserSupported();
|
|
5818
5930
|
}
|
|
5819
5931
|
_onCongestionCallback(e, t, n) {
|
|
5820
5932
|
this._encoder.setBitrate(e, t, n);
|
|
@@ -5827,8 +5939,8 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5827
5939
|
(e === void 0 || e < 640) && (e = 640), (t === void 0 || t < 360) && (t = 360);
|
|
5828
5940
|
let n = e * t / 256;
|
|
5829
5941
|
return {
|
|
5830
|
-
minBitrate: Math.max(
|
|
5831
|
-
maxBitrate: Math.round(n *
|
|
5942
|
+
minBitrate: Math.max(ya, Math.min(va, Math.round(n * ga))),
|
|
5943
|
+
maxBitrate: Math.round(n * _a)
|
|
5832
5944
|
};
|
|
5833
5945
|
}
|
|
5834
5946
|
_checkCcFeedback(e) {
|
|
@@ -5842,14 +5954,14 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5842
5954
|
}
|
|
5843
5955
|
_sendSharingStat() {
|
|
5844
5956
|
let e = Date.now();
|
|
5845
|
-
if (e - this._lastSharingStat >
|
|
5957
|
+
if (e - this._lastSharingStat > ba) {
|
|
5846
5958
|
let t = this._congestionControl.getStat();
|
|
5847
5959
|
t !== null && (this._debug.debug(`cc: send stats: ${JSON.stringify(t)}`), this._signaling.reportSharingStat(t).catch((e) => {
|
|
5848
5960
|
!(e instanceof En) && !(e instanceof Dn) && this._debug.warn("Unable to send sharing stats", e);
|
|
5849
5961
|
})), this._lastSharingStat = e;
|
|
5850
5962
|
}
|
|
5851
5963
|
}
|
|
5852
|
-
},
|
|
5964
|
+
}, Ta = class {
|
|
5853
5965
|
constructor(e, t, n, r = z, i = null) {
|
|
5854
5966
|
h(this, "_pc", null), h(this, "_transceiver", null), h(this, "_currentSimulcastInfo", null), h(this, "_signaling", void 0), h(this, "_mediaSource", void 0), h(this, "_getCameraSettings", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), this._signaling = e, this._mediaSource = t, this._getCameraSettings = n, this._debug = r, this._logger = i;
|
|
5855
5967
|
}
|
|
@@ -5981,9 +6093,9 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
5981
6093
|
if (!(e instanceof Dn)) throw e;
|
|
5982
6094
|
}
|
|
5983
6095
|
}
|
|
5984
|
-
},
|
|
6096
|
+
}, Ea = 90, Da = 4294967295, Oa = class e extends Qr {
|
|
5985
6097
|
constructor(e, t, n, r = z, i = null, a = null, o = null, s = null) {
|
|
5986
|
-
super(e, t, s), h(this, "_producerNotification", null), h(this, "_producerCommand", null), h(this, "_producerScreen", null), h(this, "_consumerScreen", null), h(this, "_asr", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_isOpen", !1), h(this, "_observer", !1), h(this, "_reconnectionPrevented", !1), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_monitorRtpShareInterval", null), h(this, "_statBytes", {}), h(this, "_ssrcMap", {}), h(this, "_ssrcMapUpdated", !1), h(this, "_perfStatReporter", void 0), h(this, "_producerOfferIsProcessing", !1), h(this, "_producerNextOffer", null), h(this, "_producerNextSessionId", null), h(this, "_lastStat", null), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_prevConsumerFastSharingSettings", {}), h(this, "_asrTrack", null), h(this, "_captureSender", null), h(this, "_captureReceiver", null), h(this, "_participantIdRegistry", null), h(this, "_disabledSenders", /* @__PURE__ */ new Set()), h(this, "_rtpReceiversByStreamId", {}), h(this, "_producerSessionId", ""), h(this, "_newAudioShareTrack", null), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_sdpStats", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_simulcast", void 0), this._debug = r, this._logger = i, this._statAggregator = a, this._sdpStats = new Lr(a), this._codecStatsAggregator = o, this._serverSettings = n, this._simulcast = new
|
|
6098
|
+
super(e, t, s), h(this, "_producerNotification", null), h(this, "_producerCommand", null), h(this, "_producerScreen", null), h(this, "_consumerScreen", null), h(this, "_asr", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_isOpen", !1), h(this, "_observer", !1), h(this, "_reconnectionPrevented", !1), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_monitorRtpShareInterval", null), h(this, "_statBytes", {}), h(this, "_ssrcMap", {}), h(this, "_ssrcMapUpdated", !1), h(this, "_perfStatReporter", void 0), h(this, "_producerOfferIsProcessing", !1), h(this, "_producerNextOffer", null), h(this, "_producerNextSessionId", null), h(this, "_lastStat", null), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_prevConsumerFastSharingSettings", {}), h(this, "_asrTrack", null), h(this, "_captureSender", null), h(this, "_captureReceiver", null), h(this, "_participantIdRegistry", null), h(this, "_disabledSenders", /* @__PURE__ */ new Set()), h(this, "_rtpReceiversByStreamId", {}), h(this, "_producerSessionId", ""), h(this, "_newAudioShareTrack", null), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_sdpStats", void 0), h(this, "_peerConnectionStats", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_simulcast", void 0), this._debug = r, this._logger = i, this._statAggregator = a, this._sdpStats = new Lr(a), this._peerConnectionStats = new Gr(a), this._codecStatsAggregator = o, this._serverSettings = n, this._simulcast = new Ta(e, t, () => this._serverSettings.camera, r, i), this.subscribe(this._signaling, xr.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, qt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, qt.SOURCE_CHANGED, this._onSourcesChanged.bind(this)), this.subscribe(this._mediaSource, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._createPerfStatsReporter(), this._debug.debug("ServerTransport: Created");
|
|
5987
6099
|
}
|
|
5988
6100
|
updateStatisticsInterval() {
|
|
5989
6101
|
this._stopStatInterval();
|
|
@@ -6022,10 +6134,10 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6022
6134
|
await this._simulcast.sync();
|
|
6023
6135
|
}
|
|
6024
6136
|
_createPerfStatsReporter() {
|
|
6025
|
-
this._perfStatReporter?.destroy(), this._perfStatReporter = new
|
|
6137
|
+
this._perfStatReporter?.destroy(), this._perfStatReporter = new Na(this, this._signaling, this._statAggregator, !1, this._debug);
|
|
6026
6138
|
}
|
|
6027
6139
|
_closeConnection() {
|
|
6028
|
-
this._signaling.resetProducerConnection(), this._ssrcMap = {}, this._ssrcMapUpdated = !0, this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcast.reset(), this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._sdpStats.stop(), this._participantIdRegistry = null, e._closeDataChannel(this._producerNotification), e._closeDataChannel(this._producerCommand), e._closeDataChannel(this._producerScreen), e._closeDataChannel(this._consumerScreen), e._closeDataChannel(this._asr), e._closeDataChannel(this._animojiDataChannel), this._pc.close(), this._pc = null, this._producerOfferIsProcessing = !1, this._producerNextOffer = null), this._triggerEvent(Y.PEER_CONNECTION_CLOSED);
|
|
6140
|
+
this._signaling.resetProducerConnection(), this._ssrcMap = {}, this._ssrcMapUpdated = !0, this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcast.reset(), this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._sdpStats.stop(), this._peerConnectionStats.stop(), this._participantIdRegistry = null, e._closeDataChannel(this._producerNotification), e._closeDataChannel(this._producerCommand), e._closeDataChannel(this._producerScreen), e._closeDataChannel(this._consumerScreen), e._closeDataChannel(this._asr), e._closeDataChannel(this._animojiDataChannel), this._pc.close(), this._pc = null, this._producerOfferIsProcessing = !1, this._producerNextOffer = null), this._triggerEvent(Y.PEER_CONNECTION_CLOSED);
|
|
6029
6141
|
}
|
|
6030
6142
|
static _closeDataChannel(e) {
|
|
6031
6143
|
e && (e.onopen = null, e.onmessage = null, e.onerror = null, e.close());
|
|
@@ -6051,14 +6163,14 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6051
6163
|
}
|
|
6052
6164
|
this._pc.ontrack = this._onAddTrack.bind(this, this._pc), this._pc.onconnectionstatechange = M.debounce((e) => {
|
|
6053
6165
|
this._pc && this._onConnectionStateChange(this._pc, e);
|
|
6054
|
-
}, 500), this._pc.onsignalingstatechange = this._onSignalingStateChange.bind(this, this._pc), this._sdpStats.observe(this._pc), this._participantIdRegistry = new
|
|
6166
|
+
}, 500), this._pc.onsignalingstatechange = this._onSignalingStateChange.bind(this, this._pc), this._sdpStats.observe(this._pc), this._peerConnectionStats.observe(this._pc), this._participantIdRegistry = new _i(this._debug), this._signaling.setParticipantIdRegistry(this._participantIdRegistry), this._createDataChannel(this._pc, Tr.producerNotification, (e) => {
|
|
6055
6167
|
this._producerNotification = e, this._producerNotification.binaryType = "arraybuffer", this._signaling.setProducerNotificationDataChannel(e);
|
|
6056
6168
|
}), this._signaling.useCommandDataChannel(!0), this._createDataChannel(this._pc, Tr.producerCommand, (e) => {
|
|
6057
6169
|
this._producerCommand = e, this._signaling.setProducerCommandDataChannel(e);
|
|
6058
6170
|
}), this._createDataChannel(this._pc, Tr.producerScreenShare, (e) => {
|
|
6059
6171
|
this._producerScreen = e, this._producerScreen.binaryType = "arraybuffer", this._createCaptureReceiver();
|
|
6060
6172
|
}), N.asrDataChannel && this._createDataChannel(this._pc, Tr.asr, (e) => {
|
|
6061
|
-
this._asr = e, this._asr.binaryType = "arraybuffer", this._removeAsrTrack(), this._asrTrack = new
|
|
6173
|
+
this._asr = e, this._asr.binaryType = "arraybuffer", this._removeAsrTrack(), this._asrTrack = new mi(e, this._participantIdRegistry, (e) => {
|
|
6062
6174
|
this._onAsrTranscription(e);
|
|
6063
6175
|
}, this._debug);
|
|
6064
6176
|
}), N.vmoji && this._createDataChannel(this._pc, Tr.animoji, (e) => {
|
|
@@ -6079,8 +6191,8 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6079
6191
|
_removeAsrTrack() {
|
|
6080
6192
|
this._asrTrack?.destroy(), this._asrTrack = null;
|
|
6081
6193
|
}
|
|
6082
|
-
_reconnect() {
|
|
6083
|
-
this.getState() !== q.OPENED && (this._setState(q.RECONNECTING), this._closeConnection(), this._openConnection(!0));
|
|
6194
|
+
_reconnect(e = !1) {
|
|
6195
|
+
this.getState() !== q.OPENED && (e && this._peerConnectionStats.logIceRestart(), this._setState(q.RECONNECTING), this._closeConnection(), this._openConnection(!0));
|
|
6084
6196
|
}
|
|
6085
6197
|
_signalActiveParticipants(e) {
|
|
6086
6198
|
this._triggerEvent(Y.SIGNALLED_ACTIVE_PARTICIPANTS, e);
|
|
@@ -6096,19 +6208,19 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6096
6208
|
}
|
|
6097
6209
|
_updateSSRCMap(e) {
|
|
6098
6210
|
e && (this._ssrcMap = {}, this._ssrcMapUpdated = !0, dn(e.sdp).forEach((e) => {
|
|
6099
|
-
let t = `a=ssrc:([0-9]+) label:(audio|video)-((?:[ug]?[\\d]+)|(?:mix)|(?:${
|
|
6211
|
+
let t = `a=ssrc:([0-9]+) label:(audio|video)-((?:[ug]?[\\d]+)|(?:mix)|(?:${fi.PARTICIPANT_AGNOSTIC_TRACK_PREFIX}-[0-9]+)|(?:${fi.TRANSPARENT_AUDIO_TRACK_PREFIX}-[0-9]+))`, n = new RegExp(t).exec(e);
|
|
6100
6212
|
n && (this._ssrcMap[n[1]] = n[3]);
|
|
6101
6213
|
}));
|
|
6102
6214
|
}
|
|
6103
6215
|
_createCaptureSender(e) {
|
|
6104
6216
|
let t = this._mediaSource.mediaSettings;
|
|
6105
|
-
!e || !this._consumerScreen || !t.isScreenSharingEnabled || (this._captureSender && this._removeCaptureSender(), this._captureSender = new
|
|
6217
|
+
!e || !this._consumerScreen || !t.isScreenSharingEnabled || (this._captureSender && this._removeCaptureSender(), this._captureSender = new wa(e, this._consumerScreen, this._signaling, t.isFastScreenSharingEnabled, this._debug, this._logger));
|
|
6106
6218
|
}
|
|
6107
6219
|
_removeCaptureSender() {
|
|
6108
6220
|
this._captureSender?.destroy(), this._captureSender = null;
|
|
6109
6221
|
}
|
|
6110
6222
|
_createCaptureReceiver() {
|
|
6111
|
-
this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new
|
|
6223
|
+
this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new Xi(this._producerScreen, this._participantIdRegistry, (e, t) => {
|
|
6112
6224
|
this._triggerEvent(Y.REMOTE_STREAM_SECOND, e, t);
|
|
6113
6225
|
}, (e) => {
|
|
6114
6226
|
this._triggerEvent(Y.REMOTE_STREAM_SECOND, e, null);
|
|
@@ -6218,7 +6330,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6218
6330
|
_detectStaleTracks(e) {
|
|
6219
6331
|
let t = e.rtps.find((e) => e.type === "inbound-rtp" && e.kind === "audio" && this._ssrcMap[e.ssrc] === "mix");
|
|
6220
6332
|
if (!t) return;
|
|
6221
|
-
let n =
|
|
6333
|
+
let n = fi.AUDIO_MIX, r = this._statBytes[n], i = !1;
|
|
6222
6334
|
if (r) {
|
|
6223
6335
|
let e = t.bytesReceived - r.bytesReceived;
|
|
6224
6336
|
e >= 0 && e <= 5 && (i = !0), r.stalled !== i && this._triggerEvent(Y.AUDIO_MIX_STALL, i);
|
|
@@ -6230,7 +6342,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6230
6342
|
}
|
|
6231
6343
|
_allocateConsumer() {
|
|
6232
6344
|
if (!this._signaling.ready) return;
|
|
6233
|
-
let e =
|
|
6345
|
+
let e = za.get();
|
|
6234
6346
|
!N.videoTracksCount && !this._observer && this._debug.warn("Setting videoTracksCount to 0 is deprecated"), this._signaling.allocateConsumer(null, e).catch((e) => {
|
|
6235
6347
|
e instanceof En || this._debug.warn("ServerTransport: Unable to allocate consumer", e);
|
|
6236
6348
|
});
|
|
@@ -6363,7 +6475,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6363
6475
|
_onConnectionStateChange(e, t) {
|
|
6364
6476
|
switch (this._debug.debug("[single] connection state changed", { state: e.connectionState }, t), this._logger?.log(C.ICE_CONNECTION_STATE, e.connectionState), e.connectionState) {
|
|
6365
6477
|
case "failed":
|
|
6366
|
-
this._reconnectionPrevented ? this.close(/* @__PURE__ */ Error("Ice connection failed")) : this._reconnect();
|
|
6478
|
+
this._reconnectionPrevented ? this.close(/* @__PURE__ */ Error("Ice connection failed")) : this._reconnect(!0);
|
|
6367
6479
|
break;
|
|
6368
6480
|
case "connecting":
|
|
6369
6481
|
let t = this.getState();
|
|
@@ -6406,11 +6518,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6406
6518
|
if (!r || !r.length) return this._debug.log(`Cannot get stream waiting time, ${e} receiver has no synchronization sources`), 0;
|
|
6407
6519
|
let i = r[0].rtpTimestamp;
|
|
6408
6520
|
if (!Number.isInteger(i)) return this._logger?.log(C.PAT_WAITING_TIME_ERROR, "timestampNotInteger"), this._debug.error(`Cannot get stream waiting time, ${e} receiver's RTP timestamp is not an integer: ${i}`), 0;
|
|
6409
|
-
let a = t - i &
|
|
6521
|
+
let a = t - i & Da, o = Math.ceil(a / Ea);
|
|
6410
6522
|
return Math.min(100, Math.max(0, o));
|
|
6411
6523
|
}
|
|
6412
6524
|
async _monitorRtpShare() {
|
|
6413
|
-
let e =
|
|
6525
|
+
let e = gi.getInstance().value;
|
|
6414
6526
|
if (!this._mediaSource.mediaSettings.isFastScreenSharingEnabled || !N.consumerFastScreenShare || e < .6) return;
|
|
6415
6527
|
let t = this._pc?.getSenders().find((e) => e.track?.kind === A.video && e.track?.contentHint === "motion");
|
|
6416
6528
|
t && (await t.getStats()).forEach((e) => {
|
|
@@ -6441,7 +6553,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6441
6553
|
}
|
|
6442
6554
|
}, Y = /* @__PURE__ */ function(e) {
|
|
6443
6555
|
return e.REMOTE_TRACK_ADDED = "REMOTE_TRACK_ADDED", e.REMOTE_TRACK_REMOVED = "REMOTE_TRACK_REMOVED", e.REMOTE_STREAM_SECOND = "REMOTE_STREAM_SECOND", e.AUDIO_MIX_STALL = "AUDIO_MIX_STALL", e.REMOTE_DATA_STATS = "REMOTE_DATA_STATS", e.STATE_CHANGED = "STATE_CHANGED", e.LOCAL_STATE_CHANGED = "LOCAL_STATE_CHANGED", e.SIGNALLED_ACTIVE_PARTICIPANTS = "SIGNALLED_ACTIVE_PARTICIPANTS", e.SIGNALLED_SPEAKER_CHANGED = "SIGNALLED_SPEAKER_CHANGED", e.SIGNALLED_STALLED_PARTICIPANTS = "SIGNALLED_STALLED_PARTICIPANTS", e.TOPOLOGY_CHANGED = "TOPOLOGY_CHANGED", e.NETWORK_STATUS = "NETWORK_STATUS", e.PEER_CONNECTION_CLOSED = "PEER_CONNECTION_CLOSED", e.ASR_TRANSCRIPTION = "ASR_TRANSCRIPTION", e.ANIMOJI_STREAM = "ANIMOJI_STREAM", e.ANIMOJI_ERROR = "ANIMOJI_ERROR", e.SCREEN_SHARING_STAT = "SCREEN_SHARING_STAT", e;
|
|
6444
|
-
}({}),
|
|
6556
|
+
}({}), ka = class extends b {
|
|
6445
6557
|
constructor(e, t, n, r, i = z, a = null, o = null, s = null, c = null) {
|
|
6446
6558
|
super(), h(this, "_signaling", void 0), h(this, "_mediaSource", void 0), h(this, "_topology", void 0), h(this, "_allocated", []), h(this, "_opened", []), h(this, "_directTransport", null), h(this, "_serverTransport", null), h(this, "_serverSettings", void 0), h(this, "_dtListeners", []), h(this, "_stListeners", []), h(this, "_states", {}), h(this, "_localState", q.IDLE), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_onFirstMediaSent", void 0), h(this, "_firstMediaSentProbeStopped", !1), h(this, "_vadController", null), h(this, "_updateVadTrack", () => {
|
|
6447
6559
|
this._vadController?.setSendTrack(this._mediaSource.getSendAudioTrack());
|
|
@@ -6562,11 +6674,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6562
6674
|
}
|
|
6563
6675
|
}
|
|
6564
6676
|
_createDirectTransport(e, t = !1) {
|
|
6565
|
-
let n = new
|
|
6677
|
+
let n = new di(e, t, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
|
|
6566
6678
|
return this._dtListeners.length > 0 && this._debug.warn(`The list of direct listeners for the participant [${e}] is not empty`), this._dtListeners = [], this._dtListeners.push(n.addEventListener("REMOTE_TRACK_ADDED", this._onRemoteTrackAdded.bind(this, e)), n.addEventListener("REMOTE_TRACK_REMOVED", this._onRemoteTrackRemoved.bind(this, e)), n.addEventListener("REMOTE_DATA_STATS", this._onRemoteDataStats.bind(this)), n.addEventListener("STATE_CHANGED", this._onDirectTransportChanged.bind(this)), n.addEventListener("NETWORK_STATUS", this._onTransportNetworkStatus.bind(this)), n.addEventListener("PEER_CONNECTION_CLOSED", this._onPeerConnectionClosed.bind(this, J.DIRECT))), this._animojiReceiver && this._animojiSender && n.setAnimojiTransport(this._animojiReceiver, this._animojiSender), n;
|
|
6567
6679
|
}
|
|
6568
6680
|
_createServerTransport() {
|
|
6569
|
-
let e = new
|
|
6681
|
+
let e = new Oa(this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
|
|
6570
6682
|
return this._stListeners.length > 0 && this._debug.warn("The list of server transport listeners is not empty"), this._stListeners = [], this._stListeners.push(e.addEventListener("REMOTE_TRACK_ADDED", this._onRemoteTrackAdded.bind(this)), e.addEventListener("REMOTE_TRACK_REMOVED", this._onRemoteTrackRemoved.bind(this)), e.addEventListener("AUDIO_MIX_STALL", this._onServerAudioMixStall.bind(this)), e.addEventListener("REMOTE_DATA_STATS", this._onRemoteDataStats.bind(this)), e.addEventListener("STATE_CHANGED", this._onServerTransportChanged.bind(this)), e.addEventListener("SIGNALLED_ACTIVE_PARTICIPANTS", this._onTransportActiveParticipants.bind(this)), e.addEventListener("SIGNALLED_SPEAKER_CHANGED", this._onTransportSpeakerChanged.bind(this)), e.addEventListener("SIGNALLED_STALLED_PARTICIPANTS", this._onTransportStalledParticipants.bind(this)), e.addEventListener("NETWORK_STATUS", this._onTransportNetworkStatus.bind(this)), e.addEventListener("REMOTE_STREAM_SECOND", this._onRemoteStreamSecond.bind(this)), e.addEventListener("PEER_CONNECTION_CLOSED", this._onPeerConnectionClosed.bind(this, J.SERVER)), e.addEventListener("ASR_TRANSCRIPTION", this._onAsrTranscription.bind(this))), this._animojiReceiver && this._animojiSender && e.setAnimojiTransport(this._animojiReceiver, this._animojiSender), e;
|
|
6571
6683
|
}
|
|
6572
6684
|
_releaseDirectTransport() {
|
|
@@ -6658,20 +6770,20 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6658
6770
|
getStreamWaitingTimeMs(e, t) {
|
|
6659
6771
|
return this._topology === J.SERVER ? this._serverTransport ? this._serverTransport.getStreamWaitingTimeMs(e, t) : (this._logger?.log(C.PAT_WAITING_TIME_ERROR, "noTransport"), this._debug.error("Cannot get stream waiting time, server transport is not initialized"), 0) : (this._logger?.log(C.PAT_WAITING_TIME_ERROR, "wrongTopology"), this._debug.error(`Cannot get stream waiting time, incorrect topology: ${this._topology}`), 0);
|
|
6660
6772
|
}
|
|
6661
|
-
},
|
|
6773
|
+
}, Aa = "videochat-epi", ja = 5e3, Ma = 500, Na = class extends b {
|
|
6662
6774
|
constructor(e, t, n = null, r = !1, i = z) {
|
|
6663
|
-
super(), h(this, "_previousPerfStatReportTimestamp", 0), h(this, "_previousNetworkStatReportTimestamp", Date.now()), h(this, "_previousCallStatReportTimestamp", Date.now()), h(this, "_previousCallStatReport", null), h(this, "_previousRemoteInboundRtps", /* @__PURE__ */ new Map()), h(this, "_screenShareStats", []), h(this, "_signaling", void 0), h(this, "_directTopology", void 0), h(this, "_debug", void 0), h(this, "_statAggregator", void 0), h(this, "_handleScreenSharingStat", (e) => {
|
|
6775
|
+
super(), h(this, "_previousPerfStatReportTimestamp", 0), h(this, "_previousNetworkStatReportTimestamp", Date.now()), h(this, "_previousCallStatReportTimestamp", Date.now()), h(this, "_previousCallStatReport", null), h(this, "_previousRemoteInboundRtps", /* @__PURE__ */ new Map()), h(this, "_previousCandidatePair", null), h(this, "_screenShareStats", []), h(this, "_signaling", void 0), h(this, "_directTopology", void 0), h(this, "_debug", void 0), h(this, "_statAggregator", void 0), h(this, "_handleScreenSharingStat", (e) => {
|
|
6664
6776
|
this._screenShareStats.push(e);
|
|
6665
6777
|
}), h(this, "_handleTransportStateChanged", (e) => {
|
|
6666
6778
|
(this._directTopology && e === q.CONNECTED || !this._directTopology && e === q.OPENED) && (this._previousNetworkStatReportTimestamp = Date.now(), this._previousCallStatReportTimestamp = Date.now(), this._previousRemoteInboundRtps.clear());
|
|
6667
6779
|
}), this._signaling = t, this._directTopology = r, this._debug = i, this._statAggregator = n, this.subscribe(e, Y.REMOTE_DATA_STATS, this._handleStats.bind(this)), this.subscribe(e, Y.SCREEN_SHARING_STAT, this._handleScreenSharingStat.bind(this)), this.subscribe(e, Y.STATE_CHANGED, this._handleTransportStateChanged.bind(this));
|
|
6668
6780
|
}
|
|
6669
6781
|
destroy() {
|
|
6670
|
-
this._previousRemoteInboundRtps.clear(), this.unsubscribe();
|
|
6782
|
+
this._previousRemoteInboundRtps.clear(), this._previousCandidatePair = null, this.unsubscribe();
|
|
6671
6783
|
}
|
|
6672
6784
|
static getEstimatedPerformanceIndex() {
|
|
6673
6785
|
try {
|
|
6674
|
-
let e = parseInt(localStorage.getItem(
|
|
6786
|
+
let e = parseInt(localStorage.getItem(Aa) || "", 10);
|
|
6675
6787
|
return isNaN(e) ? 0 : e;
|
|
6676
6788
|
} catch {
|
|
6677
6789
|
return 0;
|
|
@@ -6680,9 +6792,9 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6680
6792
|
async _handleStats(e) {
|
|
6681
6793
|
if (!e.inbound || !e.inbound.rtps) return;
|
|
6682
6794
|
let t = Date.now();
|
|
6683
|
-
!this._directTopology && N.perfStatReportEnabled && this._previousPerfStatReportTimestamp +
|
|
6795
|
+
!this._directTopology && N.perfStatReportEnabled && this._previousPerfStatReportTimestamp + ja <= t && (await this.reportPerfStats(e), this._previousPerfStatReportTimestamp = t);
|
|
6684
6796
|
let n = e.outbound.transport.local?.protocol === "tcp";
|
|
6685
|
-
!this._directTopology && n && this._previousNetworkStatReportTimestamp +
|
|
6797
|
+
!this._directTopology && n && this._previousNetworkStatReportTimestamp + Ma <= t && (await this.reportNetworkStats(e), this._previousNetworkStatReportTimestamp = t), this._reportCandidatePair(e.inbound.transport.local, e.inbound.transport.remote), N.callStatReportEnabled && this._previousCallStatReportTimestamp + N.statisticsInterval <= t && (this._reportCallStats(e), this._previousCallStatReportTimestamp = t);
|
|
6686
6798
|
}
|
|
6687
6799
|
async reportPerfStats(e) {
|
|
6688
6800
|
let t = e.inbound.rtps.reduce((e, t) => (t.kind === "video" && (e.framesDecoded += t.framesDecoded || 0, e.framesReceived += t.framesReceived || 0), e), {
|
|
@@ -6691,7 +6803,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6691
6803
|
});
|
|
6692
6804
|
if (t.framesDecoded) try {
|
|
6693
6805
|
let e = await this._signaling.reportPerfStat(t);
|
|
6694
|
-
localStorage.setItem(
|
|
6806
|
+
localStorage.setItem(Aa, e.estimatedPerformanceIndex);
|
|
6695
6807
|
} catch {}
|
|
6696
6808
|
}
|
|
6697
6809
|
async reportNetworkStats(e) {
|
|
@@ -6731,11 +6843,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6731
6843
|
rtt: Math.round(e.inbound.transport.currentRoundTripTime * 1e3),
|
|
6732
6844
|
ss_freeze_count: 0,
|
|
6733
6845
|
ss_total_freezes_duration: 0,
|
|
6734
|
-
local_address:
|
|
6846
|
+
local_address: Fa(e.inbound.transport.local),
|
|
6735
6847
|
local_connection_type: e.inbound.transport.local?.type,
|
|
6736
6848
|
network_type: e.inbound.transport.local?.networkType,
|
|
6737
6849
|
transport: e.inbound.transport.local?.protocol,
|
|
6738
|
-
remote_address:
|
|
6850
|
+
remote_address: Fa(e.inbound.transport.remote),
|
|
6739
6851
|
remote_connection_type: e.inbound.transport.remote?.type
|
|
6740
6852
|
};
|
|
6741
6853
|
this._previousCallStatReport || (this._previousCallStatReport = Object.assign({}, t));
|
|
@@ -6756,14 +6868,28 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6756
6868
|
frames_dropped: Math.max(0, t.frames_dropped - this._previousCallStatReport.frames_dropped),
|
|
6757
6869
|
rtt: Math.max(0, t.rtt)
|
|
6758
6870
|
};
|
|
6759
|
-
if (N.simulcast && (i.is_simulcast = !0), navigator.hardwareConcurrency && (i.cpu_hardware_concurrency = navigator.hardwareConcurrency), n && !
|
|
6871
|
+
if (N.simulcast && (i.is_simulcast = !0), navigator.hardwareConcurrency && (i.cpu_hardware_concurrency = navigator.hardwareConcurrency), n && !Ia(t.jitter_video) && (i.jitter_video = Math.round(t.jitter_video)), r && !Ia(t.jitter_audio) && (i.jitter_audio = Math.round(t.jitter_audio)), n && !Ia(t.interframe_delay_variance) && (i.interframe_delay_variance = t.interframe_delay_variance), t.freeze_count && t.total_freezes_duration && (i.freeze_count = t.freeze_count, i.total_freezes_duration = Math.round(t.total_freezes_duration * 1e3)), t.ss_freeze_count && t.ss_total_freezes_duration && (i.ss_freeze_count = t.ss_freeze_count, i.ss_total_freezes_duration = t.ss_total_freezes_duration), r && !Ia(t.total_audio_samples_received)) {
|
|
6760
6872
|
let e = Math.max(0, t.total_audio_samples_received - this._previousCallStatReport.total_audio_samples_received), n = Math.max(0, t.inserted_audio_samples_for_deceleration - this._previousCallStatReport.inserted_audio_samples_for_deceleration), r = Math.max(0, t.removed_audio_samples_for_acceleration - this._previousCallStatReport.removed_audio_samples_for_acceleration), a = Math.max(0, t.concealed_audio_samples - this._previousCallStatReport.concealed_audio_samples), o = Math.max(0, t.silent_concealed_audio_samples - this._previousCallStatReport.silent_concealed_audio_samples), s = Math.max(0, t.audio_concealment_events - this._previousCallStatReport.audio_concealment_events);
|
|
6761
|
-
i.inserted_audio_samples_for_deceleration =
|
|
6873
|
+
i.inserted_audio_samples_for_deceleration = La(n / e * 1e3), i.removed_audio_samples_for_acceleration = La(r / e * 1e3), i.concealed_audio_samples = La(a / e * 1e3), i.concealed_silent_audio_samples = La(o / e * 1e3), i.concealment_audio_avg_size = La(a / s), i.total_audio_energy = t.total_audio_energy;
|
|
6762
6874
|
}
|
|
6763
|
-
|
|
6875
|
+
Pa(t, "local_address", "local_connection_type", "network_type", "transport") && (i.local_address = t.local_address, i.local_connection_type = t.local_connection_type, i.network_type = t.network_type, i.transport = t.transport), Pa(t, "remote_address", "remote_connection_type") && (i.remote_address = t.remote_address, i.remote_connection_type = t.remote_connection_type);
|
|
6764
6876
|
let a = this._calculatePacketLoss(e.remoteInbound.rtps);
|
|
6765
6877
|
a.video !== void 0 && (i.video_loss = a.video), a.audio !== void 0 && (i.audio_loss = a.audio), this._statAggregator?.logCallStat(i), N.enableLogPerfStatReport && this._debug.log("Sent call stats", i), this._previousCallStatReport = t;
|
|
6766
6878
|
}
|
|
6879
|
+
_reportCandidatePair(e, t) {
|
|
6880
|
+
if (!e?.address || !t?.address) return;
|
|
6881
|
+
let n = JSON.stringify({
|
|
6882
|
+
local: e,
|
|
6883
|
+
remote: t
|
|
6884
|
+
});
|
|
6885
|
+
n !== this._previousCandidatePair && (this._previousCandidatePair = n, this._statAggregator?.logEventualStat({
|
|
6886
|
+
name: U.ICE_CANDIDATES_CHANGED,
|
|
6887
|
+
string_value: n,
|
|
6888
|
+
local_address: Fa(e),
|
|
6889
|
+
remote_address: Fa(t),
|
|
6890
|
+
transport: e.protocol
|
|
6891
|
+
}));
|
|
6892
|
+
}
|
|
6767
6893
|
_calculatePacketLoss(e) {
|
|
6768
6894
|
let t = /* @__PURE__ */ new Map(), n = {
|
|
6769
6895
|
audio: {
|
|
@@ -6792,26 +6918,26 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
|
|
|
6792
6918
|
return r;
|
|
6793
6919
|
}
|
|
6794
6920
|
};
|
|
6795
|
-
function
|
|
6921
|
+
function Pa(e, ...t) {
|
|
6796
6922
|
for (let n of t) if (!Object.hasOwn(e, n) || e[n] === void 0) return !1;
|
|
6797
6923
|
return !0;
|
|
6798
6924
|
}
|
|
6799
|
-
function
|
|
6925
|
+
function Fa(e, t = !1) {
|
|
6800
6926
|
if (e?.address) return e.address + (t ? `:${e.port}` : "");
|
|
6801
6927
|
}
|
|
6802
|
-
function
|
|
6928
|
+
function Ia(e) {
|
|
6803
6929
|
return e === void 0;
|
|
6804
6930
|
}
|
|
6805
|
-
function
|
|
6931
|
+
function La(e) {
|
|
6806
6932
|
return Number.isNaN(e) ? 0 : e;
|
|
6807
6933
|
}
|
|
6808
6934
|
//#endregion
|
|
6809
6935
|
//#region src/static/Capabilities.ts
|
|
6810
|
-
var
|
|
6936
|
+
var Ra;
|
|
6811
6937
|
(function(e) {
|
|
6812
6938
|
function t() {
|
|
6813
6939
|
return {
|
|
6814
|
-
estimatedPerformanceIndex:
|
|
6940
|
+
estimatedPerformanceIndex: Na.getEstimatedPerformanceIndex(),
|
|
6815
6941
|
audioMix: !0,
|
|
6816
6942
|
consumerUpdate: !0,
|
|
6817
6943
|
producerNotificationDataChannelVersion: 8,
|
|
@@ -6837,8 +6963,8 @@ var Ma;
|
|
|
6837
6963
|
};
|
|
6838
6964
|
}
|
|
6839
6965
|
e.get = t;
|
|
6840
|
-
})(
|
|
6841
|
-
var
|
|
6966
|
+
})(Ra || (Ra = {}));
|
|
6967
|
+
var za = Ra, Ba = {
|
|
6842
6968
|
producerScreenTrack: () => !0,
|
|
6843
6969
|
videoTracksCount: () => N.videoTracksCount > 0,
|
|
6844
6970
|
waitingHall: () => !0,
|
|
@@ -6858,28 +6984,28 @@ var Na = Ma, Pa = {
|
|
|
6858
6984
|
p2pRelay: () => !1,
|
|
6859
6985
|
waitForAdmin: () => N.waitForAdminInGroupCalls,
|
|
6860
6986
|
hold: () => N.hold
|
|
6861
|
-
},
|
|
6987
|
+
}, Va = class {
|
|
6862
6988
|
static getFlags() {
|
|
6863
|
-
let e = Object.values(
|
|
6989
|
+
let e = Object.values(Ba), t = 0;
|
|
6864
6990
|
for (let n = 0; n < e.length; n++) e[n]() && (t |= 1 << n);
|
|
6865
6991
|
return t.toString(16).toUpperCase();
|
|
6866
6992
|
}
|
|
6867
6993
|
static parseCapabilities(e) {
|
|
6868
6994
|
let t = parseInt(e || "0", 16);
|
|
6869
|
-
return Object.keys(
|
|
6995
|
+
return Object.keys(Ba).reduce((e, n, r) => (e[n] = !!(t & 1 << r), e), {});
|
|
6870
6996
|
}
|
|
6871
|
-
},
|
|
6997
|
+
}, Ha = 63n, Ua = 16383n, Wa = 1073741823, Ga = 4611686018427387903n, Ka = class {
|
|
6872
6998
|
encode(e) {
|
|
6873
6999
|
let t = typeof e == "number" ? BigInt(e) : e;
|
|
6874
|
-
if (t <=
|
|
6875
|
-
if (t <=
|
|
6876
|
-
if (t <= BigInt(
|
|
7000
|
+
if (t <= Ha) return new Uint8Array([Number(t)]);
|
|
7001
|
+
if (t <= Ua) return new Uint8Array([64 | Number(t >> 8n), Number(t & 255n)]);
|
|
7002
|
+
if (t <= BigInt(Wa)) return new Uint8Array([
|
|
6877
7003
|
128 | Number(t >> 24n),
|
|
6878
7004
|
Number(t >> 16n & 255n),
|
|
6879
7005
|
Number(t >> 8n & 255n),
|
|
6880
7006
|
Number(t & 255n)
|
|
6881
7007
|
]);
|
|
6882
|
-
if (t <=
|
|
7008
|
+
if (t <= Ga) return new Uint8Array([
|
|
6883
7009
|
192 | Number(t >> 56n),
|
|
6884
7010
|
Number(t >> 48n & 255n),
|
|
6885
7011
|
Number(t >> 40n & 255n),
|
|
@@ -6891,7 +7017,7 @@ var Na = Ma, Pa = {
|
|
|
6891
7017
|
]);
|
|
6892
7018
|
throw RangeError("Number is too large to encode using varint");
|
|
6893
7019
|
}
|
|
6894
|
-
},
|
|
7020
|
+
}, qa = class {
|
|
6895
7021
|
decode(e) {
|
|
6896
7022
|
let t = this.getNumBytesForLengthInteger(e);
|
|
6897
7023
|
if (t < 0) throw Error("Invalid length prefix");
|
|
@@ -6917,9 +7043,9 @@ var Na = Ma, Pa = {
|
|
|
6917
7043
|
let t = e[0] & 192;
|
|
6918
7044
|
return t === 0 ? 1 : t === 64 ? 2 : t === 128 ? 4 : t === 192 ? 8 : -1;
|
|
6919
7045
|
}
|
|
6920
|
-
},
|
|
7046
|
+
}, Ja = class {
|
|
6921
7047
|
constructor(e) {
|
|
6922
|
-
h(this, "encoder", void 0), h(this, "compression", void 0), h(this, "lengthEncoder", void 0), this.encoder = new TextEncoder(), this.lengthEncoder = new
|
|
7048
|
+
h(this, "encoder", void 0), h(this, "compression", void 0), h(this, "lengthEncoder", void 0), this.encoder = new TextEncoder(), this.lengthEncoder = new Ka(), this.compression = e ?? null;
|
|
6923
7049
|
}
|
|
6924
7050
|
encode(e) {
|
|
6925
7051
|
let t = this.encoder.encode(e);
|
|
@@ -6936,9 +7062,9 @@ var Na = Ma, Pa = {
|
|
|
6936
7062
|
default: return e;
|
|
6937
7063
|
}
|
|
6938
7064
|
}
|
|
6939
|
-
},
|
|
7065
|
+
}, Ya = class {
|
|
6940
7066
|
constructor(e) {
|
|
6941
|
-
h(this, "decoder", void 0), h(this, "compression", void 0), h(this, "lengthDecoder", void 0), h(this, "buffer", void 0), h(this, "expectedLength", void 0), h(this, "offset", void 0), h(this, "lengthPrefixLength", void 0), this.decoder = new TextDecoder(), this.lengthDecoder = new
|
|
7067
|
+
h(this, "decoder", void 0), h(this, "compression", void 0), h(this, "lengthDecoder", void 0), h(this, "buffer", void 0), h(this, "expectedLength", void 0), h(this, "offset", void 0), h(this, "lengthPrefixLength", void 0), this.decoder = new TextDecoder(), this.lengthDecoder = new qa(), this.compression = e ?? null, this.buffer = new Uint8Array(), this.expectedLength = null, this.offset = 0;
|
|
6942
7068
|
}
|
|
6943
7069
|
decode(e) {
|
|
6944
7070
|
let t = [];
|
|
@@ -6968,12 +7094,12 @@ var Na = Ma, Pa = {
|
|
|
6968
7094
|
default: return e;
|
|
6969
7095
|
}
|
|
6970
7096
|
}
|
|
6971
|
-
},
|
|
7097
|
+
}, Xa = class {
|
|
6972
7098
|
static isBrowserSupported() {
|
|
6973
7099
|
return !(!("WebTransport" in window && typeof WebTransport == "function") || E.browserName() === "Safari");
|
|
6974
7100
|
}
|
|
6975
7101
|
constructor(e, t = {}, n = z) {
|
|
6976
|
-
h(this, "onopen", null), h(this, "onmessage", null), h(this, "onerror", null), h(this, "onclose", null), h(this, "readyState", WebSocket.CONNECTING), h(this, "webTransport", null), h(this, "writer", null), h(this, "url", void 0), h(this, "options", void 0), h(this, "compression", void 0), h(this, "encoder", void 0), h(this, "decoder", void 0), h(this, "_debug", void 0), this._debug = n, this.url = e, this.options = t, this.compression = this.getCompressionTypeFromUrl(e), this.encoder = new
|
|
7102
|
+
h(this, "onopen", null), h(this, "onmessage", null), h(this, "onerror", null), h(this, "onclose", null), h(this, "readyState", WebSocket.CONNECTING), h(this, "webTransport", null), h(this, "writer", null), h(this, "url", void 0), h(this, "options", void 0), h(this, "compression", void 0), h(this, "encoder", void 0), h(this, "decoder", void 0), h(this, "_debug", void 0), this._debug = n, this.url = e, this.options = t, this.compression = this.getCompressionTypeFromUrl(e), this.encoder = new Ja(this.compression), this.decoder = new Ya(this.compression), this.connect();
|
|
6977
7103
|
}
|
|
6978
7104
|
async send(e) {
|
|
6979
7105
|
if (this.readyState !== WebSocket.OPEN) {
|
|
@@ -7099,11 +7225,11 @@ var Na = Ma, Pa = {
|
|
|
7099
7225
|
compression: this.compression
|
|
7100
7226
|
}, n;
|
|
7101
7227
|
}
|
|
7102
|
-
},
|
|
7103
|
-
return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.ABORTED = "ABORTED", e;
|
|
7104
|
-
}({}),
|
|
7228
|
+
}, Za = /* @__PURE__ */ function(e) {
|
|
7229
|
+
return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.RECONNECT_TIMEOUT = "RECONNECT_TIMEOUT", e.ABORTED = "ABORTED", e;
|
|
7230
|
+
}({}), Qa = class {
|
|
7105
7231
|
constructor(e = z, t) {
|
|
7106
|
-
h(this, "handlers", void 0), h(this, "socket", null), h(this, "endpoint", ""), h(this, "wtEndpoint", null), h(this, "peerId", null), h(this, "lastStamp", 0), h(this, "connectionType", void 0), h(this, "reconnectCount", 0), h(this, "reconnectTimer", 0), h(this, "doctorTimer", 0), h(this, "forceWebSocket", !1), h(this, "abortSignal", void 0), h(this, "manualClose", !1), h(this, "currentType", Sr.WEBSOCKET), h(this, "_debug", void 0), this.handlers = t, this._debug = e;
|
|
7232
|
+
h(this, "handlers", void 0), h(this, "socket", null), h(this, "endpoint", ""), h(this, "wtEndpoint", null), h(this, "peerId", null), h(this, "lastStamp", 0), h(this, "connectionType", void 0), h(this, "reconnectCount", 0), h(this, "reconnectTimer", 0), h(this, "reconnectDeadlineTimer", 0), h(this, "doctorTimer", 0), h(this, "forceWebSocket", !1), h(this, "abortSignal", void 0), h(this, "manualClose", !1), h(this, "currentType", Sr.WEBSOCKET), h(this, "_debug", void 0), this.handlers = t, this._debug = e;
|
|
7107
7233
|
}
|
|
7108
7234
|
get readyState() {
|
|
7109
7235
|
return this.socket?.readyState ?? null;
|
|
@@ -7126,14 +7252,14 @@ var Na = Ma, Pa = {
|
|
|
7126
7252
|
setAbortSignal(e) {
|
|
7127
7253
|
this.abortSignal = e;
|
|
7128
7254
|
}
|
|
7129
|
-
|
|
7130
|
-
this.reconnectCount = 0;
|
|
7255
|
+
onConnectionRestored() {
|
|
7256
|
+
this.reconnectCount = 0, this._stopReconnectDeadline();
|
|
7131
7257
|
}
|
|
7132
7258
|
connect(e) {
|
|
7133
7259
|
this.socket && this.socket.readyState < WebSocket.CLOSING || (e !== br.RETRY && (this.forceWebSocket = !1, this.reconnectCount = 0), this.manualClose = !1, this.connectionType = e, this._connect());
|
|
7134
7260
|
}
|
|
7135
7261
|
close(e) {
|
|
7136
|
-
this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this.lastStamp = 0;
|
|
7262
|
+
this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._stopReconnectDeadline(), this.lastStamp = 0;
|
|
7137
7263
|
}
|
|
7138
7264
|
async send(e) {
|
|
7139
7265
|
await this.socket?.send(e);
|
|
@@ -7151,7 +7277,7 @@ var Na = Ma, Pa = {
|
|
|
7151
7277
|
return;
|
|
7152
7278
|
}
|
|
7153
7279
|
let e = this._buildUrl(this.wtEndpoint, !0);
|
|
7154
|
-
this.currentType = Sr.WEBTRANSPORT, this.socket = new
|
|
7280
|
+
this.currentType = Sr.WEBTRANSPORT, this.socket = new Xa(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
|
|
7155
7281
|
}
|
|
7156
7282
|
_connectWebSocket() {
|
|
7157
7283
|
if (!this.endpoint) {
|
|
@@ -7174,10 +7300,10 @@ var Na = Ma, Pa = {
|
|
|
7174
7300
|
}
|
|
7175
7301
|
_buildUrl(e, t) {
|
|
7176
7302
|
let n = new URL(e), r = n.searchParams;
|
|
7177
|
-
return r.set("platform", N.platform), r.set("appVersion", N.appVersion), r.set("version", String(N.protocolVersion)), r.set("device", N.device), r.set("capabilities",
|
|
7303
|
+
return r.set("platform", N.platform), r.set("appVersion", N.appVersion), r.set("version", String(N.protocolVersion)), r.set("device", N.device), r.set("capabilities", Va.getFlags()), r.set("clientType", N.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === br.RETRY && this.lastStamp && r.set("recoverTs", String(this.lastStamp)), N.useParticipantListChunk && (r.set("partIdx", String(N.participantListChunkInitIndex)), N.participantListChunkInitCount !== null && r.set("partCount", String(N.participantListChunkInitCount))), t && (r.set("compression", "deflate-raw"), r.set("ua", navigator.userAgent)), this.peerId !== null && r.set("peerId", String(this.peerId)), n.toString();
|
|
7178
7304
|
}
|
|
7179
7305
|
_canUseWebTransport() {
|
|
7180
|
-
return !this.forceWebSocket &&
|
|
7306
|
+
return !this.forceWebSocket && Xa.isBrowserSupported() && this.wtEndpoint !== null && N.webtransport;
|
|
7181
7307
|
}
|
|
7182
7308
|
_onOpen() {
|
|
7183
7309
|
this._startDoctor(), this.handlers.onOpen();
|
|
@@ -7206,20 +7332,32 @@ var Na = Ma, Pa = {
|
|
|
7206
7332
|
}
|
|
7207
7333
|
_scheduleReconnect(e = this._getReconnectDelay()) {
|
|
7208
7334
|
if (this.reconnectCount >= N.signalingReconnectMaxCount) {
|
|
7209
|
-
this.handlers.onFailed({
|
|
7335
|
+
this._stopReconnectDeadline(), this.handlers.onFailed({
|
|
7210
7336
|
failure: "NETWORK_ERROR",
|
|
7211
7337
|
message: "Unable to connect to the signaling: reconnect attempts exhausted",
|
|
7212
7338
|
source: this.currentType
|
|
7213
7339
|
});
|
|
7214
7340
|
return;
|
|
7215
7341
|
}
|
|
7216
|
-
this.reconnectCount++, this.handlers.onReconnectScheduled({
|
|
7342
|
+
this._startReconnectDeadline(), this.reconnectCount++, this.handlers.onReconnectScheduled({
|
|
7217
7343
|
count: this.reconnectCount,
|
|
7218
7344
|
delay: e
|
|
7219
7345
|
}), this.reconnectTimer = window.setTimeout(() => {
|
|
7220
7346
|
this.connectionType = br.RETRY, this._connect();
|
|
7221
7347
|
}, e);
|
|
7222
7348
|
}
|
|
7349
|
+
_startReconnectDeadline() {
|
|
7350
|
+
this.reconnectDeadlineTimer || (this.reconnectDeadlineTimer = window.setTimeout(() => {
|
|
7351
|
+
this.reconnectDeadlineTimer = 0, window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._disconnect(4e3), this.handlers.onFailed({
|
|
7352
|
+
failure: "RECONNECT_TIMEOUT",
|
|
7353
|
+
message: "Unable to connect to the signaling: reconnect timeout",
|
|
7354
|
+
source: this.currentType
|
|
7355
|
+
});
|
|
7356
|
+
}, N.signalingReconnectMaxDuration));
|
|
7357
|
+
}
|
|
7358
|
+
_stopReconnectDeadline() {
|
|
7359
|
+
window.clearTimeout(this.reconnectDeadlineTimer), this.reconnectDeadlineTimer = 0;
|
|
7360
|
+
}
|
|
7223
7361
|
_getReconnectDelay() {
|
|
7224
7362
|
return Math.min(N.signalingReconnectMaxDelay, N.signalingReconnectDelay * 2 ** this.reconnectCount);
|
|
7225
7363
|
}
|
|
@@ -7231,31 +7369,31 @@ var Na = Ma, Pa = {
|
|
|
7231
7369
|
_stopDoctor() {
|
|
7232
7370
|
window.clearTimeout(this.doctorTimer), this.doctorTimer = 0;
|
|
7233
7371
|
}
|
|
7234
|
-
},
|
|
7372
|
+
}, $a = "open", eo = 300, to = 10, no = {
|
|
7235
7373
|
CONVERSATION_ENDED: "conversation-ended",
|
|
7236
7374
|
OBSOLETE_CLIENT: "gen.obsoleteClient",
|
|
7237
7375
|
INVALID_TOKEN: "invalid-token",
|
|
7238
7376
|
PARTICIPANT_NOT_FOUND: "participant-not-found",
|
|
7239
7377
|
ILLEGAL_PARTICIPANT_STATE: "illegal-participant-state",
|
|
7240
7378
|
SERVICE_UNAVAILABLE: "service-unavailable"
|
|
7241
|
-
},
|
|
7242
|
-
[
|
|
7243
|
-
[
|
|
7244
|
-
[
|
|
7245
|
-
[
|
|
7246
|
-
[
|
|
7247
|
-
[
|
|
7379
|
+
}, ro = {
|
|
7380
|
+
[no.CONVERSATION_ENDED]: "conversation-ended",
|
|
7381
|
+
[no.OBSOLETE_CLIENT]: "obsolete-client",
|
|
7382
|
+
[no.INVALID_TOKEN]: "invalid-token",
|
|
7383
|
+
[no.PARTICIPANT_NOT_FOUND]: "participant-not-found",
|
|
7384
|
+
[no.ILLEGAL_PARTICIPANT_STATE]: "illegal-participant-state",
|
|
7385
|
+
[no.SERVICE_UNAVAILABLE]: "service-unavailable"
|
|
7248
7386
|
};
|
|
7249
|
-
function
|
|
7387
|
+
function io(e, t) {
|
|
7250
7388
|
return e.errorMessage ?? e.message ?? e.error ?? t;
|
|
7251
7389
|
}
|
|
7252
|
-
var
|
|
7390
|
+
var ao = new Set([
|
|
7253
7391
|
O.CALLER_IS_BLOCKED,
|
|
7254
7392
|
O.ENDED,
|
|
7255
7393
|
O.NOT_FOUND,
|
|
7256
7394
|
O.PARTICIPANT_LIMIT_REACHED,
|
|
7257
7395
|
O.SERVICE_UNAVAILABLE
|
|
7258
|
-
]),
|
|
7396
|
+
]), oo = class e extends On {
|
|
7259
7397
|
static get WAIT_CONNECTION_DELAY() {
|
|
7260
7398
|
return N.waitConnectionDelay;
|
|
7261
7399
|
}
|
|
@@ -7266,7 +7404,7 @@ var $a = new Set([
|
|
|
7266
7404
|
return !this.disposed && this.transport.readyState !== null;
|
|
7267
7405
|
}
|
|
7268
7406
|
constructor(e = z, t = null, n = null, r = null, i = null) {
|
|
7269
|
-
super(), h(this, "transport", void 0), h(this, "sequence", 1), h(this, "lastStamp", 0), h(this, "websocketCommandsQueue", []), h(this, "datachannelCommandsQueue", []), h(this, "incomingCache", []), h(this, "responseHandlers", {}), h(this, "disposed", !1), h(this, "connectionType", void 0), h(this, "conversationResolve", null), h(this, "conversationReject", null), h(this, "connected", !1), h(this, "listenersReady", !1), h(this, "peerId", null), h(this, "reconnectStartedAt", null), h(this, "connectionMessageWaitTimer", 0), h(this, "participantIdRegistry", null), h(this, "producerNotificationDataChannel", null), h(this, "producerCommandDataChannel", null), h(this, "producerCommandDataChannelEnabled", !1), h(this, "producerCommandSerializationService", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_statPings", void 0), h(this, "_statSignalingCommands", void 0), this._debug = e, this._logger = t, this._statAggregator = n, this._statPings = r, this._statSignalingCommands = i, this.producerCommandSerializationService = new tr(e), this.transport = new
|
|
7407
|
+
super(), h(this, "transport", void 0), h(this, "sequence", 1), h(this, "lastStamp", 0), h(this, "websocketCommandsQueue", []), h(this, "datachannelCommandsQueue", []), h(this, "incomingCache", []), h(this, "responseHandlers", {}), h(this, "disposed", !1), h(this, "connectionType", void 0), h(this, "conversationResolve", null), h(this, "conversationReject", null), h(this, "connected", !1), h(this, "listenersReady", !1), h(this, "peerId", null), h(this, "reconnectStartedAt", null), h(this, "connectionMessageWaitTimer", 0), h(this, "participantIdRegistry", null), h(this, "producerNotificationDataChannel", null), h(this, "producerCommandDataChannel", null), h(this, "producerCommandDataChannelEnabled", !1), h(this, "producerCommandSerializationService", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_statPings", void 0), h(this, "_statSignalingCommands", void 0), this._debug = e, this._logger = t, this._statAggregator = n, this._statPings = r, this._statSignalingCommands = i, this.producerCommandSerializationService = new tr(e), this.transport = new Qa(e, {
|
|
7270
7408
|
onConnecting: this._onTransportConnecting.bind(this),
|
|
7271
7409
|
onOpen: this._onOpen.bind(this),
|
|
7272
7410
|
onMessage: this._onMessage.bind(this),
|
|
@@ -7353,20 +7491,20 @@ var $a = new Set([
|
|
|
7353
7491
|
return this._send(V.TRANSMIT_DATA, {
|
|
7354
7492
|
participantId: e,
|
|
7355
7493
|
data: r
|
|
7356
|
-
}, !0,
|
|
7494
|
+
}, !0, to);
|
|
7357
7495
|
}
|
|
7358
7496
|
async acceptCall(e) {
|
|
7359
7497
|
return this._send(V.ACCEPT_CALL, { mediaSettings: e });
|
|
7360
7498
|
}
|
|
7361
7499
|
async changeMediaSettings(e) {
|
|
7362
|
-
return this._send(V.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0,
|
|
7500
|
+
return this._send(V.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, to);
|
|
7363
7501
|
}
|
|
7364
7502
|
async changeParticipantState(e, t) {
|
|
7365
7503
|
let n = { participantState: { state: e } };
|
|
7366
7504
|
return t && (n.participantId = t), this._sendRaw(V.CHANGE_PARTICIPANT_STATE, n);
|
|
7367
7505
|
}
|
|
7368
7506
|
async hold(e) {
|
|
7369
|
-
let t =
|
|
7507
|
+
let t = za.get();
|
|
7370
7508
|
return this._send(V.HOLD, {
|
|
7371
7509
|
hold: e,
|
|
7372
7510
|
capabilities: e ? void 0 : t
|
|
@@ -7598,7 +7736,7 @@ var $a = new Set([
|
|
|
7598
7736
|
if (this.disposed) throw new En(e);
|
|
7599
7737
|
switch (t.route) {
|
|
7600
7738
|
case "producer":
|
|
7601
|
-
this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState ===
|
|
7739
|
+
this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === $a && this._handleCommandsQueue(this.datachannelCommandsQueue);
|
|
7602
7740
|
break;
|
|
7603
7741
|
case "websocket":
|
|
7604
7742
|
if (this.transport.readyState === null) {
|
|
@@ -7648,7 +7786,7 @@ var $a = new Set([
|
|
|
7648
7786
|
_handleMessage(e) {
|
|
7649
7787
|
switch (e.type) {
|
|
7650
7788
|
case "notification":
|
|
7651
|
-
this._attachNotificationCallError(e), e.notification === "connection" ? (this._debug.debug("[signaling] signaling connected", e), this.connected = !0, this.transport.
|
|
7789
|
+
this._attachNotificationCallError(e), e.notification === "connection" ? (this._debug.debug("[signaling] signaling connected", e), this.connected = !0, this.transport.onConnectionRestored(), this.transport.setEndpoint(e.endpoint), e.peerId && this.peerId !== e.peerId.id && (this.peerId = e.peerId.id, this.transport.setPeerId(e.peerId.id)), this._stopWaitConnectionMessage(), this.conversationResolve ? this.conversationResolve(e) : (this._triggerEvent(xr.RECONNECT, e), e.conversation.topology && this._triggerEvent(xr.NOTIFICATION, {
|
|
7652
7790
|
type: "notification",
|
|
7653
7791
|
notification: K.TOPOLOGY_CHANGED,
|
|
7654
7792
|
topology: e.conversation.topology
|
|
@@ -7668,9 +7806,9 @@ var $a = new Set([
|
|
|
7668
7806
|
}
|
|
7669
7807
|
_handleErrorMessage(e) {
|
|
7670
7808
|
this._logger?.log(C.SOCKET_ACTION, `error-${e.error}`);
|
|
7671
|
-
let t = this._getSocketType(), n = e.error ? this._createSignalingCallError(e.error, e.errorCode, t) : void 0, r =
|
|
7809
|
+
let t = this._getSocketType(), n = e.error ? this._createSignalingCallError(e.error, e.errorCode, t) : void 0, r = io(e, "Unknown signaling error");
|
|
7672
7810
|
switch (this._debug.debug(`[signaling] error message [${e.sequence}]`, e), e.sequence && this.responseHandlers[e.sequence] && this._handleCommandResponse(!1, e), e.error) {
|
|
7673
|
-
case
|
|
7811
|
+
case no.SERVICE_UNAVAILABLE:
|
|
7674
7812
|
let i = new k(O.SERVICE_UNAVAILABLE, {
|
|
7675
7813
|
callError: n,
|
|
7676
7814
|
message: r,
|
|
@@ -7682,7 +7820,7 @@ var $a = new Set([
|
|
|
7682
7820
|
reason: O.SERVICE_UNAVAILABLE
|
|
7683
7821
|
});
|
|
7684
7822
|
break;
|
|
7685
|
-
case
|
|
7823
|
+
case no.CONVERSATION_ENDED:
|
|
7686
7824
|
this.conversationReject ? this.conversationReject(new k(e.reason || x.SIGNALING_FAILED, {
|
|
7687
7825
|
callError: n,
|
|
7688
7826
|
message: r,
|
|
@@ -7693,22 +7831,22 @@ var $a = new Set([
|
|
|
7693
7831
|
reason: e.reason
|
|
7694
7832
|
});
|
|
7695
7833
|
break;
|
|
7696
|
-
case
|
|
7697
|
-
case
|
|
7834
|
+
case no.ILLEGAL_PARTICIPANT_STATE:
|
|
7835
|
+
case no.PARTICIPANT_NOT_FOUND:
|
|
7698
7836
|
this._throwError(new k(x.SIGNALING_FAILED, {
|
|
7699
7837
|
callError: n,
|
|
7700
7838
|
message: r,
|
|
7701
7839
|
remote: !0
|
|
7702
7840
|
}));
|
|
7703
7841
|
break;
|
|
7704
|
-
case
|
|
7842
|
+
case no.OBSOLETE_CLIENT:
|
|
7705
7843
|
this.conversationReject?.(new k(e.reason || O.OBSOLETE_CLIENT, {
|
|
7706
7844
|
callError: n,
|
|
7707
7845
|
message: r,
|
|
7708
7846
|
remote: !0
|
|
7709
7847
|
}));
|
|
7710
7848
|
break;
|
|
7711
|
-
case
|
|
7849
|
+
case no.INVALID_TOKEN:
|
|
7712
7850
|
default:
|
|
7713
7851
|
if (e.sequence || t === Sr.WEBTRANSPORT) break;
|
|
7714
7852
|
if (this.connected) this._throwError(new k(e.reason || x.SIGNALING_FAILED, {
|
|
@@ -7747,7 +7885,7 @@ var $a = new Set([
|
|
|
7747
7885
|
}
|
|
7748
7886
|
_describeErrorEvent(e) {
|
|
7749
7887
|
let t = e, n = t.error instanceof Error ? t.error : null, r = [n?.name || t.errorInfo?.name, n?.message || t.errorInfo?.message || t.message].filter(Boolean).join(": ") || "Unknown error", i = t.errorInfo?.phase;
|
|
7750
|
-
return (i ? `${i}: ${r}` : r).slice(0,
|
|
7888
|
+
return (i ? `${i}: ${r}` : r).slice(0, eo);
|
|
7751
7889
|
}
|
|
7752
7890
|
_onClose(e) {
|
|
7753
7891
|
this._logger?.log(C.SOCKET_ACTION, "closed"), this._debug.debug("[signaling] connection closed", {
|
|
@@ -7802,13 +7940,13 @@ var $a = new Set([
|
|
|
7802
7940
|
let r = this.responseHandlers[n.sequence];
|
|
7803
7941
|
window.clearTimeout(r.responseTimer);
|
|
7804
7942
|
let i = G.measureMark(r.statMarkName);
|
|
7805
|
-
i !== null && this._statSignalingCommands?.mark(r.name, i, this._getSocketType()), this._debug.debug(`[signaling] command response [${n.sequence}]`, n), t ? (delete this.responseHandlers[n.sequence], r.resolve(n)) : n.type === "error" ? (delete this.responseHandlers[n.sequence], this._logger?.log(C.SOCKET_ACTION, "response-error"), r.reject(Error(
|
|
7943
|
+
i !== null && this._statSignalingCommands?.mark(r.name, i, this._getSocketType()), this._debug.debug(`[signaling] command response [${n.sequence}]`, n), t ? (delete this.responseHandlers[n.sequence], r.resolve(n)) : n.type === "error" ? (delete this.responseHandlers[n.sequence], this._logger?.log(C.SOCKET_ACTION, "response-error"), r.reject(Error(io(n, `Response error [${r.name}]`)), !0)) : this.transport.readyState === WebSocket.OPEN ? (delete this.responseHandlers[n.sequence], this._logger?.log(C.SOCKET_ACTION, "response-timeout"), r.reject(Error(io(n, `Response timeout [${r.name}]`)))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
|
|
7806
7944
|
}
|
|
7807
7945
|
_handleCommandsQueue(e) {
|
|
7808
7946
|
for (; e.length > 0;) {
|
|
7809
7947
|
let t = e.shift();
|
|
7810
7948
|
if (this._debug.debug(`[signaling] command send [${t.sequence}]`, `'${t.name}'`, t.params), t.route === "producer") {
|
|
7811
|
-
if (this.producerCommandDataChannel?.readyState !==
|
|
7949
|
+
if (this.producerCommandDataChannel?.readyState !== $a) {
|
|
7812
7950
|
t.reject(/* @__PURE__ */ Error(`Invalid data channel state: ${this.producerCommandDataChannel?.readyState}`));
|
|
7813
7951
|
return;
|
|
7814
7952
|
}
|
|
@@ -7893,7 +8031,7 @@ var $a = new Set([
|
|
|
7893
8031
|
}
|
|
7894
8032
|
_onTransportFailed(e) {
|
|
7895
8033
|
switch (e.failure) {
|
|
7896
|
-
case
|
|
8034
|
+
case Za.EMPTY_ENDPOINT:
|
|
7897
8035
|
this.conversationReject?.(new k(x.SIGNALING_FAILED, {
|
|
7898
8036
|
callError: {
|
|
7899
8037
|
scope: "internal",
|
|
@@ -7904,7 +8042,7 @@ var $a = new Set([
|
|
|
7904
8042
|
remote: e.remote
|
|
7905
8043
|
}));
|
|
7906
8044
|
break;
|
|
7907
|
-
case
|
|
8045
|
+
case Za.NETWORK_ERROR:
|
|
7908
8046
|
this._logReconnectTimeout(), this._fail(new k(O.NETWORK_ERROR, { callError: {
|
|
7909
8047
|
scope: "network",
|
|
7910
8048
|
source: e.source,
|
|
@@ -7912,7 +8050,15 @@ var $a = new Set([
|
|
|
7912
8050
|
description: "connection-failed"
|
|
7913
8051
|
} }));
|
|
7914
8052
|
break;
|
|
7915
|
-
case
|
|
8053
|
+
case Za.RECONNECT_TIMEOUT:
|
|
8054
|
+
this._logReconnectTimeout(), this._fail(new k(O.NETWORK_ERROR, { callError: {
|
|
8055
|
+
scope: "network",
|
|
8056
|
+
source: e.source,
|
|
8057
|
+
code: "reconnect-timeout",
|
|
8058
|
+
description: "connection-failed"
|
|
8059
|
+
} }));
|
|
8060
|
+
break;
|
|
8061
|
+
case Za.ABORTED:
|
|
7916
8062
|
this._debug.debug("[signaling] aborted reconnect"), this._fail(new k(O.CANCELED));
|
|
7917
8063
|
break;
|
|
7918
8064
|
}
|
|
@@ -7927,7 +8073,7 @@ var $a = new Set([
|
|
|
7927
8073
|
this._debug.warn("[signaling] socket is dead, trying to reconnect"), this._logTransportStatSinceMark(Cr.FAILED_PINGS);
|
|
7928
8074
|
}
|
|
7929
8075
|
_attachNotificationCallError(e) {
|
|
7930
|
-
e.callError || !e.reason || e.reason === O.FAILED || e.reason === O.UNKNOWN_ERROR ||
|
|
8076
|
+
e.callError || !e.reason || e.reason === O.FAILED || e.reason === O.UNKNOWN_ERROR || !ao.has(e.reason) && !e.errorCode || (e.callError = {
|
|
7931
8077
|
scope: "server",
|
|
7932
8078
|
source: this._getSocketType(),
|
|
7933
8079
|
code: e.errorCode || "protocol",
|
|
@@ -7935,7 +8081,7 @@ var $a = new Set([
|
|
|
7935
8081
|
});
|
|
7936
8082
|
}
|
|
7937
8083
|
_createSignalingCallError(e, t, n) {
|
|
7938
|
-
let r =
|
|
8084
|
+
let r = ro[e];
|
|
7939
8085
|
if (r) return {
|
|
7940
8086
|
scope: "server",
|
|
7941
8087
|
source: n,
|
|
@@ -7961,39 +8107,39 @@ var $a = new Set([
|
|
|
7961
8107
|
let t = this._getSocketType(), n = wr[e][t];
|
|
7962
8108
|
this._statAggregator?.logEventualStatSinceMark({ name: n });
|
|
7963
8109
|
}
|
|
7964
|
-
},
|
|
8110
|
+
}, so = /* @__PURE__ */ function(e) {
|
|
7965
8111
|
return e.INCOMING = "INCOMING", e.OUTGOING = "OUTGOING", e.JOINING = "JOINING", e;
|
|
7966
|
-
}(
|
|
8112
|
+
}(so || {}), co = /* @__PURE__ */ function(e) {
|
|
7967
8113
|
return e.USER = "USER", e.GROUP = "GROUP", e.CHAT = "CHAT", e;
|
|
7968
|
-
}(
|
|
8114
|
+
}(co || {}), lo = /* @__PURE__ */ function(e) {
|
|
7969
8115
|
return e.ATTENDEE = "ATTENDEE", e.HAND_UP = "HAND_UP", e;
|
|
7970
|
-
}(
|
|
8116
|
+
}(lo || {}), uo = /* @__PURE__ */ function(e) {
|
|
7971
8117
|
return e.ADD_PARTICIPANT = "ADD_PARTICIPANT", e.RECORD = "RECORD", e.MOVIE_SHARE = "MOVIE_SHARE", e;
|
|
7972
|
-
}(
|
|
8118
|
+
}(uo || {}), fo = /* @__PURE__ */ function(e) {
|
|
7973
8119
|
return e.REQUIRE_AUTH_TO_JOIN = "REQUIRE_AUTH_TO_JOIN", e.AUDIENCE_MODE = "AUDIENCE_MODE", e.WAITING_HALL = "WAITING_HALL", e.WAIT_FOR_ADMIN = "WAIT_FOR_ADMIN", e.ADMIN_IS_HERE = "ADMIN_IS_HERE", e.ASR = "ASR", e.FEEDBACK = "FEEDBACK", e.RECURRING = "RECURRING", e;
|
|
7974
|
-
}(
|
|
7975
|
-
function
|
|
8120
|
+
}(fo || {});
|
|
8121
|
+
function po(e, t) {
|
|
7976
8122
|
if (e.length !== t.length) return !1;
|
|
7977
8123
|
for (let n of e) if (!t.includes(n)) return !1;
|
|
7978
8124
|
return !0;
|
|
7979
8125
|
}
|
|
7980
|
-
function
|
|
8126
|
+
function mo(e, t) {
|
|
7981
8127
|
let n = new Set(e);
|
|
7982
8128
|
for (let [e, r] of Object.entries(t)) r ? n.add(e) : n.delete(e);
|
|
7983
8129
|
return Array.from(n);
|
|
7984
8130
|
}
|
|
7985
8131
|
//#endregion
|
|
7986
8132
|
//#region src/enums/MuteState.ts
|
|
7987
|
-
var
|
|
8133
|
+
var ho = /* @__PURE__ */ function(e) {
|
|
7988
8134
|
return e.UNMUTE = "UNMUTE", e.MUTE = "MUTE", e.MUTE_PERMANENT = "MUTE_PERMANENT", e;
|
|
7989
|
-
}(
|
|
8135
|
+
}(ho || {}), X = /* @__PURE__ */ function(e) {
|
|
7990
8136
|
return e.CALLED = "CALLED", e.ACCEPTED = "ACCEPTED", e.REJECTED = "REJECTED", e.HUNGUP = "HUNGUP", e;
|
|
7991
|
-
}(X || {}),
|
|
8137
|
+
}(X || {}), go = /* @__PURE__ */ function(e) {
|
|
7992
8138
|
return e.UPDATE = "UPDATE", e.REMOVE = "REMOVE", e.ACTIVATE = "ACTIVATE", e.TIMEOUT = "TIMEOUT", e;
|
|
7993
|
-
}(
|
|
8139
|
+
}(go || {}), _o = /* @__PURE__ */ function(e) {
|
|
7994
8140
|
return e.NO_AVAILABLE_TRACKS = "no-available-tracks", e.UNKNOWN_ERROR = "unknown-error", e;
|
|
7995
|
-
}(
|
|
7996
|
-
function
|
|
8141
|
+
}(_o || {});
|
|
8142
|
+
function vo(e) {
|
|
7997
8143
|
switch (e) {
|
|
7998
8144
|
case 1: return "no-available-tracks";
|
|
7999
8145
|
default: return "unknown-error";
|
|
@@ -8001,17 +8147,17 @@ function fo(e) {
|
|
|
8001
8147
|
}
|
|
8002
8148
|
//#endregion
|
|
8003
8149
|
//#region src/enums/UserRole.ts
|
|
8004
|
-
var
|
|
8150
|
+
var yo = /* @__PURE__ */ function(e) {
|
|
8005
8151
|
return e.CREATOR = "CREATOR", e.ADMIN = "ADMIN", e;
|
|
8006
|
-
}(
|
|
8007
|
-
function
|
|
8152
|
+
}(yo || {});
|
|
8153
|
+
function bo(e, t) {
|
|
8008
8154
|
if (e.length !== t.length) return !1;
|
|
8009
8155
|
for (let n of e) if (!t.includes(n)) return !1;
|
|
8010
8156
|
return !0;
|
|
8011
8157
|
}
|
|
8012
8158
|
//#endregion
|
|
8013
8159
|
//#region src/static/ParticipantConnectionStatusUtils.ts
|
|
8014
|
-
var
|
|
8160
|
+
var xo;
|
|
8015
8161
|
(function(e) {
|
|
8016
8162
|
function t(e) {
|
|
8017
8163
|
let t = e?.transport ?? e?.lastEffective ?? P.WAITING, n = {
|
|
@@ -8063,8 +8209,8 @@ var ho;
|
|
|
8063
8209
|
shouldNotify: !0
|
|
8064
8210
|
});
|
|
8065
8211
|
}
|
|
8066
|
-
})(
|
|
8067
|
-
var
|
|
8212
|
+
})(xo || (xo = {}));
|
|
8213
|
+
var So = xo, Co = /* @__PURE__ */ function(e) {
|
|
8068
8214
|
return e.USER = "USER", e.ANONYM = "ANONYM", e.GROUP = "GROUP", e;
|
|
8069
8215
|
}({}), Z;
|
|
8070
8216
|
(function(e) {
|
|
@@ -8127,7 +8273,7 @@ var go = ho, _o = /* @__PURE__ */ function(e) {
|
|
|
8127
8273
|
})(Z || (Z = {}));
|
|
8128
8274
|
//#endregion
|
|
8129
8275
|
//#region src/types/WaitingHall.ts
|
|
8130
|
-
function
|
|
8276
|
+
function wo(e) {
|
|
8131
8277
|
try {
|
|
8132
8278
|
return btoa(JSON.stringify(e));
|
|
8133
8279
|
} catch (t) {
|
|
@@ -8135,7 +8281,7 @@ function vo(e) {
|
|
|
8135
8281
|
}
|
|
8136
8282
|
return null;
|
|
8137
8283
|
}
|
|
8138
|
-
function
|
|
8284
|
+
function To(e) {
|
|
8139
8285
|
try {
|
|
8140
8286
|
return JSON.parse(atob(e));
|
|
8141
8287
|
} catch (t) {
|
|
@@ -8145,12 +8291,12 @@ function yo(e) {
|
|
|
8145
8291
|
}
|
|
8146
8292
|
//#endregion
|
|
8147
8293
|
//#region src/utils/Conversation.ts
|
|
8148
|
-
var
|
|
8149
|
-
function
|
|
8294
|
+
var Eo = (e, t) => M.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
|
|
8295
|
+
function Do(e) {
|
|
8150
8296
|
if (e.conversation?.muteStates) return e.conversation.muteStates;
|
|
8151
8297
|
if (e.muteState && e.muteOptions) return e.muteOptions.reduce((t, n) => (t[n] = e.muteState, t), {});
|
|
8152
8298
|
}
|
|
8153
|
-
function
|
|
8299
|
+
function Oo(e, t) {
|
|
8154
8300
|
switch (e) {
|
|
8155
8301
|
case S.AUDIO: return !!t.isAudioEnabled;
|
|
8156
8302
|
case S.AUDIO_SHARING: return !!t.isAudioSharingEnabled;
|
|
@@ -8159,12 +8305,12 @@ function So(e, t) {
|
|
|
8159
8305
|
default: return !1;
|
|
8160
8306
|
}
|
|
8161
8307
|
}
|
|
8162
|
-
function
|
|
8308
|
+
function ko(e, t) {
|
|
8163
8309
|
return M.objectReduce(e, (e, n, r) => {
|
|
8164
8310
|
switch (n) {
|
|
8165
|
-
case
|
|
8166
|
-
case
|
|
8167
|
-
|
|
8311
|
+
case ho.MUTE:
|
|
8312
|
+
case ho.MUTE_PERMANENT:
|
|
8313
|
+
Oo(r, t) || (e[r] = n);
|
|
8168
8314
|
break;
|
|
8169
8315
|
default:
|
|
8170
8316
|
e[r] = n;
|
|
@@ -8173,19 +8319,19 @@ function Co(e, t) {
|
|
|
8173
8319
|
return e;
|
|
8174
8320
|
}, {});
|
|
8175
8321
|
}
|
|
8176
|
-
function
|
|
8322
|
+
function Ao(e) {
|
|
8177
8323
|
let { muteStates: t = {}, mediaSettings: n } = e;
|
|
8178
|
-
return
|
|
8324
|
+
return ko(t, n);
|
|
8179
8325
|
}
|
|
8180
|
-
function
|
|
8326
|
+
function jo(e, t) {
|
|
8181
8327
|
let n = e.conversation.participants.find((t) => M.comparePeerId(t.peerId, e.peerId));
|
|
8182
8328
|
if (!n) return t;
|
|
8183
8329
|
let { mediaSettings: r } = n;
|
|
8184
|
-
return
|
|
8330
|
+
return ko(t, r);
|
|
8185
8331
|
}
|
|
8186
8332
|
//#endregion
|
|
8187
8333
|
//#region src/utils/IceServers.ts
|
|
8188
|
-
function
|
|
8334
|
+
function Mo(e) {
|
|
8189
8335
|
if (!e) return null;
|
|
8190
8336
|
let t = Array.from(new Set((e.urls ?? []).map((e) => e.trim()).filter((e) => e.length > 0)));
|
|
8191
8337
|
return t.length ? {
|
|
@@ -8193,8 +8339,8 @@ function Eo(e) {
|
|
|
8193
8339
|
urls: t
|
|
8194
8340
|
} : null;
|
|
8195
8341
|
}
|
|
8196
|
-
function
|
|
8197
|
-
let n = [], r =
|
|
8342
|
+
function No(e, t) {
|
|
8343
|
+
let n = [], r = Mo(e), i = Mo(t);
|
|
8198
8344
|
if (r && n.push(r), i) {
|
|
8199
8345
|
let e = [...i.urls];
|
|
8200
8346
|
e.push(`${e[e.length - 1]}?transport=tcp`), n.push({
|
|
@@ -8206,7 +8352,7 @@ function Do(e, t) {
|
|
|
8206
8352
|
}
|
|
8207
8353
|
//#endregion
|
|
8208
8354
|
//#region src/utils/Lz4.ts
|
|
8209
|
-
function
|
|
8355
|
+
function Po(e, t) {
|
|
8210
8356
|
let n = new Uint8Array(t), r = 0, i = 0;
|
|
8211
8357
|
for (; r < e.length && i < t;) {
|
|
8212
8358
|
let a = e[r++], o = a >> 4, s = a & 15;
|
|
@@ -8233,7 +8379,7 @@ function Oo(e, t) {
|
|
|
8233
8379
|
}
|
|
8234
8380
|
//#endregion
|
|
8235
8381
|
//#region src/utils/SerializeLatest.ts
|
|
8236
|
-
function
|
|
8382
|
+
function Fo(e) {
|
|
8237
8383
|
let t, n = !1, r, i = async () => {
|
|
8238
8384
|
let t = !1, i;
|
|
8239
8385
|
for (; n;) {
|
|
@@ -8254,7 +8400,7 @@ function ko(e) {
|
|
|
8254
8400
|
}
|
|
8255
8401
|
//#endregion
|
|
8256
8402
|
//#region src/classes/AudioFix.ts
|
|
8257
|
-
var
|
|
8403
|
+
var Io = class {
|
|
8258
8404
|
constructor(e, t = z, n = null) {
|
|
8259
8405
|
h(this, "_fixNoPacketsApplied", !1), h(this, "_fixNoPacketsChecked", !1), h(this, "_fixTooManyPacketsApplied", !1), h(this, "_fixTooManyPacketsSucceeded", !1), h(this, "_fixTooManyPacketsFailed", !1), h(this, "_fixTooManyPacketsTime", void 0), h(this, "_mediaSource", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_lastPacketsSent", void 0), h(this, "_lastPacketsSentTime", void 0), h(this, "_toggleAudioPromise", null), h(this, "_fixNoPacketsAppliedVideo", !1), this._mediaSource = e, this._debug = t, this._logger = n;
|
|
8260
8406
|
}
|
|
@@ -8292,9 +8438,9 @@ var Ao = class {
|
|
|
8292
8438
|
this._debug.warn("[AudioFix] Failed to fix RV (no packets): video restart", e);
|
|
8293
8439
|
}));
|
|
8294
8440
|
}
|
|
8295
|
-
},
|
|
8296
|
-
constructor(e, t = !1, n = z, r = null
|
|
8297
|
-
h(this, "_audioElement", null), h(this, "_debug", void 0), h(this, "_preparedAudioElement", void 0), h(this, "_audioTracks", /* @__PURE__ */ new Map()), h(this, "_allowMultipleTracks", void 0), h(this, "_volume", 1), h(this, "_features", { setSinkId: !!Audio.prototype.setSinkId }), h(this, "_statFirstMediaReceived", void 0), h(this, "_logger", void 0),
|
|
8441
|
+
}, Lo = class {
|
|
8442
|
+
constructor(e, t = !1, n = z, r = null) {
|
|
8443
|
+
h(this, "_audioElement", null), h(this, "_debug", void 0), h(this, "_preparedAudioElement", void 0), h(this, "_audioTracks", /* @__PURE__ */ new Map()), h(this, "_allowMultipleTracks", void 0), h(this, "_volume", 1), h(this, "_features", { setSinkId: !!Audio.prototype.setSinkId }), h(this, "_statFirstMediaReceived", void 0), h(this, "_logger", void 0), this._statFirstMediaReceived = e, this._allowMultipleTracks = t, this._debug = n, this._logger = r, this._preparedAudioElement = this._prepareAudioElement();
|
|
8298
8444
|
}
|
|
8299
8445
|
add(e, t) {
|
|
8300
8446
|
this._allowMultipleTracks || this._clearTracks();
|
|
@@ -8333,7 +8479,7 @@ var Ao = class {
|
|
|
8333
8479
|
let e = E.getSavedOutput();
|
|
8334
8480
|
e && (await this._audioElement.setSinkId?.(e.deviceId), this._debug.debug("[audio] Output device changed", e));
|
|
8335
8481
|
} catch (e) {
|
|
8336
|
-
throw this._logger?.log(C.ERROR, "change_output"), this.
|
|
8482
|
+
throw this._logger?.log(C.ERROR, "change_output"), this._debug.error("[audio] Output change failed", e), e;
|
|
8337
8483
|
}
|
|
8338
8484
|
}
|
|
8339
8485
|
_getTracks() {
|
|
@@ -8363,7 +8509,7 @@ var Ao = class {
|
|
|
8363
8509
|
a ? t.setSinkId?.(a.deviceId).then(() => {
|
|
8364
8510
|
this._debug.debug("[audio] Output device", a);
|
|
8365
8511
|
}).catch((e) => {
|
|
8366
|
-
this.
|
|
8512
|
+
this._debug.warn("[audio] Failed to set output device", a, e);
|
|
8367
8513
|
}) : this._debug.debug("[audio] Output device: system default");
|
|
8368
8514
|
}
|
|
8369
8515
|
_stopAudioElement() {
|
|
@@ -8395,13 +8541,13 @@ var Ao = class {
|
|
|
8395
8541
|
};
|
|
8396
8542
|
//#endregion
|
|
8397
8543
|
//#region src/classes/conversation/ConversationResponseValidator.ts
|
|
8398
|
-
function
|
|
8399
|
-
e ||
|
|
8544
|
+
function Ro(e, t) {
|
|
8545
|
+
e || Bo(t, "response-empty"), e.id || Bo(t, "id-empty"), e.endpoint || Bo(t, "endpoint-empty"), !zo(e.stun_server) && !zo(e.turn_server) && Bo(t, "ice-servers-empty");
|
|
8400
8546
|
}
|
|
8401
|
-
function
|
|
8547
|
+
function zo(e) {
|
|
8402
8548
|
return Array.isArray(e?.urls) && e.urls.length > 0;
|
|
8403
8549
|
}
|
|
8404
|
-
function
|
|
8550
|
+
function Bo(e, t) {
|
|
8405
8551
|
let n = e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), r = e === "fastStart" || e === "fastJoin";
|
|
8406
8552
|
throw new k(r ? e === "fastStart" ? O.FAST_START_ERROR : O.FAST_JOIN_ERROR : O.UNKNOWN_ERROR, {
|
|
8407
8553
|
message: `Invalid ${e} response: ${t}`,
|
|
@@ -8420,7 +8566,7 @@ function Po(e, t) {
|
|
|
8420
8566
|
}
|
|
8421
8567
|
//#endregion
|
|
8422
8568
|
//#region src/classes/DebugInfo.ts
|
|
8423
|
-
var
|
|
8569
|
+
var Vo = 90, Ho = 3, Uo = class extends b {
|
|
8424
8570
|
constructor(e = z) {
|
|
8425
8571
|
super(), h(this, "_lastMemoryStat", {
|
|
8426
8572
|
percent: 0,
|
|
@@ -8436,9 +8582,9 @@ var Fo = 90, Io = 3, Lo = class extends b {
|
|
|
8436
8582
|
let e = window?.performance?.memory;
|
|
8437
8583
|
if (!e || !e.usedJSHeapSize || !e.jsHeapSizeLimit) return;
|
|
8438
8584
|
let t = Number((100 * e.usedJSHeapSize / e.jsHeapSizeLimit).toFixed(2)), n = Number((e.usedJSHeapSize / 1024 / 1024).toFixed(1));
|
|
8439
|
-
t >
|
|
8585
|
+
t > Vo ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= Ho) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
|
|
8440
8586
|
}
|
|
8441
|
-
},
|
|
8587
|
+
}, Wo = class {
|
|
8442
8588
|
constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i, onNonFatalError: a }) {
|
|
8443
8589
|
h(this, "_api", void 0), h(this, "_debug", void 0), h(this, "_getParticipants", void 0), h(this, "_isMe", void 0), h(this, "_updateDisplayLayout", void 0), h(this, "_onNonFatalError", void 0), h(this, "_requestedLayouts", {}), h(this, "_uncertainLayouts", {}), h(this, "_pendingRequests", null), h(this, "_pendingPromises", []), h(this, "_lastRequests", null), h(this, "_timer", null), h(this, "_inFlight", !1), h(this, "_lastFlushAt", null), h(this, "_generation", 0), h(this, "_forceNextFlush", !1), this._api = e, this._debug = t, this._getParticipants = n, this._isMe = r, this._updateDisplayLayout = i, this._onNonFatalError = a;
|
|
8444
8590
|
}
|
|
@@ -8553,7 +8699,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
|
|
|
8553
8699
|
let n = e, r = t;
|
|
8554
8700
|
return n.width !== r.width || n.height !== r.height || n.fit !== r.fit || n.priority !== r.priority;
|
|
8555
8701
|
}
|
|
8556
|
-
},
|
|
8702
|
+
}, Go = 44100, Ko = class {
|
|
8557
8703
|
constructor(e, t) {
|
|
8558
8704
|
h(this, "_analyser", null), h(this, "_gainNode", null), h(this, "_fftBins", null), h(this, "_mediaStreamSource", null), h(this, "_lastSmoothedLevel", 0), h(this, "_trackId", void 0), h(this, "_track", void 0), h(this, "_stream", void 0), this._trackId = e, this._track = t, this._stream = new MediaStream([t]);
|
|
8559
8705
|
try {
|
|
@@ -8570,7 +8716,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
|
|
|
8570
8716
|
_getBins() {
|
|
8571
8717
|
if (!this._fftBins || !this._analyser) return new Uint8Array();
|
|
8572
8718
|
this._analyser.getByteFrequencyData(this._fftBins);
|
|
8573
|
-
let e =
|
|
8719
|
+
let e = Go / this._fftBins.length, t = Math.ceil(N.voiceParams.minFreq / e), n = Math.floor(N.voiceParams.maxFreq / e);
|
|
8574
8720
|
return this._fftBins.subarray(t, n);
|
|
8575
8721
|
}
|
|
8576
8722
|
getLevel() {
|
|
@@ -8583,7 +8729,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
|
|
|
8583
8729
|
destroy() {
|
|
8584
8730
|
this._mediaStreamSource && (this._mediaStreamSource.disconnect(), this._mediaStreamSource = null), this._gainNode && (this._gainNode.disconnect(), this._gainNode = null), this._analyser && (this._analyser.disconnect(), this._analyser = null, this._fftBins = null, this._lastSmoothedLevel = 0), this._stream.removeTrack(this._track);
|
|
8585
8731
|
}
|
|
8586
|
-
},
|
|
8732
|
+
}, qo = class extends b {
|
|
8587
8733
|
constructor(e) {
|
|
8588
8734
|
super(), h(this, "_detector", null), h(this, "_interval", null);
|
|
8589
8735
|
let t = () => {
|
|
@@ -8599,7 +8745,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
|
|
|
8599
8745
|
}), this.subscribe(e, qt.SOURCE_READY, n), n();
|
|
8600
8746
|
}
|
|
8601
8747
|
init(e) {
|
|
8602
|
-
this._stopDetector(), this._detector = new
|
|
8748
|
+
this._stopDetector(), this._detector = new Ko("local", e.clone());
|
|
8603
8749
|
}
|
|
8604
8750
|
_stopDetector() {
|
|
8605
8751
|
this._detector && (this._detector.track.stop(), this._detector.destroy(), this._detector = null);
|
|
@@ -8607,7 +8753,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
|
|
|
8607
8753
|
destroy() {
|
|
8608
8754
|
this.unsubscribe(), this._interval && (window.clearTimeout(this._interval), this._interval = null), this._stopDetector();
|
|
8609
8755
|
}
|
|
8610
|
-
},
|
|
8756
|
+
}, Jo = class {
|
|
8611
8757
|
constructor(e, t = z) {
|
|
8612
8758
|
h(this, "processor", void 0), h(this, "queue", []), h(this, "isProcessing", !1), h(this, "_debug", void 0), this.processor = e, this._debug = t;
|
|
8613
8759
|
}
|
|
@@ -8627,9 +8773,9 @@ var Fo = 90, Io = 3, Lo = class extends b {
|
|
|
8627
8773
|
this.isProcessing = !1;
|
|
8628
8774
|
}
|
|
8629
8775
|
}
|
|
8630
|
-
},
|
|
8776
|
+
}, Yo = /* @__PURE__ */ function(e) {
|
|
8631
8777
|
return e.VOLUMES_DETECTED = "VOLUMES_DETECTED", e;
|
|
8632
|
-
}({}),
|
|
8778
|
+
}({}), Xo = class extends b {
|
|
8633
8779
|
constructor(e) {
|
|
8634
8780
|
super(), h(this, "_detectors", /* @__PURE__ */ new Map()), h(this, "_interval", null), h(this, "_activeParticipants", void 0), h(this, "_removedParticipants", void 0), h(this, "_topology", void 0), this._topology = e.getTopology(), this.subscribe(e, Y.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(e, Y.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(e, Y.SIGNALLED_ACTIVE_PARTICIPANTS, this._onSignalledActiveParticipants.bind(this)), this.subscribe(e, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
|
|
8635
8781
|
}
|
|
@@ -8637,7 +8783,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
|
|
|
8637
8783
|
this._interval && (window.clearTimeout(this._interval), this._interval = null), this.unsubscribe(), this._destroyDetectors();
|
|
8638
8784
|
}
|
|
8639
8785
|
_onRemoteTrackAdded(e, t, n) {
|
|
8640
|
-
if (n.kind === A.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new
|
|
8786
|
+
if (n.kind === A.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new Ko(e, n)), !this._interval)) {
|
|
8641
8787
|
let e = () => {
|
|
8642
8788
|
this._collectVolumes(), this._interval = window.setTimeout(e, N.voiceParams.interval);
|
|
8643
8789
|
};
|
|
@@ -8668,14 +8814,14 @@ var Fo = 90, Io = 3, Lo = class extends b {
|
|
|
8668
8814
|
this._triggerEvent("VOLUMES_DETECTED", e);
|
|
8669
8815
|
}
|
|
8670
8816
|
_getAudioTrackLevelByParticipantId(e) {
|
|
8671
|
-
let t = this._detectors.get(
|
|
8817
|
+
let t = this._detectors.get(fi.AUDIO_MIX);
|
|
8672
8818
|
return t ? t.getLevel() : this._getTransparentAudioLevelByParticipantId(e);
|
|
8673
8819
|
}
|
|
8674
8820
|
_getTransparentAudioLevelByParticipantId(e) {
|
|
8675
8821
|
if (!this._activeParticipants?.includes(e)) return null;
|
|
8676
8822
|
let t = null;
|
|
8677
8823
|
return this._detectors.forEach((e, n) => {
|
|
8678
|
-
if (!n.startsWith(`${
|
|
8824
|
+
if (!n.startsWith(`${fi.TRANSPARENT_AUDIO_TRACK_PREFIX}-`)) return;
|
|
8679
8825
|
let r = e.getLevel();
|
|
8680
8826
|
(!t || r.real > t.real) && (t = r);
|
|
8681
8827
|
}), t;
|
|
@@ -8691,11 +8837,11 @@ var Fo = 90, Io = 3, Lo = class extends b {
|
|
|
8691
8837
|
e.destroy();
|
|
8692
8838
|
}), this._detectors.clear();
|
|
8693
8839
|
}
|
|
8694
|
-
},
|
|
8840
|
+
}, Zo = /* @__PURE__ */ function(e) {
|
|
8695
8841
|
return e.SPEAKER_CHANGED = "SPEAKER_CHANGED", e;
|
|
8696
|
-
}({}),
|
|
8842
|
+
}({}), Qo = class extends b {
|
|
8697
8843
|
constructor(e, t, n) {
|
|
8698
|
-
super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === J.SERVER, this.subscribe(e,
|
|
8844
|
+
super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === J.SERVER, this.subscribe(e, Yo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this.subscribe(t, Y.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
|
|
8699
8845
|
}
|
|
8700
8846
|
destroy() {
|
|
8701
8847
|
this.unsubscribe();
|
|
@@ -8717,9 +8863,9 @@ var Fo = 90, Io = 3, Lo = class extends b {
|
|
|
8717
8863
|
_onTopologyChanged(e) {
|
|
8718
8864
|
this._serverSideSpeakerDetection = e === J.SERVER;
|
|
8719
8865
|
}
|
|
8720
|
-
},
|
|
8866
|
+
}, $o = 15e3, es = 15e3, ts = class extends b {
|
|
8721
8867
|
constructor(e, t, n, r = z, i = null) {
|
|
8722
|
-
super(), h(this, "_transport", void 0), h(this, "_volumes", {}), h(this, "_participants", {}), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_connectionTimeout", 0), h(this, "_connectionTimeoutSuppressed", !1), h(this, "_volumeTimeout", 0), this._transport = e, this._participants = n, this._debug = r, this._logger = i, this.subscribe(e, Y.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t,
|
|
8868
|
+
super(), h(this, "_transport", void 0), h(this, "_volumes", {}), h(this, "_participants", {}), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_connectionTimeout", 0), h(this, "_connectionTimeoutSuppressed", !1), h(this, "_volumeTimeout", 0), this._transport = e, this._participants = n, this._debug = r, this._logger = i, this.subscribe(e, Y.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, Yo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
|
|
8723
8869
|
}
|
|
8724
8870
|
destroy() {
|
|
8725
8871
|
this.unsubscribe(), this._connectionTimeout && window.clearTimeout(this._connectionTimeout), this._volumeTimeout && window.clearTimeout(this._volumeTimeout);
|
|
@@ -8731,10 +8877,10 @@ var Fo = 90, Io = 3, Lo = class extends b {
|
|
|
8731
8877
|
this._connectionTimeout || !this._connectionTimeoutSuppressed || this._reportConnectionTimeout();
|
|
8732
8878
|
}
|
|
8733
8879
|
_getConnectionTimeout() {
|
|
8734
|
-
return this._transport.getTopology() === J.DIRECT ?
|
|
8880
|
+
return this._transport.getTopology() === J.DIRECT ? $o : N.specListenerParams.connectionTimeout;
|
|
8735
8881
|
}
|
|
8736
8882
|
_getVolumeTimeout() {
|
|
8737
|
-
return this._transport.getTopology() === J.DIRECT ?
|
|
8883
|
+
return this._transport.getTopology() === J.DIRECT ? es : N.specListenerParams.volumeTimeout;
|
|
8738
8884
|
}
|
|
8739
8885
|
_onTransportStateChanged(e, t) {
|
|
8740
8886
|
t === q.OPENED && (this._connectionTimeout || (this._connectionTimeoutSuppressed = !1, this._connectionTimeout = window.setTimeout(this._onConnectionTimeout.bind(this), this._getConnectionTimeout()))), t === q.CONNECTED && (this._volumeTimeout || (this._volumeTimeout = window.setTimeout(this._onVolumeTimeout.bind(this), this._getVolumeTimeout())), this._volumeTimeout && (window.clearTimeout(this._volumeTimeout), this._volumeTimeout = window.setTimeout(this._onVolumeTimeout.bind(this), this._getVolumeTimeout()))), t === q.FAILED && this._connectionTimeout && (this._debug.warn("Transport failed, send callSpecError"), this._logger?.log(C.CALL_SPEC_ERROR, `${this._transport.getTopology()}_CONNECTION_TIMEOUT`));
|
|
@@ -8767,15 +8913,15 @@ var Fo = 90, Io = 3, Lo = class extends b {
|
|
|
8767
8913
|
r && r.platform && (n = r.platform), e.indexOf(n) < 0 && (e.push(n), this._logger?.log(C.CALL_SPEC_ERROR, `${this._transport.getTopology()}_VOLUME_TIMEOUT_${n}`));
|
|
8768
8914
|
}), e.length && this._debug.warn("There is silent participant, send callSpecError"), this._volumeTimeout = 0;
|
|
8769
8915
|
}
|
|
8770
|
-
},
|
|
8916
|
+
}, ns = /* @__PURE__ */ function(e) {
|
|
8771
8917
|
return e[e.PARAM_SESSION_EXPIRED = 102] = "PARAM_SESSION_EXPIRED", e[e.PARAM_SESSION_KEY = 103] = "PARAM_SESSION_KEY", e[e.PARAM_SIGNATURE = 104] = "PARAM_SIGNATURE", e[e.AUTH_LOGIN = 401] = "AUTH_LOGIN", e;
|
|
8772
|
-
}(
|
|
8773
|
-
function
|
|
8918
|
+
}(ns || {});
|
|
8919
|
+
function rs(e) {
|
|
8774
8920
|
return e === 102 || e === 103 || e === 104;
|
|
8775
8921
|
}
|
|
8776
8922
|
//#endregion
|
|
8777
8923
|
//#region src/classes/stat/StatQueue.ts
|
|
8778
|
-
var
|
|
8924
|
+
var is, as = "ok-calls-sdk-stats", os = 1, ss = "events", cs = 100, ls = 5e3, us = 10080 * 60 * 1e3, ds = 5e3, fs = 6e4, Q = class e {
|
|
8779
8925
|
static isSupported() {
|
|
8780
8926
|
return e._supported;
|
|
8781
8927
|
}
|
|
@@ -8788,7 +8934,7 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
|
|
|
8788
8934
|
n.onsuccess = () => e(n.result);
|
|
8789
8935
|
});
|
|
8790
8936
|
}).catch((e) => (z.error("[StatQueue] failed to append event", e), null));
|
|
8791
|
-
return r === null ? null : (e._appendsSinceEvictCheck += 1, e._appendsSinceEvictCheck >=
|
|
8937
|
+
return r === null ? null : (e._appendsSinceEvictCheck += 1, e._appendsSinceEvictCheck >= cs && (e._appendsSinceEvictCheck = 0, await e.evictToLimit(ls)), r);
|
|
8792
8938
|
}
|
|
8793
8939
|
static async fillDelta(t, n) {
|
|
8794
8940
|
if (t.length === 0) return;
|
|
@@ -8889,7 +9035,7 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
|
|
|
8889
9035
|
});
|
|
8890
9036
|
}
|
|
8891
9037
|
static async __resetForTests() {
|
|
8892
|
-
if (e._appendsSinceEvictCheck = 0, e._lastOpenFailureAt = null, e._supported = e._checkSupport(), e._dbName ===
|
|
9038
|
+
if (e._appendsSinceEvictCheck = 0, e._lastOpenFailureAt = null, e._supported = e._checkSupport(), e._dbName === as && (e._dbName = `${as}-test-${Math.random().toString(36).slice(2)}`, e._close()), e._supported) {
|
|
8893
9039
|
let t = await e._open();
|
|
8894
9040
|
t && await e._runTransaction(t, "readwrite", (e) => {
|
|
8895
9041
|
e.clear();
|
|
@@ -8897,7 +9043,6 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
|
|
|
8897
9043
|
z.error("[StatQueue] failed to reset storage", e);
|
|
8898
9044
|
});
|
|
8899
9045
|
}
|
|
8900
|
-
e._close();
|
|
8901
9046
|
}
|
|
8902
9047
|
static _checkSupport() {
|
|
8903
9048
|
return typeof window < "u" && !!window.indexedDB;
|
|
@@ -8905,18 +9050,18 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
|
|
|
8905
9050
|
static _open() {
|
|
8906
9051
|
if (!e._checkSupport()) return e._supported = !1, Promise.resolve(null);
|
|
8907
9052
|
if (e._dbPromise) return e._dbPromise;
|
|
8908
|
-
if (e._lastOpenFailureAt !== null && Date.now() - e._lastOpenFailureAt <
|
|
9053
|
+
if (e._lastOpenFailureAt !== null && Date.now() - e._lastOpenFailureAt < fs) return Promise.resolve(null);
|
|
8909
9054
|
let t = !1, n = new Promise((n) => {
|
|
8910
9055
|
let r = (r, i) => {
|
|
8911
9056
|
t || (t = !0, z.error(r, i), e._supported = !1, e._dbPromise = null, e._lastOpenFailureAt = Date.now(), n(null));
|
|
8912
9057
|
}, i;
|
|
8913
9058
|
try {
|
|
8914
|
-
i = window.indexedDB.open(e._dbName,
|
|
9059
|
+
i = window.indexedDB.open(e._dbName, os);
|
|
8915
9060
|
} catch (e) {
|
|
8916
9061
|
r("[StatQueue] storage is not accessible", e);
|
|
8917
9062
|
return;
|
|
8918
9063
|
}
|
|
8919
|
-
let a = window.setTimeout(() => r("[StatQueue] storage opening timed out"),
|
|
9064
|
+
let a = window.setTimeout(() => r("[StatQueue] storage opening timed out"), ds);
|
|
8920
9065
|
i.onupgradeneeded = () => {
|
|
8921
9066
|
e._createSchema(i.result);
|
|
8922
9067
|
}, i.onsuccess = () => {
|
|
@@ -8937,8 +9082,8 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
|
|
|
8937
9082
|
e._db && (e._db.close(), e._db = null), e._dbPromise = null;
|
|
8938
9083
|
}
|
|
8939
9084
|
static _createSchema(e) {
|
|
8940
|
-
if (e.objectStoreNames.contains(
|
|
8941
|
-
let t = e.createObjectStore(
|
|
9085
|
+
if (e.objectStoreNames.contains(ss)) return;
|
|
9086
|
+
let t = e.createObjectStore(ss, {
|
|
8942
9087
|
keyPath: "id",
|
|
8943
9088
|
autoIncrement: !0
|
|
8944
9089
|
});
|
|
@@ -8946,8 +9091,8 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
|
|
|
8946
9091
|
}
|
|
8947
9092
|
static _runTransaction(e, t, n) {
|
|
8948
9093
|
return new Promise((r, i) => {
|
|
8949
|
-
let a = e.transaction(
|
|
8950
|
-
a.oncomplete = () => r(o), a.onerror = () => i(a.error), a.onabort = () => i(a.error), Promise.resolve(n(a.objectStore(
|
|
9094
|
+
let a = e.transaction(ss, t), o;
|
|
9095
|
+
a.oncomplete = () => r(o), a.onerror = () => i(a.error), a.onabort = () => i(a.error), Promise.resolve(n(a.objectStore(ss))).then((e) => {
|
|
8951
9096
|
o = e;
|
|
8952
9097
|
}).catch((e) => {
|
|
8953
9098
|
try {
|
|
@@ -8972,18 +9117,18 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
|
|
|
8972
9117
|
});
|
|
8973
9118
|
}
|
|
8974
9119
|
};
|
|
8975
|
-
|
|
9120
|
+
is = Q, h(Q, "_db", null), h(Q, "_dbPromise", null), h(Q, "_dbName", as), h(Q, "_supported", is._checkSupport()), h(Q, "_appendsSinceEvictCheck", 0), h(Q, "_lastOpenFailureAt", null);
|
|
8976
9121
|
//#endregion
|
|
8977
9122
|
//#region src/static/ApiTransport.ts
|
|
8978
|
-
var
|
|
8979
|
-
function
|
|
8980
|
-
|
|
9123
|
+
var ps = null, ms = null, hs = 64 * 1024;
|
|
9124
|
+
function gs() {
|
|
9125
|
+
ps = null, ms = null;
|
|
8981
9126
|
}
|
|
8982
|
-
function
|
|
9127
|
+
function _s(e) {
|
|
8983
9128
|
return e?.endsWith("/") ? e.slice(0, -1) : e;
|
|
8984
9129
|
}
|
|
8985
|
-
async function
|
|
8986
|
-
let n =
|
|
9130
|
+
async function vs(e = null, t) {
|
|
9131
|
+
let n = _s(e ?? N.apiBaseUrl);
|
|
8987
9132
|
if (n) return n;
|
|
8988
9133
|
if ((t ?? N.apiEnv) !== "AUTO") return N.apiEndpoint(t);
|
|
8989
9134
|
try {
|
|
@@ -8998,25 +9143,25 @@ async function fs(e = null, t) {
|
|
|
8998
9143
|
return z.warn("Failed to resolve API endpoint using DNS, default is used", e), N.apiEndpoint(t);
|
|
8999
9144
|
}
|
|
9000
9145
|
}
|
|
9001
|
-
async function
|
|
9002
|
-
return
|
|
9146
|
+
async function ys() {
|
|
9147
|
+
return ps || ms || (ms = vs(), ps = await ms, ms = null, ps);
|
|
9003
9148
|
}
|
|
9004
|
-
async function
|
|
9149
|
+
async function bs(e, t = {}, n = !1) {
|
|
9005
9150
|
if (!window.Blob || !window.navigator.sendBeacon) return;
|
|
9006
|
-
await
|
|
9007
|
-
let r =
|
|
9008
|
-
window.navigator.sendBeacon(`${
|
|
9151
|
+
await ys();
|
|
9152
|
+
let r = Es(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
|
|
9153
|
+
window.navigator.sendBeacon(`${ps}/fb.do`, i);
|
|
9009
9154
|
}
|
|
9010
|
-
async function
|
|
9011
|
-
return await
|
|
9155
|
+
async function xs(e, t = {}, n = !1, r) {
|
|
9156
|
+
return await ys(), Cs(Es(e, t, n), r);
|
|
9012
9157
|
}
|
|
9013
|
-
async function
|
|
9014
|
-
await
|
|
9015
|
-
let r =
|
|
9016
|
-
return
|
|
9158
|
+
async function Ss(e, t = {}, n = !1) {
|
|
9159
|
+
await ys();
|
|
9160
|
+
let r = Es(e, t, n);
|
|
9161
|
+
return Cs(r, void 0, new Blob([r]).size <= hs);
|
|
9017
9162
|
}
|
|
9018
|
-
async function
|
|
9019
|
-
let r = `${t ??
|
|
9163
|
+
async function Cs(e, t, n = !1) {
|
|
9164
|
+
let r = `${t ?? ps}/fb.do`, i = new AbortController(), a = new k(x.NETWORK, { callError: {
|
|
9020
9165
|
scope: "network",
|
|
9021
9166
|
source: "api",
|
|
9022
9167
|
code: "timeout",
|
|
@@ -9035,16 +9180,16 @@ async function _s(e, t, n = !1) {
|
|
|
9035
9180
|
} catch {
|
|
9036
9181
|
o = { result: a };
|
|
9037
9182
|
}
|
|
9038
|
-
if (!t.ok && !
|
|
9183
|
+
if (!t.ok && !ws(o)) throw new k(x.API, { callError: {
|
|
9039
9184
|
scope: "server",
|
|
9040
9185
|
source: "api",
|
|
9041
9186
|
code: `http-${t.status}`,
|
|
9042
9187
|
description: "http-error"
|
|
9043
9188
|
} });
|
|
9044
|
-
if (
|
|
9189
|
+
if (ws(o)) throw o;
|
|
9045
9190
|
return o;
|
|
9046
9191
|
} catch (e) {
|
|
9047
|
-
throw e instanceof k ? e : i.signal.aborted ? a :
|
|
9192
|
+
throw e instanceof k ? e : i.signal.aborted ? a : ws(e) ? e : new k(x.NETWORK, { callError: {
|
|
9048
9193
|
scope: "network",
|
|
9049
9194
|
source: "api",
|
|
9050
9195
|
code: "fetch-failed",
|
|
@@ -9054,12 +9199,12 @@ async function _s(e, t, n = !1) {
|
|
|
9054
9199
|
clearTimeout(o);
|
|
9055
9200
|
}
|
|
9056
9201
|
}
|
|
9057
|
-
function
|
|
9202
|
+
function ws(e) {
|
|
9058
9203
|
if (typeof e != "object" || !e) return !1;
|
|
9059
9204
|
let t = e;
|
|
9060
9205
|
return typeof t.error_code == "number" && typeof t.error_msg == "string";
|
|
9061
9206
|
}
|
|
9062
|
-
async function
|
|
9207
|
+
async function Ts(e, t) {
|
|
9063
9208
|
try {
|
|
9064
9209
|
let n = await fetch(e, {
|
|
9065
9210
|
method: "POST",
|
|
@@ -9072,7 +9217,7 @@ async function ys(e, t) {
|
|
|
9072
9217
|
throw z.warn("Failed to send form data", e), e;
|
|
9073
9218
|
}
|
|
9074
9219
|
}
|
|
9075
|
-
function
|
|
9220
|
+
function Es(e, t = {}, n = !1) {
|
|
9076
9221
|
t.method = e, t.format = "JSON", t.application_key || (t.application_key = N.apiKey), n || (y.sessionKey ? t.session_key = y.sessionKey : y.accessToken && (t.access_token = y.accessToken));
|
|
9077
9222
|
for (let [e, n] of Object.entries(t)) typeof n == "object" && (t[e] = JSON.stringify(n));
|
|
9078
9223
|
let r = "";
|
|
@@ -9081,7 +9226,7 @@ function bs(e, t = {}, n = !1) {
|
|
|
9081
9226
|
}
|
|
9082
9227
|
//#endregion
|
|
9083
9228
|
//#region src/static/SessionStore.ts
|
|
9084
|
-
var
|
|
9229
|
+
var Ds = "sessions", Os = 5, ks = class e {
|
|
9085
9230
|
static remember(t, n) {
|
|
9086
9231
|
let r = e._read();
|
|
9087
9232
|
r[String(t)] = {
|
|
@@ -9089,7 +9234,7 @@ var xs = "sessions", Ss = 5, Cs = class e {
|
|
|
9089
9234
|
savedAt: Date.now()
|
|
9090
9235
|
};
|
|
9091
9236
|
let i = Object.keys(r);
|
|
9092
|
-
i.length >
|
|
9237
|
+
i.length > Os && i.sort((e, t) => r[e].savedAt - r[t].savedAt).slice(0, i.length - Os).forEach((e) => delete r[e]), e._write(r);
|
|
9093
9238
|
}
|
|
9094
9239
|
static get(t) {
|
|
9095
9240
|
return e._read()[String(t)] ?? null;
|
|
@@ -9105,10 +9250,10 @@ var xs = "sessions", Ss = 5, Cs = class e {
|
|
|
9105
9250
|
}), r && e._write(n);
|
|
9106
9251
|
}
|
|
9107
9252
|
static currentEndpoint() {
|
|
9108
|
-
return String(
|
|
9253
|
+
return String(_s(N.apiBaseUrl) || N.apiEndpoint());
|
|
9109
9254
|
}
|
|
9110
9255
|
static _read() {
|
|
9111
|
-
let t = w.get(
|
|
9256
|
+
let t = w.get(Ds);
|
|
9112
9257
|
if (!t || typeof t != "object" || Array.isArray(t)) return {};
|
|
9113
9258
|
let n = {};
|
|
9114
9259
|
return Object.entries(t).forEach(([t, r]) => {
|
|
@@ -9117,16 +9262,16 @@ var xs = "sessions", Ss = 5, Cs = class e {
|
|
|
9117
9262
|
}
|
|
9118
9263
|
static _write(e) {
|
|
9119
9264
|
if (Object.keys(e).length === 0) {
|
|
9120
|
-
w.remove(
|
|
9265
|
+
w.remove(Ds);
|
|
9121
9266
|
return;
|
|
9122
9267
|
}
|
|
9123
|
-
w.set(
|
|
9268
|
+
w.set(Ds, e);
|
|
9124
9269
|
}
|
|
9125
9270
|
static _isValid(e) {
|
|
9126
9271
|
let t = e;
|
|
9127
9272
|
return typeof t == "object" && !!t && typeof t.sessionKey == "string" && t.sessionKey.length > 0 && typeof t.endpoint == "string" && typeof t.savedAt == "number";
|
|
9128
9273
|
}
|
|
9129
|
-
},
|
|
9274
|
+
}, As = 15e3, js = class e {
|
|
9130
9275
|
static setApi(t) {
|
|
9131
9276
|
e._api = t;
|
|
9132
9277
|
}
|
|
@@ -9137,7 +9282,7 @@ var xs = "sessions", Ss = 5, Cs = class e {
|
|
|
9137
9282
|
e._delta === null && e._api && e.get();
|
|
9138
9283
|
}
|
|
9139
9284
|
static get() {
|
|
9140
|
-
return e._delta === null ? !e._api || !e._hasCredentials() || e._lastFailureAt !== null && Date.now() - e._lastFailureAt <
|
|
9285
|
+
return e._delta === null ? !e._api || !e._hasCredentials() || e._lastFailureAt !== null && Date.now() - e._lastFailureAt < As ? Promise.resolve(0) : (e._pending || (e._pending = e._measure().finally(() => {
|
|
9141
9286
|
e._pending = null;
|
|
9142
9287
|
})), e._pending) : Promise.resolve(e._delta);
|
|
9143
9288
|
}
|
|
@@ -9167,10 +9312,10 @@ var xs = "sessions", Ss = 5, Cs = class e {
|
|
|
9167
9312
|
return e._idsAwaitingDelta = [], await Q.fillDelta(n, t), t;
|
|
9168
9313
|
}
|
|
9169
9314
|
};
|
|
9170
|
-
h(
|
|
9315
|
+
h(js, "_api", null), h(js, "_delta", null), h(js, "_pending", null), h(js, "_idsAwaitingDelta", []), h(js, "_lastFailureAt", null);
|
|
9171
9316
|
//#endregion
|
|
9172
9317
|
//#region src/classes/stat/StatUnloadJournal.ts
|
|
9173
|
-
var
|
|
9318
|
+
var Ms = "okcls-stat-unload.", Ns = class e {
|
|
9174
9319
|
static beginTabSession() {
|
|
9175
9320
|
e._tabKey = null, e._entries = [];
|
|
9176
9321
|
}
|
|
@@ -9178,7 +9323,7 @@ var Es = "okcls-stat-unload.", Ds = class e {
|
|
|
9178
9323
|
let n = e._storage();
|
|
9179
9324
|
if (!n) return !1;
|
|
9180
9325
|
try {
|
|
9181
|
-
return e._tabKey || (e._tabKey =
|
|
9326
|
+
return e._tabKey || (e._tabKey = Ms + M.uuid()), e._entries.length > 0 && n.getItem(e._tabKey) === null && (e._entries = []), e._entries.push(t), n.setItem(e._tabKey, JSON.stringify(e._entries)), !0;
|
|
9182
9327
|
} catch (e) {
|
|
9183
9328
|
return z.error("[StatUnloadJournal] failed to write", e), !1;
|
|
9184
9329
|
}
|
|
@@ -9190,7 +9335,7 @@ var Es = "okcls-stat-unload.", Ds = class e {
|
|
|
9190
9335
|
try {
|
|
9191
9336
|
for (let e = 0; e < t.length; e += 1) {
|
|
9192
9337
|
let r = t.key(e);
|
|
9193
|
-
r && r.startsWith(
|
|
9338
|
+
r && r.startsWith(Ms) && n.push(r);
|
|
9194
9339
|
}
|
|
9195
9340
|
} catch (e) {
|
|
9196
9341
|
return z.error("[StatUnloadJournal] failed to scan journals", e), 0;
|
|
@@ -9233,32 +9378,32 @@ var Es = "okcls-stat-unload.", Ds = class e {
|
|
|
9233
9378
|
return typeof t == "object" && !!t && typeof t.uid == "number" && (t.vcid === null || typeof t.vcid == "string") && typeof t.ts == "number" && (t.delta === void 0 || t.delta === null || typeof t.delta == "number") && typeof t.ev == "object" && t.ev !== null;
|
|
9234
9379
|
}
|
|
9235
9380
|
};
|
|
9236
|
-
h(
|
|
9381
|
+
h(Ns, "_tabKey", null), h(Ns, "_entries", []);
|
|
9237
9382
|
//#endregion
|
|
9238
9383
|
//#region src/classes/stat/StatDrainScheduler.ts
|
|
9239
|
-
var
|
|
9384
|
+
var Ps = 500, Fs = 100, Is = 3e4, Ls = 1e3, Rs = 5e3, zs = 3e3, Bs = "okcls-stat-drain", Vs = class e {
|
|
9240
9385
|
static setApi(t) {
|
|
9241
|
-
e._api = t,
|
|
9386
|
+
e._api = t, js.setApi(t);
|
|
9242
9387
|
}
|
|
9243
9388
|
static start(t) {
|
|
9244
|
-
e.setApi(t),
|
|
9389
|
+
e.setApi(t), Ns.drainToQueue().catch((e) => z.error("[StatDrainScheduler] failed to import unload journal", e)).then(async () => (ks.prune(), await Q.evictOlderThan(us), await Q.evictToLimit(ls), e._drain())).catch((e) => z.error("[StatDrainScheduler] failed to start", e));
|
|
9245
9390
|
}
|
|
9246
9391
|
static notifyAppended() {
|
|
9247
9392
|
if (e._api) {
|
|
9248
|
-
if (e._localCount += 1, e._localCount >=
|
|
9393
|
+
if (e._localCount += 1, e._localCount >= Fs) {
|
|
9249
9394
|
e._drain();
|
|
9250
9395
|
return;
|
|
9251
9396
|
}
|
|
9252
|
-
e._state === "IDLE" && e._arm(
|
|
9397
|
+
e._state === "IDLE" && e._arm(Is);
|
|
9253
9398
|
}
|
|
9254
9399
|
}
|
|
9255
9400
|
static notifyCallFinished() {
|
|
9256
9401
|
if (e._api) {
|
|
9257
|
-
if (e._directBuffer.length > 0 && e._armDirect(
|
|
9402
|
+
if (e._directBuffer.length > 0 && e._armDirect(Ls), e._state === "DRAINING") {
|
|
9258
9403
|
e._callFinishedDuringDrain = !0;
|
|
9259
9404
|
return;
|
|
9260
9405
|
}
|
|
9261
|
-
e._arm(
|
|
9406
|
+
e._arm(Ls);
|
|
9262
9407
|
}
|
|
9263
9408
|
}
|
|
9264
9409
|
static drainOnce() {
|
|
@@ -9267,7 +9412,7 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
|
|
|
9267
9412
|
if (!t) return !1;
|
|
9268
9413
|
let n = e._currentUserId(), r = await Q.listUids(), i = !1, a = null;
|
|
9269
9414
|
for (let o of r) try {
|
|
9270
|
-
(o === n ? await e._drainCurrent(t, o) : await e._drainStored(t, o)) ===
|
|
9415
|
+
(o === n ? await e._drainCurrent(t, o) : await e._drainStored(t, o)) === Ps && (i = !0);
|
|
9271
9416
|
} catch (e) {
|
|
9272
9417
|
a === null && (a = e);
|
|
9273
9418
|
}
|
|
@@ -9281,20 +9426,20 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
|
|
|
9281
9426
|
z.error("[StatDrainScheduler] direct send skipped: event belongs to another user");
|
|
9282
9427
|
return;
|
|
9283
9428
|
}
|
|
9284
|
-
e._directBuffer.push(t), e._directTimer === null && e._armDirect(
|
|
9429
|
+
e._directBuffer.push(t), e._directTimer === null && e._armDirect(zs);
|
|
9285
9430
|
}
|
|
9286
9431
|
}
|
|
9287
9432
|
static __resetForTests() {
|
|
9288
|
-
|
|
9433
|
+
js.__resetForTests(), e._clearTimer(), e._clearDirectTimer(), e._directBuffer = [], e._api = null, e._state = "IDLE", e._localCount = 0, e._callFinishedDuringDrain = !1, e._blockedSession = null;
|
|
9289
9434
|
}
|
|
9290
9435
|
static _currentUserId() {
|
|
9291
9436
|
return y.userId;
|
|
9292
9437
|
}
|
|
9293
9438
|
static async _drainCurrent(t, n) {
|
|
9294
9439
|
if (e._isSessionBlocked()) return 0;
|
|
9295
|
-
let r = await Q.readOldest(n,
|
|
9440
|
+
let r = await Q.readOldest(n, Ps);
|
|
9296
9441
|
if (r.length === 0) return 0;
|
|
9297
|
-
let i = await
|
|
9442
|
+
let i = await js.get(), a = r.map((t) => e._toClientStats(t, i)), o = r.map((e) => e.id);
|
|
9298
9443
|
try {
|
|
9299
9444
|
await t.logClientStats(a);
|
|
9300
9445
|
} catch (t) {
|
|
@@ -9305,25 +9450,25 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
|
|
|
9305
9450
|
return await Q.remove(o), r.length;
|
|
9306
9451
|
}
|
|
9307
9452
|
static async _drainStored(t, n) {
|
|
9308
|
-
let r =
|
|
9309
|
-
if (!r || r.endpoint !==
|
|
9310
|
-
let i = await Q.readOldest(n,
|
|
9453
|
+
let r = ks.get(n);
|
|
9454
|
+
if (!r || r.endpoint !== ks.currentEndpoint()) return 0;
|
|
9455
|
+
let i = await Q.readOldest(n, Ps);
|
|
9311
9456
|
if (i.length === 0) return 0;
|
|
9312
|
-
let a = await
|
|
9457
|
+
let a = await js.get(), o = i.map((t) => e._toClientStats(t, a)), s = i.map((e) => e.id);
|
|
9313
9458
|
try {
|
|
9314
9459
|
await t.logClientStatsWith(r.sessionKey, o), z.debug("[StatDrainScheduler] delivered", i.length, "stored events of uid", n);
|
|
9315
9460
|
} catch (t) {
|
|
9316
|
-
if (e._isAuthError(t)) return z.error("[StatDrainScheduler] stored session expired, skipping uid", n),
|
|
9461
|
+
if (e._isAuthError(t)) return z.error("[StatDrainScheduler] stored session expired, skipping uid", n), ks.forget(n), 0;
|
|
9317
9462
|
if (e._isRetryable(t)) throw t;
|
|
9318
9463
|
return z.error("[StatDrainScheduler] batch rejected, dropping", t), await Q.remove(s), i.length;
|
|
9319
9464
|
}
|
|
9320
9465
|
return await Q.remove(s), i.length;
|
|
9321
9466
|
}
|
|
9322
9467
|
static _withLock(e) {
|
|
9323
|
-
return typeof navigator > "u" || !navigator.locks ? e() : navigator.locks.request(
|
|
9468
|
+
return typeof navigator > "u" || !navigator.locks ? e() : navigator.locks.request(Bs, e);
|
|
9324
9469
|
}
|
|
9325
9470
|
static _isSessionError(e) {
|
|
9326
|
-
return
|
|
9471
|
+
return rs(e?.error_code);
|
|
9327
9472
|
}
|
|
9328
9473
|
static _isReauthorizeFailure(e) {
|
|
9329
9474
|
return e?.error === x.AUTH;
|
|
@@ -9336,7 +9481,7 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
|
|
|
9336
9481
|
}
|
|
9337
9482
|
static _isAuthError(t) {
|
|
9338
9483
|
let n = t?.error_code;
|
|
9339
|
-
return e._isSessionError(t) || n ===
|
|
9484
|
+
return e._isSessionError(t) || n === ns.AUTH_LOGIN;
|
|
9340
9485
|
}
|
|
9341
9486
|
static _isRetryable(t) {
|
|
9342
9487
|
if (e._isSessionError(t)) return !0;
|
|
@@ -9361,7 +9506,7 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
|
|
|
9361
9506
|
static async _flushDirect() {
|
|
9362
9507
|
let t = e._api, n = e._directBuffer;
|
|
9363
9508
|
if (e._directBuffer = [], !(!t || n.length === 0)) try {
|
|
9364
|
-
let r = await
|
|
9509
|
+
let r = await js.get();
|
|
9365
9510
|
await t.logClientStats(n.map((t) => e._toClientStats(t, r)));
|
|
9366
9511
|
} catch (e) {
|
|
9367
9512
|
z.error("[StatDrainScheduler] direct send failed, events lost", e);
|
|
@@ -9380,28 +9525,28 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
|
|
|
9380
9525
|
e._clearTimer(), e._state = "DRAINING", e._localCount = 0, e._callFinishedDuringDrain = !1;
|
|
9381
9526
|
try {
|
|
9382
9527
|
if (await e.drainOnce()) {
|
|
9383
|
-
e._arm(
|
|
9528
|
+
e._arm(Rs);
|
|
9384
9529
|
return;
|
|
9385
9530
|
}
|
|
9386
9531
|
if (e._callFinishedDuringDrain) {
|
|
9387
|
-
e._arm(
|
|
9532
|
+
e._arm(Ls);
|
|
9388
9533
|
return;
|
|
9389
9534
|
}
|
|
9390
9535
|
if (e._localCount > 0) {
|
|
9391
|
-
e._arm(
|
|
9536
|
+
e._arm(Is);
|
|
9392
9537
|
return;
|
|
9393
9538
|
}
|
|
9394
9539
|
e._state = "IDLE";
|
|
9395
9540
|
} catch (t) {
|
|
9396
|
-
z.error("[StatDrainScheduler] drain failed", t), e._arm(
|
|
9541
|
+
z.error("[StatDrainScheduler] drain failed", t), e._arm(Is);
|
|
9397
9542
|
}
|
|
9398
9543
|
}
|
|
9399
9544
|
}
|
|
9400
9545
|
};
|
|
9401
|
-
h(
|
|
9546
|
+
h(Vs, "_api", null), h(Vs, "_state", "IDLE"), h(Vs, "_timer", null), h(Vs, "_localCount", 0), h(Vs, "_callFinishedDuringDrain", !1), h(Vs, "_blockedSession", null), h(Vs, "_directBuffer", []), h(Vs, "_directTimer", null);
|
|
9402
9547
|
//#endregion
|
|
9403
9548
|
//#region src/classes/StatsLogger.ts
|
|
9404
|
-
var
|
|
9549
|
+
var Hs = class extends f {
|
|
9405
9550
|
constructor(e, t, n, r = () => void 0) {
|
|
9406
9551
|
super(), h(this, "_externalLogger", void 0), h(this, "_api", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_topologyProvider", void 0), h(this, "_batchInterval", 3e3), h(this, "_batchedClientStats", []), h(this, "_batchTimeout", null), h(this, "_serverTimeDelta", 0), h(this, "_waitingForServerTime", !0), h(this, "_deferredClientStats", []), this._api = e, this._externalLogger = t, this._conversationIdProvider = n, this._topologyProvider = r, this._calculateServerTimeDelta();
|
|
9407
9552
|
}
|
|
@@ -9481,7 +9626,7 @@ var Is = class extends f {
|
|
|
9481
9626
|
_now() {
|
|
9482
9627
|
return Date.now() - this._serverTimeDelta;
|
|
9483
9628
|
}
|
|
9484
|
-
},
|
|
9629
|
+
}, Us = class e extends f {
|
|
9485
9630
|
static __resetForTests() {
|
|
9486
9631
|
e._pending = [], e._pendingOverflow = !1;
|
|
9487
9632
|
}
|
|
@@ -9497,17 +9642,17 @@ var Is = class extends f {
|
|
|
9497
9642
|
return e._pending = [], e._pendingOverflow = !1, t;
|
|
9498
9643
|
}
|
|
9499
9644
|
constructor(e, t, n, r = () => void 0) {
|
|
9500
|
-
super(), h(this, "_externalLogger", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_topologyProvider", void 0), h(this, "_unloadMode", !1), h(this, "_legacy", void 0), this._externalLogger = t, this._conversationIdProvider = n, this._topologyProvider = r, this._legacy = N.statQueueEnabled ? null : new
|
|
9645
|
+
super(), h(this, "_externalLogger", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_topologyProvider", void 0), h(this, "_unloadMode", !1), h(this, "_legacy", void 0), this._externalLogger = t, this._conversationIdProvider = n, this._topologyProvider = r, this._legacy = N.statQueueEnabled ? null : new Hs(e, t, n, r);
|
|
9501
9646
|
}
|
|
9502
9647
|
log(e, t, n = !1) {
|
|
9503
9648
|
this._externalLogger && this._externalLogger.log(e, t, n);
|
|
9504
9649
|
}
|
|
9505
9650
|
enterUnloadMode() {
|
|
9506
|
-
this._legacy || (this._unloadMode = !0,
|
|
9651
|
+
this._legacy || (this._unloadMode = !0, Ns.beginTabSession());
|
|
9507
9652
|
}
|
|
9508
9653
|
exitUnloadMode() {
|
|
9509
|
-
this._legacy || !this._unloadMode || (this._unloadMode = !1,
|
|
9510
|
-
e > 0 &&
|
|
9654
|
+
this._legacy || !this._unloadMode || (this._unloadMode = !1, Ns.drainToQueue().then((e) => {
|
|
9655
|
+
e > 0 && Vs.notifyAppended();
|
|
9511
9656
|
}).catch((e) => z.error("[StatEventCollector] failed to import unload journal", e)));
|
|
9512
9657
|
}
|
|
9513
9658
|
logClientStats(t, n = {}) {
|
|
@@ -9526,11 +9671,11 @@ var Is = class extends f {
|
|
|
9526
9671
|
};
|
|
9527
9672
|
Object.keys(a).forEach((e) => {
|
|
9528
9673
|
a[e] === void 0 && delete a[e];
|
|
9529
|
-
}),
|
|
9674
|
+
}), js.ensure();
|
|
9530
9675
|
let o = {
|
|
9531
9676
|
vcid: r,
|
|
9532
9677
|
ts: i,
|
|
9533
|
-
delta:
|
|
9678
|
+
delta: js.delta(),
|
|
9534
9679
|
ev: a
|
|
9535
9680
|
}, s = y.userId;
|
|
9536
9681
|
if (s === null) {
|
|
@@ -9553,12 +9698,12 @@ var Is = class extends f {
|
|
|
9553
9698
|
}
|
|
9554
9699
|
}
|
|
9555
9700
|
_store(e) {
|
|
9556
|
-
this._unloadMode &&
|
|
9701
|
+
this._unloadMode && Ns.writeSync(e) || Q.append(e).then((t) => {
|
|
9557
9702
|
if (t !== null) {
|
|
9558
|
-
typeof e.delta != "number" &&
|
|
9703
|
+
typeof e.delta != "number" && js.noteAppended(t), Vs.notifyAppended();
|
|
9559
9704
|
return;
|
|
9560
9705
|
}
|
|
9561
|
-
z.error("[StatEventCollector] failed to store event, sending directly"),
|
|
9706
|
+
z.error("[StatEventCollector] failed to store event, sending directly"), Vs.sendDirect(e);
|
|
9562
9707
|
}).catch((e) => z.error("[StatEventCollector] failed to store event", e));
|
|
9563
9708
|
}
|
|
9564
9709
|
_getConversationId() {
|
|
@@ -9576,10 +9721,10 @@ var Is = class extends f {
|
|
|
9576
9721
|
}
|
|
9577
9722
|
}
|
|
9578
9723
|
};
|
|
9579
|
-
h(
|
|
9724
|
+
h(Us, "_pending", []), h(Us, "_pendingOverflow", !1);
|
|
9580
9725
|
//#endregion
|
|
9581
9726
|
//#region src/classes/stat/ApiCallStats.ts
|
|
9582
|
-
var
|
|
9727
|
+
var Ws = class {
|
|
9583
9728
|
constructor(e) {
|
|
9584
9729
|
h(this, "_statAggregator", void 0), this._statAggregator = e;
|
|
9585
9730
|
}
|
|
@@ -9591,7 +9736,7 @@ var Rs = class {
|
|
|
9591
9736
|
string_value: n
|
|
9592
9737
|
});
|
|
9593
9738
|
}
|
|
9594
|
-
},
|
|
9739
|
+
}, Gs = "invalid-error-metadata", Ks = 64, qs = new Set(Object.values(O)), Js = new Set(Object.values(x)), Ys = {
|
|
9595
9740
|
[O.CANCELED]: {
|
|
9596
9741
|
type: "semantic",
|
|
9597
9742
|
reason: "canceled"
|
|
@@ -9712,7 +9857,7 @@ var Rs = class {
|
|
|
9712
9857
|
type: "semantic",
|
|
9713
9858
|
reason: "obsolete_client"
|
|
9714
9859
|
}
|
|
9715
|
-
},
|
|
9860
|
+
}, Xs = {
|
|
9716
9861
|
[x.MIC_CAMERA_PERMISSION]: {
|
|
9717
9862
|
type: "direct-error",
|
|
9718
9863
|
error: {
|
|
@@ -9801,14 +9946,14 @@ var Rs = class {
|
|
|
9801
9946
|
}
|
|
9802
9947
|
}
|
|
9803
9948
|
};
|
|
9804
|
-
function
|
|
9805
|
-
if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return
|
|
9949
|
+
function Zs(e) {
|
|
9950
|
+
if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return Gs;
|
|
9806
9951
|
let t = String(e).trim();
|
|
9807
|
-
if (!t) return
|
|
9952
|
+
if (!t) return Gs;
|
|
9808
9953
|
let n = t.toLowerCase().replace(/[\s_:]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
9809
|
-
return !n || !/^[a-z0-9.-]+$/.test(n) ?
|
|
9954
|
+
return !n || !/^[a-z0-9.-]+$/.test(n) ? Gs : n.length > Ks ? `${n.slice(0, Ks - 3)}...` : n;
|
|
9810
9955
|
}
|
|
9811
|
-
function
|
|
9956
|
+
function Qs(e) {
|
|
9812
9957
|
if (!e || typeof e != "object") return !1;
|
|
9813
9958
|
let t = e;
|
|
9814
9959
|
switch (t.scope) {
|
|
@@ -9820,49 +9965,49 @@ function Ks(e) {
|
|
|
9820
9965
|
default: return !1;
|
|
9821
9966
|
}
|
|
9822
9967
|
}
|
|
9823
|
-
function
|
|
9824
|
-
let t =
|
|
9968
|
+
function $s(e) {
|
|
9969
|
+
let t = Zs(e.description);
|
|
9825
9970
|
if (e.scope === "unknown") return `unknown:${t}`;
|
|
9826
|
-
let n =
|
|
9971
|
+
let n = Zs(e.code);
|
|
9827
9972
|
return e.scope === "internal" ? `internal:${n}:${t}` : `${e.scope}:${e.source}:${n}:${t}`;
|
|
9828
9973
|
}
|
|
9829
|
-
function
|
|
9974
|
+
function ec(e, t) {
|
|
9830
9975
|
return t === null ? e.type === "direct-error" ? {
|
|
9831
9976
|
reason: "error",
|
|
9832
|
-
string_value:
|
|
9833
|
-
} : { reason: "failed" } :
|
|
9977
|
+
string_value: $s(e.error)
|
|
9978
|
+
} : { reason: "failed" } : Qs(t) ? {
|
|
9834
9979
|
reason: "error",
|
|
9835
|
-
string_value:
|
|
9980
|
+
string_value: $s(t)
|
|
9836
9981
|
} : { reason: "failed" };
|
|
9837
9982
|
}
|
|
9838
|
-
function
|
|
9983
|
+
function tc(e) {
|
|
9839
9984
|
if (e.hangup) {
|
|
9840
|
-
let t =
|
|
9985
|
+
let t = Ys[e.hangup];
|
|
9841
9986
|
return t ? t.type === "semantic" ? e.hangup === O.OBSOLETE_CLIENT && e.custom_error?.vchat_detailed_api_error.code ? {
|
|
9842
9987
|
reason: t.reason,
|
|
9843
9988
|
string_value: e.custom_error.vchat_detailed_api_error.code
|
|
9844
|
-
} : { reason: t.reason } :
|
|
9989
|
+
} : { reason: t.reason } : ec(t, e.callError) : { reason: "failed" };
|
|
9845
9990
|
}
|
|
9846
9991
|
if (e.error) {
|
|
9847
|
-
let t =
|
|
9848
|
-
return t ?
|
|
9992
|
+
let t = Xs[e.error];
|
|
9993
|
+
return t ? ec(t, e.callError) : { reason: "failed" };
|
|
9849
9994
|
}
|
|
9850
9995
|
return { reason: "failed" };
|
|
9851
9996
|
}
|
|
9852
|
-
function
|
|
9853
|
-
return e instanceof k ?
|
|
9997
|
+
function nc(e) {
|
|
9998
|
+
return e instanceof k ? tc(e) : typeof e == "string" && (qs.has(e) || Js.has(e)) ? tc(new k(e)) : { reason: "failed" };
|
|
9854
9999
|
}
|
|
9855
10000
|
//#endregion
|
|
9856
10001
|
//#region src/classes/stat/CallLifecycleStats.ts
|
|
9857
|
-
var
|
|
10002
|
+
var rc = {
|
|
9858
10003
|
wallNow: () => Date.now(),
|
|
9859
10004
|
monotonicNow: () => performance.now()
|
|
9860
10005
|
};
|
|
9861
|
-
function
|
|
10006
|
+
function ic(e) {
|
|
9862
10007
|
return e === "anonym_join" ? "join" : e;
|
|
9863
10008
|
}
|
|
9864
|
-
var
|
|
9865
|
-
constructor(e, t =
|
|
10009
|
+
var ac = class {
|
|
10010
|
+
constructor(e, t = rc) {
|
|
9866
10011
|
h(this, "_logger", void 0), h(this, "_clock", void 0), h(this, "_conversationId", null), h(this, "_callStartLabel", null), h(this, "_lifecycleStartedAtMonotonic", 0), h(this, "_pendingEvents", []), h(this, "_callStarted", !1), h(this, "_accepted", !1), h(this, "_firstMediaSent", !1), h(this, "_finished", !1), h(this, "_destroyed", !1), this._logger = e, this._clock = t;
|
|
9867
10012
|
}
|
|
9868
10013
|
get firstMediaSentReported() {
|
|
@@ -9874,7 +10019,7 @@ var $s = class {
|
|
|
9874
10019
|
markInitializationStarted({ source: e, conversationId: t }) {
|
|
9875
10020
|
if (this._destroyed || this._callStartLabel !== null) return;
|
|
9876
10021
|
let n = this._clock.wallNow();
|
|
9877
|
-
this._callStartLabel =
|
|
10022
|
+
this._callStartLabel = ic(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
|
|
9878
10023
|
name: U.CALL_INIT,
|
|
9879
10024
|
source: e
|
|
9880
10025
|
}, n);
|
|
@@ -9902,7 +10047,7 @@ var $s = class {
|
|
|
9902
10047
|
!this._canRecord() || this._firstMediaSent || (this._firstMediaSent = !0, this._record({ name: U.FIRST_MEDIA_SENT }));
|
|
9903
10048
|
}
|
|
9904
10049
|
markFinished(e) {
|
|
9905
|
-
this._finish(
|
|
10050
|
+
this._finish(nc(e));
|
|
9906
10051
|
}
|
|
9907
10052
|
markTerminated() {
|
|
9908
10053
|
this._finish({ reason: "terminated" });
|
|
@@ -9953,7 +10098,7 @@ var $s = class {
|
|
|
9953
10098
|
...n && { immediately: !0 }
|
|
9954
10099
|
});
|
|
9955
10100
|
}
|
|
9956
|
-
},
|
|
10101
|
+
}, oc = class {
|
|
9957
10102
|
constructor(e, t) {
|
|
9958
10103
|
h(this, "_logger", void 0), h(this, "_codecUsages", /* @__PURE__ */ new Map()), h(this, "getCurrentTransportTopology", void 0), this._logger = e, this.getCurrentTransportTopology = t;
|
|
9959
10104
|
}
|
|
@@ -10016,45 +10161,7 @@ var $s = class {
|
|
|
10016
10161
|
this.report(e);
|
|
10017
10162
|
}), this._codecUsages.clear();
|
|
10018
10163
|
}
|
|
10019
|
-
},
|
|
10020
|
-
constructor(e) {
|
|
10021
|
-
h(this, "_statAggregator", void 0), this._statAggregator = e;
|
|
10022
|
-
}
|
|
10023
|
-
logAudioError(e, t) {
|
|
10024
|
-
this._statAggregator?.logEventualStat({
|
|
10025
|
-
name: U.AUDIO_ERROR,
|
|
10026
|
-
value: nc(t),
|
|
10027
|
-
string_value: rc(t) ? `${e}: ${rc(t)}` : e
|
|
10028
|
-
});
|
|
10029
|
-
}
|
|
10030
|
-
logMlReady(e, t) {
|
|
10031
|
-
this._statAggregator?.logEventualStat({
|
|
10032
|
-
name: U.ML_READY_TO_USE,
|
|
10033
|
-
value: Math.round(t),
|
|
10034
|
-
source: e
|
|
10035
|
-
});
|
|
10036
|
-
}
|
|
10037
|
-
logMlError(e, t) {
|
|
10038
|
-
this._statAggregator?.logEventualStat({
|
|
10039
|
-
name: U.ML_ERROR,
|
|
10040
|
-
value: nc(t),
|
|
10041
|
-
source: e,
|
|
10042
|
-
string_value: ic(t)
|
|
10043
|
-
});
|
|
10044
|
-
}
|
|
10045
|
-
};
|
|
10046
|
-
function nc(e) {
|
|
10047
|
-
return e instanceof DOMException ? e.code : 0;
|
|
10048
|
-
}
|
|
10049
|
-
function rc(e) {
|
|
10050
|
-
return e instanceof Error ? e.name : "";
|
|
10051
|
-
}
|
|
10052
|
-
function ic(e) {
|
|
10053
|
-
return e instanceof Error ? `${e.name}: ${e.message}` : typeof e == "string" ? e : "";
|
|
10054
|
-
}
|
|
10055
|
-
//#endregion
|
|
10056
|
-
//#region src/classes/stat/StatAggregator.ts
|
|
10057
|
-
var ac = class {
|
|
10164
|
+
}, sc = class {
|
|
10058
10165
|
constructor(e) {
|
|
10059
10166
|
h(this, "_logger", void 0), h(this, "_eventualLogs", /* @__PURE__ */ new Set()), h(this, "_lastCallStatContext", null), this._logger = e;
|
|
10060
10167
|
}
|
|
@@ -10097,7 +10204,7 @@ var ac = class {
|
|
|
10097
10204
|
for (let [t, r] of Object.entries(e)) r !== void 0 && (r === null ? delete n[t] : n[t] = r);
|
|
10098
10205
|
this._logger.logClientStats(n, { occurredAt: t });
|
|
10099
10206
|
}
|
|
10100
|
-
},
|
|
10207
|
+
}, cc = class {
|
|
10101
10208
|
constructor(e) {
|
|
10102
10209
|
if (h(this, "q", void 0), h(this, "inits", []), h(this, "n", [
|
|
10103
10210
|
1,
|
|
@@ -10156,7 +10263,7 @@ var ac = class {
|
|
|
10156
10263
|
5
|
|
10157
10264
|
];
|
|
10158
10265
|
}
|
|
10159
|
-
},
|
|
10266
|
+
}, lc = class {
|
|
10160
10267
|
constructor() {
|
|
10161
10268
|
h(this, "n", 0), h(this, "mean", 0);
|
|
10162
10269
|
}
|
|
@@ -10168,9 +10275,9 @@ var ac = class {
|
|
|
10168
10275
|
get avg() {
|
|
10169
10276
|
return this.n ? this.mean : NaN;
|
|
10170
10277
|
}
|
|
10171
|
-
},
|
|
10278
|
+
}, uc = class {
|
|
10172
10279
|
constructor() {
|
|
10173
|
-
h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new
|
|
10280
|
+
h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new lc()), h(this, "p50", new cc(.5)), h(this, "p95", new cc(.95));
|
|
10174
10281
|
}
|
|
10175
10282
|
add(e) {
|
|
10176
10283
|
e < this.minVal && (this.minVal = e), e > this.maxVal && (this.maxVal = e), this.mean.add(e), this.p50.add(e), this.p95.add(e), this.count++;
|
|
@@ -10188,11 +10295,11 @@ var ac = class {
|
|
|
10188
10295
|
get hasData() {
|
|
10189
10296
|
return this.count > 0;
|
|
10190
10297
|
}
|
|
10191
|
-
},
|
|
10298
|
+
}, dc = class {
|
|
10192
10299
|
constructor(e) {
|
|
10193
10300
|
h(this, "_logger", void 0), h(this, "trackerByTransport", {
|
|
10194
|
-
ws: new
|
|
10195
|
-
wt: new
|
|
10301
|
+
ws: new uc(),
|
|
10302
|
+
wt: new uc()
|
|
10196
10303
|
}), h(this, "lastSeen", {}), this._logger = e;
|
|
10197
10304
|
}
|
|
10198
10305
|
mark(e) {
|
|
@@ -10221,17 +10328,17 @@ var ac = class {
|
|
|
10221
10328
|
}
|
|
10222
10329
|
destroy() {
|
|
10223
10330
|
this.trackerByTransport = {
|
|
10224
|
-
ws: new
|
|
10225
|
-
wt: new
|
|
10331
|
+
ws: new uc(),
|
|
10332
|
+
wt: new uc()
|
|
10226
10333
|
}, this.lastSeen = {};
|
|
10227
10334
|
}
|
|
10228
|
-
},
|
|
10335
|
+
}, fc = class {
|
|
10229
10336
|
constructor(e) {
|
|
10230
10337
|
h(this, "_logger", void 0), h(this, "trackerByCommand", /* @__PURE__ */ new Map()), this._logger = e;
|
|
10231
10338
|
}
|
|
10232
10339
|
mark(e, t, n) {
|
|
10233
10340
|
let r = `${e}|${n}`, i;
|
|
10234
|
-
this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new
|
|
10341
|
+
this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new uc(), this.trackerByCommand.set(r, i)), i.add(t);
|
|
10235
10342
|
}
|
|
10236
10343
|
logMetrics() {
|
|
10237
10344
|
for (let [e, t] of this.trackerByCommand.entries()) {
|
|
@@ -10253,9 +10360,9 @@ var ac = class {
|
|
|
10253
10360
|
destroy() {
|
|
10254
10361
|
this.trackerByCommand.clear();
|
|
10255
10362
|
}
|
|
10256
|
-
},
|
|
10363
|
+
}, pc = class {
|
|
10257
10364
|
constructor(e, t, n, r) {
|
|
10258
|
-
h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), h(this, "apiCalls", void 0), h(this, "
|
|
10365
|
+
h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), h(this, "apiCalls", void 0), h(this, "_api", void 0), h(this, "_unloading", !1), this.logger = new Us(e, t, n, r), this.lifecycle = new ac(this.logger), this.statAggregator = new sc(this.logger), this.codecStatsAggregator = new oc(this.logger, r), this.pings = new dc(this.logger), this.signalingCommands = new fc(this.logger), this.apiCalls = new Ws(this.statAggregator), this._api = e, this._api.setApiCallStats(this.apiCalls);
|
|
10259
10366
|
}
|
|
10260
10367
|
prepareForUnload() {
|
|
10261
10368
|
N.statQueueEnabled && (this._unloading = !0, this.logger.enterUnloadMode(), this.pings.logMetrics(), this.signalingCommands.logMetrics());
|
|
@@ -10270,9 +10377,9 @@ var ac = class {
|
|
|
10270
10377
|
this.codecStatsAggregator.destroy(), this.pings.logMetrics(), this.pings.destroy(), this.signalingCommands.logMetrics(), this.signalingCommands.destroy();
|
|
10271
10378
|
}
|
|
10272
10379
|
destroy() {
|
|
10273
|
-
this._api.setApiCallStats(null), this.lifecycle.markTerminated(), this.lifecycle.destroy(), this.statAggregator.destroy(), this.codecStatsAggregator.destroy(), this.pings.destroy(), this.signalingCommands.destroy(), this.logger.destroy(), N.statQueueEnabled && !this._unloading &&
|
|
10380
|
+
this._api.setApiCallStats(null), this.lifecycle.markTerminated(), this.lifecycle.destroy(), this.statAggregator.destroy(), this.codecStatsAggregator.destroy(), this.pings.destroy(), this.signalingCommands.destroy(), this.logger.destroy(), N.statQueueEnabled && !this._unloading && Vs.notifyCallFinished();
|
|
10274
10381
|
}
|
|
10275
|
-
},
|
|
10382
|
+
}, mc = class {
|
|
10276
10383
|
constructor(e) {
|
|
10277
10384
|
h(this, "_statAggregator", void 0), h(this, "_isCallMarked", !1), h(this, "_isFinished", !1), h(this, "_callType", null), this._statAggregator = e;
|
|
10278
10385
|
}
|
|
@@ -10297,8 +10404,8 @@ var ac = class {
|
|
|
10297
10404
|
call_type: this._callType
|
|
10298
10405
|
}));
|
|
10299
10406
|
}
|
|
10300
|
-
},
|
|
10301
|
-
function
|
|
10407
|
+
}, hc = 1e3, gc = 1e4;
|
|
10408
|
+
function _c(e, t, n, r) {
|
|
10302
10409
|
return new k(e, {
|
|
10303
10410
|
callError: {
|
|
10304
10411
|
scope: "external",
|
|
@@ -10309,11 +10416,11 @@ function hc(e, t, n, r) {
|
|
|
10309
10416
|
message: r
|
|
10310
10417
|
});
|
|
10311
10418
|
}
|
|
10312
|
-
var
|
|
10419
|
+
var vc = 15, $ = class e extends b {
|
|
10313
10420
|
constructor(e, t) {
|
|
10314
|
-
super(), h(this, "_api", void 0), h(this, "_signaling", void 0), h(this, "_signalingActor", void 0), h(this, "_displayLayoutRequester", void 0), h(this, "_mediaSource", null), h(this, "_conversation", null), h(this, "_myLastRequestedLayouts", {}), h(this, "_state", "IDLE"), h(this, "_previousState", null), h(this, "_waitingHallHoldPending", !1), h(this, "_participantState", X.CALLED), h(this, "_participants", {}), h(this, "_directTransportIsMaster", void 0), h(this, "_transport", null), h(this, "_debugInfo", null), h(this, "_debug", z.createSessionLogger()), h(this, "_volumesDetector", null), h(this, "_speakerDetector", null), h(this, "_localVolumeDetector", null), h(this, "_specListener", null), h(this, "_activeSpeakerId", null), h(this, "_lastSignalledActiveSpeakerId", null), h(this, "_isRealTimeAsrRequested", !1), h(this, "_serverSettings", Mr()), h(this, "_serverTimeOffset", 0), h(this, "_delayedHangup", !1), h(this, "_onFastHangup", void 0), h(this, "_hangupEmitted", !1), h(this, "_hangupPromise", null), h(this, "_abortController", null), h(this, "_registeredPeerReceived", !1), h(this, "_calleeUnavailableTimer", null), h(this, "_reservedId", null), h(this, "_onUnload", void 0), h(this, "_onRestore", void 0), h(this, "_audioOutput", void 0), h(this, "_stats", void 0), h(this, "_lastStalled", {}), h(this, "_audioMixStalled", !1), h(this, "_audioFix", null), h(this, "_streamByStreamId", /* @__PURE__ */ new Map()), h(this, "_streamIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_streamWaitTimerByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_sequenceNumberByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownTimestampByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownQueueCleanupTimer", null), h(this, "_statFirstMediaReceived", void 0), h(this, "_toggleLocalVideo",
|
|
10421
|
+
super(), h(this, "_api", void 0), h(this, "_signaling", void 0), h(this, "_signalingActor", void 0), h(this, "_displayLayoutRequester", void 0), h(this, "_mediaSource", null), h(this, "_conversation", null), h(this, "_myLastRequestedLayouts", {}), h(this, "_state", "IDLE"), h(this, "_previousState", null), h(this, "_waitingHallHoldPending", !1), h(this, "_participantState", X.CALLED), h(this, "_participants", {}), h(this, "_directTransportIsMaster", void 0), h(this, "_transport", null), h(this, "_debugInfo", null), h(this, "_debug", z.createSessionLogger()), h(this, "_volumesDetector", null), h(this, "_speakerDetector", null), h(this, "_localVolumeDetector", null), h(this, "_specListener", null), h(this, "_activeSpeakerId", null), h(this, "_lastSignalledActiveSpeakerId", null), h(this, "_isRealTimeAsrRequested", !1), h(this, "_serverSettings", Mr()), h(this, "_serverTimeOffset", 0), h(this, "_delayedHangup", !1), h(this, "_onFastHangup", void 0), h(this, "_hangupEmitted", !1), h(this, "_hangupPromise", null), h(this, "_abortController", null), h(this, "_registeredPeerReceived", !1), h(this, "_calleeUnavailableTimer", null), h(this, "_reservedId", null), h(this, "_onUnload", void 0), h(this, "_onRestore", void 0), h(this, "_audioOutput", void 0), h(this, "_stats", void 0), h(this, "_lastStalled", {}), h(this, "_audioMixStalled", !1), h(this, "_audioFix", null), h(this, "_streamByStreamId", /* @__PURE__ */ new Map()), h(this, "_streamIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_streamWaitTimerByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_sequenceNumberByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownTimestampByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownQueueCleanupTimer", null), h(this, "_statFirstMediaReceived", void 0), h(this, "_toggleLocalVideo", Fo((e) => {
|
|
10315
10422
|
if (this._mediaSource) return this._stats.logger.log(C.MEDIA_STATUS, e ? "video_1" : "video_0"), this._mediaSource.toggleVideo(e);
|
|
10316
|
-
})), h(this, "_toggleLocalAudio",
|
|
10423
|
+
})), h(this, "_toggleLocalAudio", Fo((e) => {
|
|
10317
10424
|
if (this._mediaSource) return this._stats.logger.log(C.MEDIA_STATUS, e ? "audio_1" : "audio_0"), this._mediaSource.toggleAudio(e);
|
|
10318
10425
|
})), h(this, "_changeMediaSettings", M.debounce(async (e) => {
|
|
10319
10426
|
if (this._signaling.ready) try {
|
|
@@ -10325,7 +10432,7 @@ var gc = 15, $ = class e extends b {
|
|
|
10325
10432
|
captureAudio: !1
|
|
10326
10433
|
});
|
|
10327
10434
|
}
|
|
10328
|
-
}, 100)), this._stats = new
|
|
10435
|
+
}, 100)), this._stats = new pc(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new oo(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new Jo(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new Wo({
|
|
10329
10436
|
api: this._api,
|
|
10330
10437
|
debug: this._debug,
|
|
10331
10438
|
getParticipants: () => this._participants,
|
|
@@ -10336,13 +10443,13 @@ var gc = 15, $ = class e extends b {
|
|
|
10336
10443
|
this._stopFirstMediaSentProbe(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? O.CANCELED : O.HUNGUP), this._stats.prepareForUnload(), this._stats.destroy();
|
|
10337
10444
|
}, this._onRestore = () => {
|
|
10338
10445
|
this._stats.restoreAfterUnload();
|
|
10339
|
-
}, window.addEventListener("pagehide", this._onUnload), window.addEventListener("pageshow", this._onRestore), this._statFirstMediaReceived = new
|
|
10446
|
+
}, window.addEventListener("pagehide", this._onUnload), window.addEventListener("pageshow", this._onRestore), this._statFirstMediaReceived = new mc(this._stats.statAggregator), this._audioOutput = new Lo(this._statFirstMediaReceived, N.transparentAudio, this._debug, this._stats.logger), N.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), hc));
|
|
10340
10447
|
}
|
|
10341
10448
|
static current() {
|
|
10342
10449
|
return B.getActive() ?? (N.hold ? null : B.getFirst());
|
|
10343
10450
|
}
|
|
10344
10451
|
static hangupAfterInit(e) {
|
|
10345
|
-
let t =
|
|
10452
|
+
let t = yc;
|
|
10346
10453
|
if (t) {
|
|
10347
10454
|
if (typeof e == "function" && (t._onFastHangup = e), t._delayedHangup === !1 && !t._conversation) {
|
|
10348
10455
|
t._delayedHangup = !0, t._abortController?.abort(new k(O.CANCELED));
|
|
@@ -10370,7 +10477,7 @@ var gc = 15, $ = class e extends b {
|
|
|
10370
10477
|
return this._state === "HELD";
|
|
10371
10478
|
}
|
|
10372
10479
|
get isIncomingRinging() {
|
|
10373
|
-
return this._conversation?.direction ===
|
|
10480
|
+
return this._conversation?.direction === so.INCOMING && this._state === "IDLE";
|
|
10374
10481
|
}
|
|
10375
10482
|
static debugSessionId() {
|
|
10376
10483
|
return e.current()?.debugSessionId ?? null;
|
|
@@ -10396,7 +10503,7 @@ var gc = 15, $ = class e extends b {
|
|
|
10396
10503
|
R.onNonFatalError(Error(e), this.id);
|
|
10397
10504
|
}
|
|
10398
10505
|
getIncomingCallerExternalId() {
|
|
10399
|
-
return this._conversation?.direction ===
|
|
10506
|
+
return this._conversation?.direction === so.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
|
|
10400
10507
|
}
|
|
10401
10508
|
_buildInternalParams() {
|
|
10402
10509
|
let e = {
|
|
@@ -10406,24 +10513,24 @@ var gc = 15, $ = class e extends b {
|
|
|
10406
10513
|
platform: N.platform,
|
|
10407
10514
|
protocolVersion: N.protocolVersion,
|
|
10408
10515
|
domainId: N.domain,
|
|
10409
|
-
capabilities:
|
|
10516
|
+
capabilities: Va.getFlags()
|
|
10410
10517
|
};
|
|
10411
10518
|
return JSON.stringify(e);
|
|
10412
10519
|
}
|
|
10413
10520
|
async onStart({ opponentIds: e, opponentType: t, mediaOptions: n, payload: r = "", joiningAllowed: i = !1, requireAuthToJoin: a = !1, onlyAdminCanShareMovie: o, externalIds: s, onFastStart: c, conversationId: l }) {
|
|
10414
|
-
let u = l ?? M.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t ===
|
|
10521
|
+
let u = l ?? M.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t === co.USER && d === 1 ? N.calleeUnavailableWaitingTime : void 0;
|
|
10415
10522
|
this._stats.lifecycle.markInitializationStarted({
|
|
10416
10523
|
source: "outgoing",
|
|
10417
10524
|
conversationId: u
|
|
10418
|
-
}), this._debug.setConversationId(u),
|
|
10525
|
+
}), this._debug.setConversationId(u), yc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
|
|
10419
10526
|
try {
|
|
10420
10527
|
this._mediaSource = this._createMediaSource(), await this._mediaSource.request(n);
|
|
10421
10528
|
let l = this._mediaSource.mediaSettings;
|
|
10422
|
-
t ===
|
|
10529
|
+
t === co.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l);
|
|
10423
10530
|
let d = await this._startConversation({
|
|
10424
10531
|
opponentIds: e,
|
|
10425
10532
|
opponentType: t,
|
|
10426
|
-
direction:
|
|
10533
|
+
direction: so.OUTGOING,
|
|
10427
10534
|
mediaOptions: n,
|
|
10428
10535
|
payload: r,
|
|
10429
10536
|
joiningAllowed: i,
|
|
@@ -10447,18 +10554,18 @@ var gc = 15, $ = class e extends b {
|
|
|
10447
10554
|
let e = B.get(this._conversation.id);
|
|
10448
10555
|
e && e !== this && e._close(new k(O.HUNGUP, { remote: !0 }));
|
|
10449
10556
|
}
|
|
10450
|
-
return B.add(this), await B.setActive(this.id),
|
|
10557
|
+
return B.add(this), await B.setActive(this.id), yc = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
|
|
10451
10558
|
this._calleeUnavailableTimer = null, this._close(new k(O.CALLEE_UNAVAILABLE), { signalingReason: O.CANCELED });
|
|
10452
10559
|
}, f)), this._conversation;
|
|
10453
10560
|
} catch (e) {
|
|
10454
|
-
throw
|
|
10561
|
+
throw yc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
|
|
10455
10562
|
}
|
|
10456
10563
|
}
|
|
10457
10564
|
async onJoin(e) {
|
|
10458
10565
|
this._stats.lifecycle.markInitializationStarted({
|
|
10459
10566
|
source: e.anonymous ? "anonym_join" : "join",
|
|
10460
10567
|
conversationId: e.conversationId
|
|
10461
|
-
}),
|
|
10568
|
+
}), yc = this, this._state = "PROCESSING", this._debug.setConversationId(e.conversationId ?? null), this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
|
|
10462
10569
|
try {
|
|
10463
10570
|
let t = !!e.observedIds?.length;
|
|
10464
10571
|
if (t && N.videoTracksCount > 0) throw this._debug.error("Observer mode: please set videoTracksCount=0"), new k(O.UNSUPPORTED, { callError: {
|
|
@@ -10475,9 +10582,9 @@ var gc = 15, $ = class e extends b {
|
|
|
10475
10582
|
code: "conversation",
|
|
10476
10583
|
description: "not-initialized-after-join"
|
|
10477
10584
|
} });
|
|
10478
|
-
return this._conversation.observer = t, R.onLocalStream(this._mediaSource.getStream(), n, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), B.add(this),
|
|
10585
|
+
return this._conversation.observer = t, R.onLocalStream(this._mediaSource.getStream(), n, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), B.add(this), yc = null, this._signaling.readyToSend(), R.onLocalStatus(this._conversation.waitForAdmin ? P.WAIT_FOR_ADMIN : P.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
|
|
10479
10586
|
} catch (e) {
|
|
10480
|
-
throw
|
|
10587
|
+
throw yc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
|
|
10481
10588
|
}
|
|
10482
10589
|
}
|
|
10483
10590
|
async _onJoinPart2(e, t = !0, n = !1) {
|
|
@@ -10492,7 +10599,7 @@ var gc = 15, $ = class e extends b {
|
|
|
10492
10599
|
if (this._delayedHangup) throw new k(O.CANCELED);
|
|
10493
10600
|
this._processConnectionSharedMovieInfo(e), this._processConversationUrlSharingInfo(e), this._processConnectionAsrInfo(e);
|
|
10494
10601
|
let r = this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
|
|
10495
|
-
R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (B.add(this), n ? await this._holdLocally() : await B.setActive(this.id),
|
|
10602
|
+
R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (B.add(this), n ? await this._holdLocally() : await B.setActive(this.id), yc = null);
|
|
10496
10603
|
let i = this._extractLocalParticipantFromConnection(e);
|
|
10497
10604
|
if (i) {
|
|
10498
10605
|
let e = M.mapParticipantState(i);
|
|
@@ -10500,7 +10607,7 @@ var gc = 15, $ = class e extends b {
|
|
|
10500
10607
|
}
|
|
10501
10608
|
return t && this._openTransport(Object.values(this._participants), !1), this._conversation;
|
|
10502
10609
|
} catch (e) {
|
|
10503
|
-
throw
|
|
10610
|
+
throw yc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
|
|
10504
10611
|
}
|
|
10505
10612
|
}
|
|
10506
10613
|
_extractExternalRooms(e) {
|
|
@@ -10520,7 +10627,7 @@ var gc = 15, $ = class e extends b {
|
|
|
10520
10627
|
B.reserve(e), this._reservedId = e, a && this._api.setUserId(a), this._stats.lifecycle.markInitializationStarted({
|
|
10521
10628
|
source: "incoming",
|
|
10522
10629
|
conversationId: e
|
|
10523
|
-
}), this._debug.setConversationId(e),
|
|
10630
|
+
}), this._debug.setConversationId(e), yc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
|
|
10524
10631
|
try {
|
|
10525
10632
|
let a = await this._prepareConversation(e, t, n, r, i);
|
|
10526
10633
|
if (this._mediaSource = this._createMediaSource(), !this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
|
|
@@ -10529,20 +10636,20 @@ var gc = 15, $ = class e extends b {
|
|
|
10529
10636
|
description: "incoming-not-initialized"
|
|
10530
10637
|
} });
|
|
10531
10638
|
if (!a.conversation.participants.find((e) => e.state === X.CALLED && e.id === this._conversation?.userId)) throw this._debug.log("Push rejected (there is an active call)"), this._stats.logger.log(C.PUSH, "rejected"), new k(O.REJECTED);
|
|
10532
|
-
if (await this._processConnection(a), this._extractConnectionUrlSharingInfo(a), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._processPinnedParticipants(a), this._signaling.readyToSend(), this._stats.lifecycle.markCallStarted(), this._stats.logger.log(C.PUSH, "accepted"), B.add(this),
|
|
10639
|
+
if (await this._processConnection(a), this._extractConnectionUrlSharingInfo(a), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._processPinnedParticipants(a), this._signaling.readyToSend(), this._stats.lifecycle.markCallStarted(), this._stats.logger.log(C.PUSH, "accepted"), B.add(this), yc = null, this._delayedHangup) throw new k(O.CANCELED);
|
|
10533
10640
|
} catch (e) {
|
|
10534
|
-
throw
|
|
10641
|
+
throw yc = null, this._cleanupRegistry(), this._close(e, {
|
|
10535
10642
|
errorText: "Unable to handle inbound call push",
|
|
10536
10643
|
signalingReason: e instanceof k && e.hangup === O.BUSY ? O.BUSY : void 0
|
|
10537
10644
|
}), e;
|
|
10538
10645
|
}
|
|
10539
10646
|
}
|
|
10540
10647
|
_isInWaitingHall(e) {
|
|
10541
|
-
return !e.conversation || !e.conversation.options.includes(
|
|
10648
|
+
return !e.conversation || !e.conversation.options.includes(fo.WAITING_HALL) ? !1 : this._isRestricted(e);
|
|
10542
10649
|
}
|
|
10543
10650
|
_isWaitForAdmin(e) {
|
|
10544
10651
|
if (!e.conversation) return !1;
|
|
10545
|
-
let t = e.conversation.options.includes(
|
|
10652
|
+
let t = e.conversation.options.includes(fo.WAIT_FOR_ADMIN), n = e.conversation.options.includes(fo.ADMIN_IS_HERE);
|
|
10546
10653
|
return !t || t && n ? !1 : this._isRestricted(e);
|
|
10547
10654
|
}
|
|
10548
10655
|
_isRestricted(e) {
|
|
@@ -10550,7 +10657,7 @@ var gc = 15, $ = class e extends b {
|
|
|
10550
10657
|
return t && t.restricted || !1;
|
|
10551
10658
|
}
|
|
10552
10659
|
_isAudienceMode(e) {
|
|
10553
|
-
return e.conversation?.options?.includes(
|
|
10660
|
+
return e.conversation?.options?.includes(fo.AUDIENCE_MODE) || !1;
|
|
10554
10661
|
}
|
|
10555
10662
|
_isAudienceModeListener() {
|
|
10556
10663
|
return this._conversation?.audienceMode && this._conversation?.restricted;
|
|
@@ -10580,7 +10687,7 @@ var gc = 15, $ = class e extends b {
|
|
|
10580
10687
|
let i = atob(n), a = new Uint8Array(i.length);
|
|
10581
10688
|
for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
|
|
10582
10689
|
try {
|
|
10583
|
-
let e =
|
|
10690
|
+
let e = Po(a, r).reduce((e, t) => (e += String.fromCharCode(t), e), ""), { srcp: t, stne: n, tkn: i, trne: o, trnp: s, trnu: c, wse: l, wte: u } = JSON.parse(e);
|
|
10584
10691
|
return {
|
|
10585
10692
|
token: i,
|
|
10586
10693
|
endpoint: l,
|
|
@@ -10783,10 +10890,10 @@ var gc = 15, $ = class e extends b {
|
|
|
10783
10890
|
let t = await this._api.getConversationParams(e);
|
|
10784
10891
|
this._debug.debug("Api.getConversationParams", t);
|
|
10785
10892
|
let { turn_server: n, stun_server: r } = t;
|
|
10786
|
-
return N.iceServers =
|
|
10893
|
+
return N.iceServers = No(r, n), N.wssBase = t.endpoint, t.wt_endpoint && (N.wtsBase = t.wt_endpoint), N.wssToken = t.token, t.client_type && (N.clientType = t.client_type), t.external_user_type && (N.externalUserType = t.external_user_type), t;
|
|
10787
10894
|
}
|
|
10788
10895
|
_setConversationParams({ turn_server: e, stun_server: t, endpoint: n, wt_endpoint: r, token: i, client_type: a }) {
|
|
10789
|
-
N.iceServers =
|
|
10896
|
+
N.iceServers = No(t, e), N.wssBase = n, N.wssToken = i, r && (N.wtsBase = r), a && (N.clientType = a);
|
|
10790
10897
|
}
|
|
10791
10898
|
_buildSignalingEndpoint({ baseEndpoint: e, userId: t, type: n, deviceIdx: r, conversationId: i, token: a, conversationParams: o }) {
|
|
10792
10899
|
let s = new URL(e), c = s.searchParams;
|
|
@@ -10818,10 +10925,10 @@ var gc = 15, $ = class e extends b {
|
|
|
10818
10925
|
isVideo: f,
|
|
10819
10926
|
joiningAllowed: a,
|
|
10820
10927
|
requireAuthToJoin: o
|
|
10821
|
-
}, this._abortController?.signal), !e) throw
|
|
10928
|
+
}, this._abortController?.signal), !e) throw _c(O.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
|
|
10822
10929
|
if (!e.internalCallerParams) {
|
|
10823
10930
|
let t = e.rejectedParticipants[0]?.status;
|
|
10824
|
-
throw
|
|
10931
|
+
throw _c(O.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
|
|
10825
10932
|
}
|
|
10826
10933
|
} catch (e) {
|
|
10827
10934
|
throw this._delayedHangup && this._abortController?.signal.aborted ? new k(O.CANCELED) : e instanceof k ? e : e instanceof Error ? new k(O.FAST_START_ERROR, { message: e.message }) : new k(O.FAST_START_ERROR, { message: String(e) });
|
|
@@ -10843,10 +10950,10 @@ var gc = 15, $ = class e extends b {
|
|
|
10843
10950
|
token: new URL(t.endpoint).searchParams.get("token") ?? ""
|
|
10844
10951
|
}, this._debug.debug("FastStart", p), m = "fastStart";
|
|
10845
10952
|
} catch {
|
|
10846
|
-
throw
|
|
10953
|
+
throw _c(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
|
|
10847
10954
|
}
|
|
10848
10955
|
} else p = await this._api.startConversation(d, e, t, f, i, a, o, { onlyAdminCanShareMovie: s }, c), this._debug.debug("Api.startConversation", p), m = "startConversation";
|
|
10849
|
-
|
|
10956
|
+
Ro(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
|
|
10850
10957
|
let ee = await this._connectSignaling(br.START, p);
|
|
10851
10958
|
return this._setConversation(p, ee, n), this._stats.lifecycle.markCallStarted(), ee;
|
|
10852
10959
|
}
|
|
@@ -10871,9 +10978,9 @@ var gc = 15, $ = class e extends b {
|
|
|
10871
10978
|
joinLink: i,
|
|
10872
10979
|
isVideo: c,
|
|
10873
10980
|
internalParams: this._buildInternalParams()
|
|
10874
|
-
}, this._abortController?.signal), !e) throw
|
|
10875
|
-
if (!e.internalCallerParams) throw
|
|
10876
|
-
if (!e.conversationId) throw
|
|
10981
|
+
}, this._abortController?.signal), !e) throw _c(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
|
|
10982
|
+
if (!e.internalCallerParams) throw _c(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
|
|
10983
|
+
if (!e.conversationId) throw _c(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
|
|
10877
10984
|
} catch (e) {
|
|
10878
10985
|
throw this._delayedHangup && this._abortController?.signal.aborted ? new k(O.CANCELED) : e instanceof k ? e : e instanceof Error ? new k(O.FAST_JOIN_ERROR, { message: e.message }) : new k(O.FAST_JOIN_ERROR, { message: String(e) });
|
|
10879
10986
|
}
|
|
@@ -10891,7 +10998,7 @@ var gc = 15, $ = class e extends b {
|
|
|
10891
10998
|
token: new URL(t.endpoint).searchParams.get("token") ?? ""
|
|
10892
10999
|
}, this._debug.debug("FastJoin", l), u = "fastJoin";
|
|
10893
11000
|
} catch (e) {
|
|
10894
|
-
throw e instanceof k ? e :
|
|
11001
|
+
throw e instanceof k ? e : _c(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
|
|
10895
11002
|
}
|
|
10896
11003
|
} else if (t) l = await this._api.joinConversation(t, c, r), u = "joinConversation";
|
|
10897
11004
|
else if (i) l = await this._api.joinConversationByLink(i, c, a, o), u = "joinConversationByLink";
|
|
@@ -10900,13 +11007,13 @@ var gc = 15, $ = class e extends b {
|
|
|
10900
11007
|
code: "join",
|
|
10901
11008
|
description: "target-missing"
|
|
10902
11009
|
} });
|
|
10903
|
-
if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id),
|
|
11010
|
+
if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), Ro(l, u), l.id) {
|
|
10904
11011
|
if (B.has(l.id)) throw new k(O.HAS_ACTIVE_CALL);
|
|
10905
11012
|
B.reserve(l.id), this._reservedId = l.id;
|
|
10906
11013
|
}
|
|
10907
11014
|
this._setConversationParams(l);
|
|
10908
11015
|
let d = await this._connectSignaling(br.JOIN, l);
|
|
10909
|
-
return this._setConversation(l, d,
|
|
11016
|
+
return this._setConversation(l, d, so.JOINING), this._stats.lifecycle.markCallStarted(), d;
|
|
10910
11017
|
}
|
|
10911
11018
|
async _prepareConversation(e, t = j.USER, n, r, i) {
|
|
10912
11019
|
G.setMark(U.SIGNALING_CONNECTED), this._debug.debug("Conversation: push", {
|
|
@@ -10968,7 +11075,7 @@ var gc = 15, $ = class e extends b {
|
|
|
10968
11075
|
}), l.wt_endpoint = c);
|
|
10969
11076
|
}
|
|
10970
11077
|
let u = await this._connectSignaling(br.ACCEPT, l);
|
|
10971
|
-
return B.callsLength >= N.maxParallelCalls || !N.hold && B.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(C.PUSH, "busy"), Promise.reject(new k(O.BUSY))) : (this._setConversation(l, u,
|
|
11078
|
+
return B.callsLength >= N.maxParallelCalls || !N.hold && B.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(C.PUSH, "busy"), Promise.reject(new k(O.BUSY))) : (this._setConversation(l, u, so.INCOMING, t), u);
|
|
10972
11079
|
}
|
|
10973
11080
|
_createParticipant(e, t, n = !0) {
|
|
10974
11081
|
let r = Object.assign({
|
|
@@ -10995,7 +11102,7 @@ var gc = 15, $ = class e extends b {
|
|
|
10995
11102
|
let e = this._getParticipantId(t ?? r.id);
|
|
10996
11103
|
e && (r.externalId = e);
|
|
10997
11104
|
}
|
|
10998
|
-
return n && i && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && r.externalId && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus =
|
|
11105
|
+
return n && i && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && r.externalId && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus = So.create(r.connectionStatus), r;
|
|
10999
11106
|
}
|
|
11000
11107
|
_getParticipantId(e) {
|
|
11001
11108
|
let t = this._api.userId(e);
|
|
@@ -11073,8 +11180,8 @@ var gc = 15, $ = class e extends b {
|
|
|
11073
11180
|
this._conversation.acceptTime = e.conversation.acceptTime, this._conversation.features = e.conversation.features || [], this._conversation.featuresPerRole = e.conversation.featuresPerRole, this._conversation.participantsLimit = e.conversation.participantsLimit || 30, this._conversation.topology = e.conversation.topology || J.DIRECT, this._conversation.concurrent = e.isConcurrent || !1, this._conversation.chatId = e.conversation.multichatId, this._conversation.mediaModifiers = e.mediaModifiers, this._conversation.waitingHall = !1, this._conversation.waitForAdmin = !1, this._conversation.restricted = !1, this._cacheParticipantExternalIds(e.conversation.participants ?? []);
|
|
11074
11181
|
}
|
|
11075
11182
|
_createMediaSource() {
|
|
11076
|
-
let e = new Yt(this._debug, this._stats.logger
|
|
11077
|
-
return this.subscribe(e, qt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new
|
|
11183
|
+
let e = new Yt(this._debug, this._stats.logger);
|
|
11184
|
+
return this.subscribe(e, qt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new Io(e, this._debug, this._stats.logger), e;
|
|
11078
11185
|
}
|
|
11079
11186
|
async _connectSignaling(e, t) {
|
|
11080
11187
|
this._signaling.setEndpoint(t.endpoint), this._signaling.setWebTransportEndpoint(t.wt_endpoint ? t.wt_endpoint : null), this.subscribe(this._signaling, xr.NOTIFICATION, (e) => this._signalingActor.add(e)), this.subscribe(this._signaling, xr.FAILED, this._onSignalingFailed.bind(this)), this.subscribe(this._signaling, xr.RECONNECT, this._onSignalingReconnect.bind(this));
|
|
@@ -11082,7 +11189,7 @@ var gc = 15, $ = class e extends b {
|
|
|
11082
11189
|
return this._stats.statAggregator.logEventualStatSinceMark({ name: U.SIGNALING_CONNECTED }), n;
|
|
11083
11190
|
}
|
|
11084
11191
|
async _processConnection(e) {
|
|
11085
|
-
await this._registerConnectionParticipants(e), this._processRooms(e), this._processMuteStates(e), this._processRecordInfos(e), this._onOptionsChanged(e.conversation.options), e.chatRoom && e.chatRoom.totalCount && this._onChatRoomUpdated(
|
|
11192
|
+
await this._registerConnectionParticipants(e), this._processRooms(e), this._processMuteStates(e), this._processRecordInfos(e), this._onOptionsChanged(e.conversation.options), e.chatRoom && e.chatRoom.totalCount && this._onChatRoomUpdated(lo.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
|
|
11086
11193
|
}
|
|
11087
11194
|
_onConversationParticipantListChunk(e) {
|
|
11088
11195
|
let t = e.participants;
|
|
@@ -11151,7 +11258,7 @@ var gc = 15, $ = class e extends b {
|
|
|
11151
11258
|
_registerParticipantLocalMuteState({ muteStates: e, unmuteOptions: t }) {
|
|
11152
11259
|
if (!e) return;
|
|
11153
11260
|
let n = async () => {
|
|
11154
|
-
let n =
|
|
11261
|
+
let n = Eo(e, ho.MUTE), r = Eo(e, ho.MUTE_PERMANENT);
|
|
11155
11262
|
for (let i of [n, r]) i.length && await this._onMuteParticipant({
|
|
11156
11263
|
muteStates: e,
|
|
11157
11264
|
unmuteOptions: t,
|
|
@@ -11165,8 +11272,8 @@ var gc = 15, $ = class e extends b {
|
|
|
11165
11272
|
if (!(!N.enableSessionStateUpdates || this._isMe(e))) return t;
|
|
11166
11273
|
}
|
|
11167
11274
|
_buildConnectionStatus(e, t, n, r = !1) {
|
|
11168
|
-
return
|
|
11169
|
-
transport: r ? P.ONHOLD :
|
|
11275
|
+
return So.create({
|
|
11276
|
+
transport: r ? P.ONHOLD : So.fromTransportState(n) ?? P.WAITING,
|
|
11170
11277
|
sessionState: this._remoteParticipantSessionState(e, t),
|
|
11171
11278
|
sessionStateApplicable: this._isParticipantSessionStateApplicable(e)
|
|
11172
11279
|
});
|
|
@@ -11175,12 +11282,12 @@ var gc = 15, $ = class e extends b {
|
|
|
11175
11282
|
return N.enableSessionStateUpdates && !this._isMe(e) && this._conversation?.topology === J.SERVER;
|
|
11176
11283
|
}
|
|
11177
11284
|
_setTransportStatus(e, t) {
|
|
11178
|
-
return
|
|
11285
|
+
return So.setTransport(e.connectionStatus, t);
|
|
11179
11286
|
}
|
|
11180
11287
|
_setSessionState(e, t) {
|
|
11181
|
-
let n =
|
|
11288
|
+
let n = So.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
|
|
11182
11289
|
this._emitParticipantTransition(e, n);
|
|
11183
|
-
let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === P.CONNECTED, i =
|
|
11290
|
+
let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === P.CONNECTED, i = So.setSessionState(e.connectionStatus, t, r);
|
|
11184
11291
|
return this._emitParticipantTransition(e, i), i;
|
|
11185
11292
|
}
|
|
11186
11293
|
_emitParticipantTransition(e, t, n = null) {
|
|
@@ -11251,11 +11358,11 @@ var gc = 15, $ = class e extends b {
|
|
|
11251
11358
|
this._onRoomSwitched(t, !0);
|
|
11252
11359
|
}
|
|
11253
11360
|
_processMuteStates(e, t = !1) {
|
|
11254
|
-
let n =
|
|
11361
|
+
let n = Do(e);
|
|
11255
11362
|
this._setMuteStatesForRoomId(n, null);
|
|
11256
11363
|
for (let t of e.rooms?.rooms ?? []) this._setMuteStatesForRoomId(t.muteStates, t.id);
|
|
11257
11364
|
let r = this._getMuteStatesForCurrentRoom();
|
|
11258
|
-
t && (r =
|
|
11365
|
+
t && (r = jo(e, r));
|
|
11259
11366
|
let i = Object.keys(r), a = this._conversation?.roomId;
|
|
11260
11367
|
i.length && this._onMuteParticipant({
|
|
11261
11368
|
muteStates: r,
|
|
@@ -11275,15 +11382,15 @@ var gc = 15, $ = class e extends b {
|
|
|
11275
11382
|
}
|
|
11276
11383
|
_allocateTransport() {
|
|
11277
11384
|
if (!this._conversation || !this._mediaSource) return;
|
|
11278
|
-
this._transport = new
|
|
11279
|
-
let e = this._conversation.direction ===
|
|
11385
|
+
this._transport = new ka(this._conversation.topology, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._stats.logger, this._stats.statAggregator, this._stats.codecStatsAggregator, this._getFirstMediaSentCallback()), this._debugInfo = new Uo(this._debug), this.subscribe(this._transport, Y.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, Y.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, Y.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, Y.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, Y.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, Y.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, Y.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, Y.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, Y.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, Y.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, Y.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, Y.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, Y.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
|
|
11386
|
+
let e = this._conversation.direction === so.OUTGOING && !this._conversation.concurrent, t = this._participants;
|
|
11280
11387
|
for (let n of Object.values(t)) (n.state === X.ACCEPTED || n.state === X.CALLED) && this._allocateParticipantTransport(n.id, e);
|
|
11281
11388
|
}
|
|
11282
11389
|
_createSpeakerDetector() {
|
|
11283
|
-
this._transport && this._conversation && (this._volumesDetector = new
|
|
11390
|
+
this._transport && this._conversation && (this._volumesDetector = new Xo(this._transport), this.subscribe(this._volumesDetector, Yo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new Qo(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, Zo.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new qo(this._mediaSource));
|
|
11284
11391
|
}
|
|
11285
11392
|
_createSpecListener() {
|
|
11286
|
-
this._transport && this._volumesDetector && (this._specListener = new
|
|
11393
|
+
this._transport && this._volumesDetector && (this._specListener = new ts(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
|
|
11287
11394
|
}
|
|
11288
11395
|
_logDevices() {
|
|
11289
11396
|
let e = E.getCameras().length, t = E.getMicrophones().length;
|
|
@@ -11382,7 +11489,7 @@ var gc = 15, $ = class e extends b {
|
|
|
11382
11489
|
_onRemoveParticipant(e) {
|
|
11383
11490
|
this._debug.debug(`Remove participant [${e}]`);
|
|
11384
11491
|
let t = [], n = this._participants;
|
|
11385
|
-
for (let r = 0; r <=
|
|
11492
|
+
for (let r = 0; r <= vc; r++) {
|
|
11386
11493
|
let i = n[M.compose(e, r)];
|
|
11387
11494
|
i && t.push(i);
|
|
11388
11495
|
}
|
|
@@ -11472,11 +11579,11 @@ var gc = 15, $ = class e extends b {
|
|
|
11472
11579
|
this._waitingHallHoldPending = !1, await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus()), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener();
|
|
11473
11580
|
return;
|
|
11474
11581
|
}
|
|
11475
|
-
let n =
|
|
11582
|
+
let n = za.get();
|
|
11476
11583
|
await this._signaling.hold(!1, n), this._restoreStateAfterHold();
|
|
11477
11584
|
let r = null;
|
|
11478
11585
|
if (this._state === "IDLE" && this._participantState === X.ACCEPTED && (r = Object.values(this._participants), r.some((e) => e.state === X.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), await this._resumeLocalMedia(t, P.WAITING), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._state === "ACTIVE") {
|
|
11479
|
-
let e = this._conversation?.direction ===
|
|
11586
|
+
let e = this._conversation?.direction === so.OUTGOING && !this._conversation.concurrent;
|
|
11480
11587
|
this._openTransport(r ?? Object.values(this._participants), e);
|
|
11481
11588
|
}
|
|
11482
11589
|
}
|
|
@@ -11599,13 +11706,13 @@ var gc = 15, $ = class e extends b {
|
|
|
11599
11706
|
let n = Fn(e), a = i[n.participantId];
|
|
11600
11707
|
if (a) {
|
|
11601
11708
|
let e;
|
|
11602
|
-
typeof t == "number" ? e =
|
|
11709
|
+
typeof t == "number" ? e = vo(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = _o.UNKNOWN_ERROR), r.push({
|
|
11603
11710
|
externalId: a.externalId,
|
|
11604
11711
|
errorReason: e
|
|
11605
11712
|
});
|
|
11606
11713
|
}
|
|
11607
11714
|
}
|
|
11608
|
-
if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new
|
|
11715
|
+
if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new bc("Could not allocate one or more participants", r);
|
|
11609
11716
|
}
|
|
11610
11717
|
async _cleanupCooldownQueue() {
|
|
11611
11718
|
let e = {}, t = this._cooldownTimestampByStreamDescription.entries();
|
|
@@ -11613,7 +11720,7 @@ var gc = 15, $ = class e extends b {
|
|
|
11613
11720
|
let n = t.next();
|
|
11614
11721
|
if (n.done) break;
|
|
11615
11722
|
let r = n.value;
|
|
11616
|
-
if (r[1] +
|
|
11723
|
+
if (r[1] + gc > Date.now()) break;
|
|
11617
11724
|
let i = r[0];
|
|
11618
11725
|
await this._stopStreaming(i), e[i] = { stopStream: !0 };
|
|
11619
11726
|
} while (!0);
|
|
@@ -11817,10 +11924,10 @@ var gc = 15, $ = class e extends b {
|
|
|
11817
11924
|
throw Error("transport is not initialized");
|
|
11818
11925
|
}
|
|
11819
11926
|
_isCallAdmin() {
|
|
11820
|
-
return this._conversation ? M.includesOneOf(this._conversation.roles, [
|
|
11927
|
+
return this._conversation ? M.includesOneOf(this._conversation.roles, [yo.ADMIN, yo.CREATOR]) : !1;
|
|
11821
11928
|
}
|
|
11822
11929
|
_checkAdminRole() {
|
|
11823
|
-
if (this._conversation && !M.includesOneOf(this._conversation.roles, [
|
|
11930
|
+
if (this._conversation && !M.includesOneOf(this._conversation.roles, [yo.ADMIN, yo.CREATOR])) throw Error("You don't have the required permission");
|
|
11824
11931
|
}
|
|
11825
11932
|
_isCalledState() {
|
|
11826
11933
|
return this._participantState === X.CALLED;
|
|
@@ -11858,21 +11965,21 @@ var gc = 15, $ = class e extends b {
|
|
|
11858
11965
|
async changeOptions(e) {
|
|
11859
11966
|
if (this._signaling.ready && this._conversation) {
|
|
11860
11967
|
this._checkAdminRole(), await this._signaling.changeOptions(e);
|
|
11861
|
-
let t =
|
|
11968
|
+
let t = mo(this._conversation.options, e);
|
|
11862
11969
|
this._onOptionsChanged(t);
|
|
11863
11970
|
}
|
|
11864
11971
|
}
|
|
11865
11972
|
async getWaitingHall(e, t, n) {
|
|
11866
11973
|
if (!this._signaling) return Promise.reject();
|
|
11867
11974
|
let r = null;
|
|
11868
|
-
if (e && (r =
|
|
11975
|
+
if (e && (r = To(e), r)) {
|
|
11869
11976
|
let e = this._api.getDecorativeIdByInitialId(r.id);
|
|
11870
11977
|
r.id = e ?? r.id;
|
|
11871
11978
|
}
|
|
11872
11979
|
let i = await this._signaling.getWaitingHall(r, t, n);
|
|
11873
11980
|
if (i.error) return Promise.reject(i.message);
|
|
11874
11981
|
let a = i.participants || [], { externalIds: o } = this._resolveWaitingHallExternalIds(a, "getWaitingHall"), s = null;
|
|
11875
|
-
return a.length && i.hasMore && (s =
|
|
11982
|
+
return a.length && i.hasMore && (s = wo(a[a.length - 1].id)), {
|
|
11876
11983
|
participants: o,
|
|
11877
11984
|
pageMarker: s,
|
|
11878
11985
|
totalCount: i.totalCount || 0
|
|
@@ -11906,7 +12013,7 @@ var gc = 15, $ = class e extends b {
|
|
|
11906
12013
|
}
|
|
11907
12014
|
async promoteParticipant(e, t) {
|
|
11908
12015
|
if (this._signaling && this._conversation) try {
|
|
11909
|
-
if (!M.includesOneOf(this._conversation.options, [
|
|
12016
|
+
if (!M.includesOneOf(this._conversation.options, [fo.WAITING_HALL, fo.AUDIENCE_MODE])) throw Error("Unable to promote a participant in the conversation with current options");
|
|
11910
12017
|
if (this._checkAdminRole(), !e && t) throw Error("participantId is required");
|
|
11911
12018
|
await this._signaling.promoteParticipant(e, t);
|
|
11912
12019
|
} catch (t) {
|
|
@@ -12078,7 +12185,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12078
12185
|
let a = this._transport?.getState();
|
|
12079
12186
|
return n.participants.forEach((e) => {
|
|
12080
12187
|
let t = M.composeId(e), n = r[t];
|
|
12081
|
-
this._updateParticipantExternalId(n, e), this._setSessionState(n, this._remoteParticipantSessionState(t, e.sessionState)), n.isOnHold || this._setTransportStatus(n,
|
|
12188
|
+
this._updateParticipantExternalId(n, e), this._setSessionState(n, this._remoteParticipantSessionState(t, e.sessionState)), n.isOnHold || this._setTransportStatus(n, So.fromTransportState(a) ?? P.WAITING), n.movieShareInfos = e.movieShareInfos, Object.assign(n.mediaSettings, D(e.mediaSettings)), Object.assign(n.muteStates, e.muteStates), n.unmuteOptions = e.unmuteOptions ?? n.unmuteOptions, this._openTransport([n], !0);
|
|
12082
12189
|
}), this._participantListChunkToExternalChunk(n);
|
|
12083
12190
|
}
|
|
12084
12191
|
async _getInitialParticiapntListChunk() {
|
|
@@ -12092,7 +12199,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12092
12199
|
_onLocalMediaStreamChanged(e) {
|
|
12093
12200
|
if (!this._conversation || !this._mediaSource) return;
|
|
12094
12201
|
let t = this._mediaSource.mediaSettings;
|
|
12095
|
-
this._debug.debug("Local media stream changed", t), e.kind === A.audio && this._mediaSource && (this._audioFix = new
|
|
12202
|
+
this._debug.debug("Local media stream changed", t), e.kind === A.audio && this._mediaSource && (this._audioFix = new Io(this._mediaSource, this._debug, this._stats.logger)), R.onLocalStreamUpdate(t, e.kind, this.id), !this._conversation?.waitingHall && !this._conversation?.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
|
|
12096
12203
|
}
|
|
12097
12204
|
_onScreenSharingStatus(e) {
|
|
12098
12205
|
let t = this.mediaSettings;
|
|
@@ -12222,9 +12329,9 @@ var gc = 15, $ = class e extends b {
|
|
|
12222
12329
|
for (let n of e.conversation.participants) {
|
|
12223
12330
|
let e = M.composeId(n), i = n.roles || [];
|
|
12224
12331
|
if (this._isMe(e)) {
|
|
12225
|
-
|
|
12332
|
+
bo(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
|
|
12226
12333
|
this._registerParticipantLocalMuteState({
|
|
12227
|
-
muteStates:
|
|
12334
|
+
muteStates: Ao(n),
|
|
12228
12335
|
unmuteOptions: n.unmuteOptions
|
|
12229
12336
|
});
|
|
12230
12337
|
};
|
|
@@ -12242,7 +12349,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12242
12349
|
let t = D(n.mediaSettings);
|
|
12243
12350
|
Wt(t, a.mediaSettings) || this._changeRemoteMediaSettings(e, t);
|
|
12244
12351
|
let r = M.mapParticipantState(n), o = a.participantState;
|
|
12245
|
-
M.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r),
|
|
12352
|
+
M.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), bo(i, a.roles) || this._onRolesChanged(a.id, i), !!n.onHold != !!a.isOnHold && (a.isOnHold = !!n.onHold, this._setParticipantsStatus([a], n.onHold ? P.ONHOLD : P.CONNECTED));
|
|
12246
12353
|
}
|
|
12247
12354
|
}
|
|
12248
12355
|
let i = this._participants;
|
|
@@ -12267,7 +12374,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12267
12374
|
this._close(new k(O.ANOTHER_DEVICE), { errorText: "Call accepted on other device" });
|
|
12268
12375
|
return;
|
|
12269
12376
|
}
|
|
12270
|
-
this._conversation?.direction ===
|
|
12377
|
+
this._conversation?.direction === so.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
|
|
12271
12378
|
let r = this._getParticipant(t);
|
|
12272
12379
|
if (!r) {
|
|
12273
12380
|
let n = this._api.getDecorativeIdByInitialId(t);
|
|
@@ -12280,7 +12387,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12280
12387
|
let t = Z.fromSignaling(e.externalId, e.deviceIdx);
|
|
12281
12388
|
r.externalId = t, this._api.cacheExternalId(r.id, t);
|
|
12282
12389
|
}
|
|
12283
|
-
r.state = X.ACCEPTED, r.mediaSettings = D(e.mediaSettings), this._logWithMediaSettings(C.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction ===
|
|
12390
|
+
r.state = X.ACCEPTED, r.mediaSettings = D(e.mediaSettings), this._logWithMediaSettings(C.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === so.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), this._state === "ACTIVE" && this._transport && this._transport.open([r.id], n), this._changeRemoteMediaSettings(t, r.mediaSettings), await this._changeRemoteParticipantState(t);
|
|
12284
12391
|
let i = Object.keys(r.muteStates);
|
|
12285
12392
|
if (i.length && this._onMuteParticipant({
|
|
12286
12393
|
muteStates: r.muteStates,
|
|
@@ -12292,7 +12399,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12292
12399
|
this._reportMissingExternalIds([t], "ACCEPTED_CALL");
|
|
12293
12400
|
return;
|
|
12294
12401
|
}
|
|
12295
|
-
R.onAcceptedCall(r.externalId,
|
|
12402
|
+
R.onAcceptedCall(r.externalId, Va.parseCapabilities(e.capabilities), this.id);
|
|
12296
12403
|
}
|
|
12297
12404
|
}
|
|
12298
12405
|
async _onHungup(e) {
|
|
@@ -12329,7 +12436,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12329
12436
|
return;
|
|
12330
12437
|
}
|
|
12331
12438
|
if (e.connected) {
|
|
12332
|
-
let e =
|
|
12439
|
+
let e = So.fromTransportState(this._transport?.getState());
|
|
12333
12440
|
e && this._setTransportStatus(n, e);
|
|
12334
12441
|
}
|
|
12335
12442
|
this._setSessionState(n, { connected: e.connected });
|
|
@@ -12406,7 +12513,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12406
12513
|
isOnHold: !!r.onHold
|
|
12407
12514
|
}, i), n = this._getParticipant(t);
|
|
12408
12515
|
}
|
|
12409
|
-
this._conversation && this._conversation.direction ===
|
|
12516
|
+
this._conversation && this._conversation.direction === so.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), n.state = X.ACCEPTED, n.mediaSettings = D(e.mediaSettings), n.participantState = M.mapParticipantState(e.participant), n.roles = e.participant.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), e.participant.onHold ? (n.isOnHold = !0, this._setParticipantsStatus([n], P.ONHOLD)) : this._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], P.CONNECTED) : this._setParticipantsStatus([n], P.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && (this._transport.isAllocated(n.id) || this._allocateParticipantTransport(n.id, !0), this._transport.open([n.id], null, !!this._conversation?.observer)), R.onParticipantJoined(n.externalId, n.markers, this.id), this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
|
|
12410
12517
|
let i = Object.keys(n.muteStates);
|
|
12411
12518
|
i.length && this._onMuteParticipant({
|
|
12412
12519
|
muteStates: n.muteStates,
|
|
@@ -12597,15 +12704,15 @@ var gc = 15, $ = class e extends b {
|
|
|
12597
12704
|
R.onAsrTranscription(t, e.text, e.timestamp, e.duration, this.id);
|
|
12598
12705
|
}
|
|
12599
12706
|
async _onRolesChanged(e, t) {
|
|
12600
|
-
if (this._conversation && this._isMe(e) && !
|
|
12707
|
+
if (this._conversation && this._isMe(e) && !bo(this._conversation.roles, t)) {
|
|
12601
12708
|
this._debug.debug(`Local roles changed: ${t}`), this._conversation.roles = t, R.onLocalRolesChanged(t, !1, this.id), this._processMuteState({
|
|
12602
|
-
mediaOptions:
|
|
12709
|
+
mediaOptions: Eo(this._getMuteStatesForCurrentRoom(), ho.MUTE_PERMANENT),
|
|
12603
12710
|
stateUpdated: !0
|
|
12604
|
-
}), M.includesOneOf(t, [
|
|
12711
|
+
}), M.includesOneOf(t, [yo.ADMIN, yo.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
|
|
12605
12712
|
return;
|
|
12606
12713
|
}
|
|
12607
12714
|
let n = this._getParticipant(e);
|
|
12608
|
-
n && !
|
|
12715
|
+
n && !bo(n.roles, t) && (this._debug.debug(`Roles for participant [${e}] changed: ${t}`), n.roles = t, R.onRolesChanged(n.externalId, t, !1, this.id));
|
|
12609
12716
|
}
|
|
12610
12717
|
async _onMuteParticipant(e, t = !1) {
|
|
12611
12718
|
if (!this._conversation) return;
|
|
@@ -12654,7 +12761,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12654
12761
|
let { mediaOptions: t = [], muteAll: n, unmute: r, stateUpdated: i, requestedMedia: a, roomId: o = null, unmuteOptions: s = [] } = e, c = e.adminId ? this._getExternalIdByParticipantId(e.adminId) : null, l = Object.assign({}, e.muteStates ?? this._getMuteStatesForRoomId(o)), u = this._mediaSource.mediaSettings, d = Object.entries(l);
|
|
12655
12762
|
for (let [e, i] of d) {
|
|
12656
12763
|
let a = this._isCallAdmin() && n;
|
|
12657
|
-
if (!(i !==
|
|
12764
|
+
if (!(i !== ho.MUTE && i !== ho.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === ho.MUTE_PERMANENT && !n && (l[e] = ho.MUTE), !(!t.includes(e) || r))) switch (e) {
|
|
12658
12765
|
case S.VIDEO:
|
|
12659
12766
|
u.isVideoEnabled && (R.onDeviceSwitched(S.VIDEO, !1, this.id), await this.toggleLocalVideo(!1));
|
|
12660
12767
|
break;
|
|
@@ -12691,7 +12798,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12691
12798
|
this._conversation.pinnedParticipantIdByRoom.set(r, t ? null : e);
|
|
12692
12799
|
}
|
|
12693
12800
|
_onOptionsChanged(e) {
|
|
12694
|
-
this._conversation && !
|
|
12801
|
+
this._conversation && !po(this._conversation.options, e) && (this._conversation.options = e, R.onOptionsChanged(e, this.id), e.includes(fo.ADMIN_IS_HERE) ? this._conversation.restricted && this._conversation.waitingHall && R.onLocalStatus(P.WAITING_HALL, this.id) : e.includes(fo.WAIT_FOR_ADMIN) && this._conversation.restricted && R.onLocalStatus(P.WAIT_FOR_ADMIN, this.id));
|
|
12695
12802
|
}
|
|
12696
12803
|
async _onNetworkStatus(e) {
|
|
12697
12804
|
if (this._conversation) {
|
|
@@ -12701,7 +12808,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12701
12808
|
if (this._isMe(r) || r === "") e = this._conversation.networkRating;
|
|
12702
12809
|
else if (n[r]) e = n[r].networkRating;
|
|
12703
12810
|
else continue;
|
|
12704
|
-
if (e !== i) if (this._isMe(r) || r === "") this._conversation.networkRating = i,
|
|
12811
|
+
if (e !== i) if (this._isMe(r) || r === "") this._conversation.networkRating = i, gi.getInstance().value = i, R.onLocalNetworkStatusChanged(i, this.id);
|
|
12705
12812
|
else {
|
|
12706
12813
|
let e = n[r];
|
|
12707
12814
|
e.networkRating = i, t.push({
|
|
@@ -12746,7 +12853,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12746
12853
|
}
|
|
12747
12854
|
_changeFeatureSet() {
|
|
12748
12855
|
if (this._conversation) {
|
|
12749
|
-
let e = this._state === "ACTIVE", t = this._conversation.features.includes(
|
|
12856
|
+
let e = this._state === "ACTIVE", t = this._conversation.features.includes(uo.ADD_PARTICIPANT);
|
|
12750
12857
|
R.onCallState(e, t, this._conversation, this.id);
|
|
12751
12858
|
}
|
|
12752
12859
|
}
|
|
@@ -12780,7 +12887,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12780
12887
|
let n = this._getParticipant(e);
|
|
12781
12888
|
if (n) {
|
|
12782
12889
|
if (n.connectionStatus.sessionStateApplicable && n.connectionStatus.sessionState?.connected === !1) {
|
|
12783
|
-
let e =
|
|
12890
|
+
let e = So.fromTransportState(this._transport?.getState());
|
|
12784
12891
|
e && this._setTransportStatus(n, e), n.connectionStatus.sessionStateConnectedBySpeaker = !0;
|
|
12785
12892
|
let t = this._setTransportStatus(n, n.connectionStatus.transport);
|
|
12786
12893
|
this._emitParticipantTransition(n, t);
|
|
@@ -12790,7 +12897,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12790
12897
|
}
|
|
12791
12898
|
async _onTransportStateChanged(e, t) {
|
|
12792
12899
|
this._debug.debug(`Transport state has changed: ${t}`, e);
|
|
12793
|
-
let n =
|
|
12900
|
+
let n = So.fromTransportState(t);
|
|
12794
12901
|
if (!n) return;
|
|
12795
12902
|
let r = this._participants, i = [], a = e.reduce((e, n) => {
|
|
12796
12903
|
if (n in r) {
|
|
@@ -12824,9 +12931,9 @@ var gc = 15, $ = class e extends b {
|
|
|
12824
12931
|
return e.every((e) => t[e]?.isOnHold);
|
|
12825
12932
|
}
|
|
12826
12933
|
_onRemoteTrackAdded(e, t, n) {
|
|
12827
|
-
if (e.endsWith(
|
|
12828
|
-
else if (e.startsWith(
|
|
12829
|
-
else if (e.startsWith(
|
|
12934
|
+
if (e.endsWith(fi.AUDIO_MIX)) this._debug.debug("Remote audio mix track added"), this._audioOutput.add(e, n), R.onRemoteMixedAudioStream(t, this.id);
|
|
12935
|
+
else if (e.startsWith(fi.TRANSPARENT_AUDIO_TRACK_PREFIX)) this._debug.debug(`Remote transparent audio track added: ${e}`), this._audioOutput.add(e, n);
|
|
12936
|
+
else if (e.startsWith(fi.PARTICIPANT_AGNOSTIC_TRACK_PREFIX)) this._debug.debug(`Participant-agnostic track added: ${e}`), this._streamByStreamId.set(e, t);
|
|
12830
12937
|
else {
|
|
12831
12938
|
this._debug.debug(`Remote track added on the participant [${e}]`, { kind: n.kind });
|
|
12832
12939
|
let r = this._getParticipant(e);
|
|
@@ -12853,7 +12960,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12853
12960
|
}
|
|
12854
12961
|
}
|
|
12855
12962
|
async _removeAudioTrack(e, t, n) {
|
|
12856
|
-
if (e !==
|
|
12963
|
+
if (e !== fi.AUDIO_MIX) {
|
|
12857
12964
|
let n = this._getParticipant(e);
|
|
12858
12965
|
if (!n || n.remoteStream && n.remoteStream !== t) return;
|
|
12859
12966
|
}
|
|
@@ -12868,7 +12975,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12868
12975
|
if (this._statFirstMediaReceived.markTopologyChanged(e), e === J.DIRECT && (this._onRemoteSignalledStall([]), this._onAudioMixStall(!1)), this._conversation) {
|
|
12869
12976
|
this._conversation.topology = e;
|
|
12870
12977
|
for (let e of Object.values(this._participants)) {
|
|
12871
|
-
let t =
|
|
12978
|
+
let t = So.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
|
|
12872
12979
|
this._emitParticipantTransition(e, t);
|
|
12873
12980
|
}
|
|
12874
12981
|
this._changeFeatureSet(), this._forceOpenTransportForAloneInCall();
|
|
@@ -12924,7 +13031,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12924
13031
|
].includes(t) ? null : this._setTransportStatus(e, t), n);
|
|
12925
13032
|
}
|
|
12926
13033
|
_setParticipantsStalled(e, t) {
|
|
12927
|
-
this._updateParticipantsStatus(e, (e) =>
|
|
13034
|
+
this._updateParticipantsStatus(e, (e) => So.setStalled(e.connectionStatus, t));
|
|
12928
13035
|
}
|
|
12929
13036
|
_updateParticipantsStatus(e, t, n = null) {
|
|
12930
13037
|
let r = e.reduce((e, n) => {
|
|
@@ -12943,7 +13050,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12943
13050
|
_onRoomsUpdated(e) {
|
|
12944
13051
|
if (this._isCalledState()) return;
|
|
12945
13052
|
let t = {}, n = [], r = [];
|
|
12946
|
-
for (let i of Object.keys(
|
|
13053
|
+
for (let i of Object.keys(go)) {
|
|
12947
13054
|
let a = e.updates[i];
|
|
12948
13055
|
a && (a?.rooms?.forEach((e) => {
|
|
12949
13056
|
let { room: t, missingParticipantIds: i } = this._convertRoomToExternal(e);
|
|
@@ -12958,7 +13065,7 @@ var gc = 15, $ = class e extends b {
|
|
|
12958
13065
|
}
|
|
12959
13066
|
_onRoomUpdated(e) {
|
|
12960
13067
|
let { room: t, missingParticipantIds: n } = this._convertRoomToExternal(e.room || null);
|
|
12961
|
-
e.events.some((e) => e ===
|
|
13068
|
+
e.events.some((e) => e === go.UPDATE) && (e.muteStates !== void 0 && this._setMuteStatesForRoomId(e.muteStates, e.roomId), e.recordInfo !== void 0 && this._conversation?.recordsInfoByRoom.set(e.roomId, e.recordInfo), e.asrInfo !== void 0 && this._conversation?.asrInfoByRoom.set(e.roomId, e.asrInfo)), this._isCalledState() || (this._reportMissingExternalIds(n, "ROOM_UPDATED"), R.onRoomUpdated(e.events, e.roomId, t, e.deactivate || null, this.id));
|
|
12962
13069
|
}
|
|
12963
13070
|
_convertRoomToExternal(e) {
|
|
12964
13071
|
if (!e) return {
|
|
@@ -13069,7 +13176,7 @@ var gc = 15, $ = class e extends b {
|
|
|
13069
13176
|
n && r.push(n);
|
|
13070
13177
|
}
|
|
13071
13178
|
}
|
|
13072
|
-
r.length && !this._isCalledState() && R.onRoomsUpdated({ [
|
|
13179
|
+
r.length && !this._isCalledState() && R.onRoomsUpdated({ [go.UPDATE]: { rooms: r } }, this.id);
|
|
13073
13180
|
}
|
|
13074
13181
|
_onFeedback(e) {
|
|
13075
13182
|
let t = [];
|
|
@@ -13145,11 +13252,11 @@ var gc = 15, $ = class e extends b {
|
|
|
13145
13252
|
_getParticipant(e) {
|
|
13146
13253
|
return this._participants[e];
|
|
13147
13254
|
}
|
|
13148
|
-
},
|
|
13255
|
+
}, yc = null, bc = class e extends Error {
|
|
13149
13256
|
constructor(t, n) {
|
|
13150
13257
|
super(t), h(this, "participantErrors", void 0), Object.setPrototypeOf(this, e.prototype), this.participantErrors = n;
|
|
13151
13258
|
}
|
|
13152
|
-
},
|
|
13259
|
+
}, xc = class {
|
|
13153
13260
|
constructor() {
|
|
13154
13261
|
h(this, "_abortSignal", void 0), h(this, "_apiCallStats", null);
|
|
13155
13262
|
}
|
|
@@ -13194,14 +13301,14 @@ var gc = 15, $ = class e extends b {
|
|
|
13194
13301
|
async getInbounds() {
|
|
13195
13302
|
return [];
|
|
13196
13303
|
}
|
|
13197
|
-
},
|
|
13304
|
+
}, Sc = class e {
|
|
13198
13305
|
constructor() {
|
|
13199
13306
|
h(this, "_participantIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToParticipantId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
|
|
13200
13307
|
}
|
|
13201
13308
|
static _normalizeType(e) {
|
|
13202
|
-
return e.type ===
|
|
13309
|
+
return e.type === Co.GROUP ? {
|
|
13203
13310
|
...e,
|
|
13204
|
-
type:
|
|
13311
|
+
type: Co.USER
|
|
13205
13312
|
} : e;
|
|
13206
13313
|
}
|
|
13207
13314
|
getExternalId(e) {
|
|
@@ -13229,27 +13336,27 @@ var gc = 15, $ = class e extends b {
|
|
|
13229
13336
|
clear() {
|
|
13230
13337
|
this._participantIdToExternalId.clear(), this._externalIdToParticipantId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
|
|
13231
13338
|
}
|
|
13232
|
-
},
|
|
13233
|
-
function
|
|
13339
|
+
}, Cc = "anonymLogin:", wc = 700, Tc = 3e3;
|
|
13340
|
+
function Ec(e) {
|
|
13234
13341
|
let t = e.error_code;
|
|
13235
13342
|
switch (t) {
|
|
13236
|
-
case 2: return
|
|
13237
|
-
case 4: return e.error_msg.includes("participants.limit.exceeded") ?
|
|
13238
|
-
case 300: return
|
|
13239
|
-
case 1101: return
|
|
13240
|
-
case 1102: return
|
|
13241
|
-
case 1103: return
|
|
13242
|
-
case 1104: return
|
|
13243
|
-
case 1106: return
|
|
13244
|
-
case 1113: return
|
|
13343
|
+
case 2: return Dc(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
|
|
13344
|
+
case 4: return e.error_msg.includes("participants.limit.exceeded") ? Dc(O.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : Dc(x.API, t, "request-error");
|
|
13345
|
+
case 300: return Dc(O.NOT_FOUND, t, "not-found");
|
|
13346
|
+
case 1101: return Dc(O.SERVICE_DISABLED, t, "vchat-service-disabled");
|
|
13347
|
+
case 1102: return Dc(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
|
|
13348
|
+
case 1103: return Dc(O.NOT_FRIENDS, t, "friendship-required");
|
|
13349
|
+
case 1104: return kc(t, "youla-api-error");
|
|
13350
|
+
case 1106: return kc(t, "vk-api-error");
|
|
13351
|
+
case 1113: return Dc(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
|
|
13245
13352
|
case 1114: {
|
|
13246
13353
|
let n = e.custom_error?.vchat_detailed_api_error?.code, r = n?.startsWith("obsolete_client");
|
|
13247
|
-
return
|
|
13354
|
+
return Dc(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
|
|
13248
13355
|
}
|
|
13249
|
-
default: return
|
|
13356
|
+
default: return Dc(x.API, t, "api-error");
|
|
13250
13357
|
}
|
|
13251
13358
|
}
|
|
13252
|
-
function
|
|
13359
|
+
function Dc(e, t, n, r) {
|
|
13253
13360
|
return {
|
|
13254
13361
|
type: e,
|
|
13255
13362
|
callError: {
|
|
@@ -13261,10 +13368,10 @@ function Tc(e, t, n, r) {
|
|
|
13261
13368
|
message: r
|
|
13262
13369
|
};
|
|
13263
13370
|
}
|
|
13264
|
-
function
|
|
13371
|
+
function Oc(e) {
|
|
13265
13372
|
return e?.error_code === void 0 ? e instanceof k && e.callError && "code" in e.callError ? String(e.callError.code) : e instanceof Error ? e.name : "network" : String(e.error_code);
|
|
13266
13373
|
}
|
|
13267
|
-
function
|
|
13374
|
+
function kc(e, t) {
|
|
13268
13375
|
return {
|
|
13269
13376
|
type: O.EXTERNAL_API_ERROR,
|
|
13270
13377
|
callError: {
|
|
@@ -13275,21 +13382,21 @@ function Dc(e, t) {
|
|
|
13275
13382
|
}
|
|
13276
13383
|
};
|
|
13277
13384
|
}
|
|
13278
|
-
var
|
|
13385
|
+
var Ac = class extends xc {
|
|
13279
13386
|
constructor(...e) {
|
|
13280
|
-
super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new
|
|
13387
|
+
super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new Sc());
|
|
13281
13388
|
}
|
|
13282
13389
|
async _callUnsafe(e, t = {}, n = !1) {
|
|
13283
13390
|
let r = async (i) => {
|
|
13284
13391
|
let a = performance.now();
|
|
13285
13392
|
try {
|
|
13286
|
-
let r = await
|
|
13393
|
+
let r = await xs(e, t, n);
|
|
13287
13394
|
return this._apiCallStats?.log(e, performance.now() - a), r;
|
|
13288
13395
|
} catch (t) {
|
|
13289
|
-
if (this._apiCallStats?.log(e, performance.now() - a,
|
|
13396
|
+
if (this._apiCallStats?.log(e, performance.now() - a, Oc(t)), !t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
|
|
13290
13397
|
i++;
|
|
13291
13398
|
let n = t && (typeof t == "object" || typeof t == "function") ? Object.getOwnPropertyNames(t).map((e) => `${e}: ${JSON.stringify(t[e])}`) : [String(t)];
|
|
13292
|
-
if (z.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (z.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < N.apiMaxAttempt) return await M.delay(Math.min(i *
|
|
13399
|
+
if (z.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (z.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < N.apiMaxAttempt) return await M.delay(Math.min(i * wc, Tc), { signal: this._abortSignal }), r(i);
|
|
13293
13400
|
}
|
|
13294
13401
|
throw z.warn(e, "error", t), t;
|
|
13295
13402
|
}
|
|
@@ -13301,13 +13408,13 @@ var Oc = class extends yc {
|
|
|
13301
13408
|
return await this._callUnsafe(e, t, n);
|
|
13302
13409
|
} catch (i) {
|
|
13303
13410
|
if (z.warn("Api call error", i), i instanceof k) throw i;
|
|
13304
|
-
if (
|
|
13411
|
+
if (rs(i?.error_code) && r) return await this._reauthorize(), this._call(e, t, n, !1);
|
|
13305
13412
|
let a = {
|
|
13306
13413
|
message: i?.error_msg,
|
|
13307
13414
|
code: i?.error_code
|
|
13308
13415
|
};
|
|
13309
|
-
if (i.custom_error && (a.custom_error = i.custom_error),
|
|
13310
|
-
let e =
|
|
13416
|
+
if (i.custom_error && (a.custom_error = i.custom_error), jc(i)) {
|
|
13417
|
+
let e = Ec(i);
|
|
13311
13418
|
throw a.callError = e.callError, a.message = e.message ?? a.message, new k(e.type, a);
|
|
13312
13419
|
}
|
|
13313
13420
|
throw new k(x.API, a);
|
|
@@ -13337,7 +13444,7 @@ var Oc = class extends yc {
|
|
|
13337
13444
|
return this._anonymLogin(N.authToken).then((e) => {
|
|
13338
13445
|
this._applyAnonymLogin(e), this._setCachedAnonymLogin(e);
|
|
13339
13446
|
}).catch((e) => {
|
|
13340
|
-
throw e instanceof k ? e : (e?.error_code ===
|
|
13447
|
+
throw e instanceof k ? e : (e?.error_code === ns.AUTH_LOGIN && (this._removeCachedAnonymLogin(), R.onTokenExpired()), new k(x.AUTH, {
|
|
13341
13448
|
message: e?.error_msg,
|
|
13342
13449
|
code: e?.error_code,
|
|
13343
13450
|
callError: {
|
|
@@ -13359,17 +13466,17 @@ var Oc = class extends yc {
|
|
|
13359
13466
|
return e && (t.session_data.auth_token = e, t.session_data.version = 3), this._callUnsafe("auth.anonymLogin", t, !0);
|
|
13360
13467
|
}
|
|
13361
13468
|
_getAnonymLoginCacheKey() {
|
|
13362
|
-
return N.authToken ? `${
|
|
13469
|
+
return N.authToken ? `${Cc}${N.authToken}` : null;
|
|
13363
13470
|
}
|
|
13364
13471
|
_getCachedAnonymLogin() {
|
|
13365
13472
|
let e = this._getAnonymLoginCacheKey();
|
|
13366
13473
|
if (!e) return null;
|
|
13367
13474
|
let t = w.get(e);
|
|
13368
|
-
return
|
|
13475
|
+
return Mc(t) ? t : (t && w.remove(e), null);
|
|
13369
13476
|
}
|
|
13370
13477
|
_setCachedAnonymLogin(e) {
|
|
13371
13478
|
let t = this._getAnonymLoginCacheKey();
|
|
13372
|
-
!t || !
|
|
13479
|
+
!t || !Mc(e) || w.set(t, {
|
|
13373
13480
|
session_key: e.session_key,
|
|
13374
13481
|
session_secret_key: e.session_secret_key,
|
|
13375
13482
|
uid: e.uid
|
|
@@ -13383,9 +13490,9 @@ var Oc = class extends yc {
|
|
|
13383
13490
|
return this._removeCachedAnonymLogin(), y.reauthorize(() => this.authorize());
|
|
13384
13491
|
}
|
|
13385
13492
|
_applyAnonymLogin(e) {
|
|
13386
|
-
e.uid && (y.userId = Number(e.uid)), y.sessionKey = e.session_key, y.sessionSecretKey = e.session_secret_key, N.statQueueEnabled && e.uid &&
|
|
13493
|
+
e.uid && (y.userId = Number(e.uid)), y.sessionKey = e.session_key, y.sessionSecretKey = e.session_secret_key, N.statQueueEnabled && e.uid && ks.remember(Number(e.uid), {
|
|
13387
13494
|
sessionKey: e.session_key,
|
|
13388
|
-
endpoint:
|
|
13495
|
+
endpoint: ks.currentEndpoint()
|
|
13389
13496
|
});
|
|
13390
13497
|
}
|
|
13391
13498
|
_buildClientStatsData(e) {
|
|
@@ -13404,7 +13511,7 @@ var Oc = class extends yc {
|
|
|
13404
13511
|
});
|
|
13405
13512
|
}
|
|
13406
13513
|
async _sendClientStatsWith(e, t) {
|
|
13407
|
-
let n = await
|
|
13514
|
+
let n = await xs("vchat.clientStats", {
|
|
13408
13515
|
...t,
|
|
13409
13516
|
session_key: e
|
|
13410
13517
|
}, !0);
|
|
@@ -13412,10 +13519,10 @@ var Oc = class extends yc {
|
|
|
13412
13519
|
}
|
|
13413
13520
|
async _sendClientStats(e, t, n = !0) {
|
|
13414
13521
|
try {
|
|
13415
|
-
let n = t ? await
|
|
13522
|
+
let n = t ? await Ss("vchat.clientStats", e) : await xs("vchat.clientStats", e);
|
|
13416
13523
|
this._reportClientStatsItemErrors(n);
|
|
13417
13524
|
} catch (r) {
|
|
13418
|
-
if (!n || !
|
|
13525
|
+
if (!n || !rs(r?.error_code)) throw r;
|
|
13419
13526
|
await this._reauthorize(), await this._sendClientStats(e, t, !1);
|
|
13420
13527
|
}
|
|
13421
13528
|
}
|
|
@@ -13439,14 +13546,14 @@ var Oc = class extends yc {
|
|
|
13439
13546
|
}, a = await this._callUnsafe("vchat.getLogUploadUrl", i), o = new FormData(), s = new Blob([r], { type: "application/json" });
|
|
13440
13547
|
o.append("file", s, "log.json");
|
|
13441
13548
|
let c = new URL(a.upload_url);
|
|
13442
|
-
return c.searchParams.append("size", s.size.toString()),
|
|
13549
|
+
return c.searchParams.append("size", s.size.toString()), Ts(c.toString(), o);
|
|
13443
13550
|
}
|
|
13444
13551
|
async joinConversation(e, t = !1, n) {
|
|
13445
13552
|
let r = {
|
|
13446
13553
|
conversationId: e,
|
|
13447
13554
|
isVideo: t,
|
|
13448
13555
|
protocolVersion: N.protocolVersion,
|
|
13449
|
-
capabilities:
|
|
13556
|
+
capabilities: Va.getFlags()
|
|
13450
13557
|
};
|
|
13451
13558
|
return n && (r.chatId = n), this._call("vchat.joinConversation", r);
|
|
13452
13559
|
}
|
|
@@ -13478,13 +13585,13 @@ var Oc = class extends yc {
|
|
|
13478
13585
|
externalIds: l
|
|
13479
13586
|
});
|
|
13480
13587
|
if (t && t.length) switch (n) {
|
|
13481
|
-
case
|
|
13588
|
+
case co.USER:
|
|
13482
13589
|
u.uids = t.join(",");
|
|
13483
13590
|
break;
|
|
13484
|
-
case
|
|
13591
|
+
case co.GROUP:
|
|
13485
13592
|
u.gid = t[0];
|
|
13486
13593
|
break;
|
|
13487
|
-
case
|
|
13594
|
+
case co.CHAT:
|
|
13488
13595
|
u.chatId = t[0];
|
|
13489
13596
|
break;
|
|
13490
13597
|
}
|
|
@@ -13527,7 +13634,7 @@ var Oc = class extends yc {
|
|
|
13527
13634
|
joinLink: e,
|
|
13528
13635
|
isVideo: t,
|
|
13529
13636
|
protocolVersion: N.protocolVersion,
|
|
13530
|
-
capabilities:
|
|
13637
|
+
capabilities: Va.getFlags()
|
|
13531
13638
|
};
|
|
13532
13639
|
return n?.length && (i.observedIds = n.join(",")), N.anonymToken && (i.anonymToken = N.anonymToken), r && (i.payload = r), this._call("vchat.joinConversationByLink", i);
|
|
13533
13640
|
}
|
|
@@ -13557,9 +13664,9 @@ var Oc = class extends yc {
|
|
|
13557
13664
|
return y.userId;
|
|
13558
13665
|
}
|
|
13559
13666
|
setUserId(e) {
|
|
13560
|
-
y.userId = e, N.statQueueEnabled && y.sessionKey &&
|
|
13667
|
+
y.userId = e, N.statQueueEnabled && y.sessionKey && ks.remember(Number(e), {
|
|
13561
13668
|
sessionKey: y.sessionKey,
|
|
13562
|
-
endpoint:
|
|
13669
|
+
endpoint: ks.currentEndpoint()
|
|
13563
13670
|
});
|
|
13564
13671
|
}
|
|
13565
13672
|
hangupConversation(e, t = O.HUNGUP, n) {
|
|
@@ -13567,7 +13674,7 @@ var Oc = class extends yc {
|
|
|
13567
13674
|
conversationId: e,
|
|
13568
13675
|
reason: t
|
|
13569
13676
|
};
|
|
13570
|
-
N.anonymToken && (r.anonymToken = N.anonymToken), n?.peerId && (r.peerId = n.peerId),
|
|
13677
|
+
N.anonymToken && (r.anonymToken = N.anonymToken), n?.peerId && (r.peerId = n.peerId), bs("vchat.hangupConversation", r);
|
|
13571
13678
|
}
|
|
13572
13679
|
async removeHistoryRecords(e) {
|
|
13573
13680
|
await this._call("vchat.removeHistoryRecords", { recordIds: e.join(",") });
|
|
@@ -13583,19 +13690,19 @@ var Oc = class extends yc {
|
|
|
13583
13690
|
return Array.isArray(e?.inbounds) ? e.inbounds : [];
|
|
13584
13691
|
}
|
|
13585
13692
|
};
|
|
13586
|
-
function
|
|
13693
|
+
function jc(e) {
|
|
13587
13694
|
return typeof e == "object" && !!e && "error_code" in e && "error_msg" in e;
|
|
13588
13695
|
}
|
|
13589
|
-
function
|
|
13696
|
+
function Mc(e) {
|
|
13590
13697
|
return typeof e == "object" && !!e && "session_key" in e && "session_secret_key" in e && typeof e.session_key == "string" && e.session_key.length > 0 && typeof e.session_secret_key == "string" && e.session_secret_key.length > 0;
|
|
13591
13698
|
}
|
|
13592
13699
|
//#endregion
|
|
13593
13700
|
//#region src/enums/RecordRole.ts
|
|
13594
|
-
var
|
|
13701
|
+
var Nc = /* @__PURE__ */ function(e) {
|
|
13595
13702
|
return e.KING = "KING", e.PAWN = "PAWN", e;
|
|
13596
|
-
}(
|
|
13703
|
+
}(Nc || {}), Pc = /* @__PURE__ */ function(e) {
|
|
13597
13704
|
return e.OFF = "0", e.ON = "1", e;
|
|
13598
|
-
}({}),
|
|
13705
|
+
}({}), Fc = class {
|
|
13599
13706
|
constructor(e) {
|
|
13600
13707
|
h(this, "_queue", void 0), h(this, "_readCursor", void 0), h(this, "_writeCursor", void 0), h(this, "_moveReadCursor", void 0), h(this, "_left", void 0), this._queue = Array(e).fill(null), this._readCursor = this._writeCursor = this._left = 0, this._moveReadCursor = !1;
|
|
13601
13708
|
}
|
|
@@ -13618,12 +13725,12 @@ var jc = /* @__PURE__ */ function(e) {
|
|
|
13618
13725
|
let e = this._queue[this._readCursor];
|
|
13619
13726
|
return e && (this._moveReadCursor = !1, this._queue[this._readCursor] = null, this._readCursor = this.nextCursor(this._readCursor), --this._left), e;
|
|
13620
13727
|
}
|
|
13621
|
-
},
|
|
13728
|
+
}, Ic = class {
|
|
13622
13729
|
constructor(e, t, n, r = null) {
|
|
13623
13730
|
h(this, "_uuid", void 0), h(this, "_apiKey", void 0), h(this, "_callToken", void 0), h(this, "_apiEnv", void 0), h(this, "_baseApiUrl", void 0), h(this, "_sessionKey", void 0), this._uuid = M.uuid(), this._apiKey = t, this._callToken = n, this._apiEnv = e, this._baseApiUrl = r;
|
|
13624
13731
|
}
|
|
13625
13732
|
async authorize() {
|
|
13626
|
-
let e = await
|
|
13733
|
+
let e = await xs("auth.anonymLogin", {
|
|
13627
13734
|
session_data: {
|
|
13628
13735
|
device_id: this._uuid,
|
|
13629
13736
|
client_version: N.apiClientVersion,
|
|
@@ -13632,7 +13739,7 @@ var jc = /* @__PURE__ */ function(e) {
|
|
|
13632
13739
|
version: 3
|
|
13633
13740
|
},
|
|
13634
13741
|
application_key: this._apiKey
|
|
13635
|
-
}, !0, await
|
|
13742
|
+
}, !0, await vs(this._baseApiUrl, this._apiEnv));
|
|
13636
13743
|
return M.isObject(e) && !("error_msg" in e) ? (this._sessionKey = e.session_key, !0) : !1;
|
|
13637
13744
|
}
|
|
13638
13745
|
async hangupConversation(e, t) {
|
|
@@ -13642,9 +13749,9 @@ var jc = /* @__PURE__ */ function(e) {
|
|
|
13642
13749
|
application_key: this._apiKey,
|
|
13643
13750
|
session_key: this._sessionKey
|
|
13644
13751
|
};
|
|
13645
|
-
t?.peerId && (n.peerId = t.peerId), await
|
|
13752
|
+
t?.peerId && (n.peerId = t.peerId), await xs("vchat.hangupConversation", n, !0, await vs(this._baseApiUrl, this._apiEnv));
|
|
13646
13753
|
}
|
|
13647
|
-
},
|
|
13754
|
+
}, Lc, Rc = null, zc = !1, Bc = {
|
|
13648
13755
|
getCameras: E.getCameras,
|
|
13649
13756
|
getMicrophones: E.getMicrophones,
|
|
13650
13757
|
getOutput: E.getOutput,
|
|
@@ -13670,27 +13777,27 @@ var jc = /* @__PURE__ */ function(e) {
|
|
|
13670
13777
|
baseChromeVersion: E.baseChromeVersion,
|
|
13671
13778
|
getAudioContext: E.getAudioContext,
|
|
13672
13779
|
isAudioShareSupported: E.isAudioShareSupported
|
|
13673
|
-
},
|
|
13674
|
-
function
|
|
13675
|
-
|
|
13780
|
+
}, Vc = { participantMarkerCompare: M.participantMarkerCompare };
|
|
13781
|
+
function Hc(e) {
|
|
13782
|
+
Rc = e;
|
|
13676
13783
|
}
|
|
13677
|
-
function
|
|
13784
|
+
function Uc(e) {
|
|
13678
13785
|
N.videoEffects = e;
|
|
13679
13786
|
}
|
|
13680
|
-
function
|
|
13787
|
+
function Wc(e) {
|
|
13681
13788
|
N.audioEffects = e;
|
|
13682
13789
|
}
|
|
13683
|
-
function
|
|
13790
|
+
function Gc(e, t = {}) {
|
|
13684
13791
|
N.vad = e, N.vadOptions = t;
|
|
13685
13792
|
}
|
|
13686
|
-
function
|
|
13793
|
+
function Kc(e, t = null, n = {}, r = 1) {
|
|
13687
13794
|
N.vmoji = e, N.vmojiOptions = {
|
|
13688
13795
|
protocolVersion: r,
|
|
13689
13796
|
renderingOptions: n
|
|
13690
13797
|
}, t && e.setSDK(t);
|
|
13691
13798
|
}
|
|
13692
|
-
async function
|
|
13693
|
-
N.set(t),
|
|
13799
|
+
async function qc(t) {
|
|
13800
|
+
N.set(t), Lc || (Lc = new Ac()), N.statQueueEnabled && (js.setApi(Lc), N.autoStartStats && el()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
|
|
13694
13801
|
let n = E.getBrowserSupportFailure();
|
|
13695
13802
|
if (n) throw new k(x.UNSUPPORTED, { callError: {
|
|
13696
13803
|
scope: "internal",
|
|
@@ -13699,19 +13806,19 @@ async function Gc(t) {
|
|
|
13699
13806
|
} });
|
|
13700
13807
|
z.log("UserAgent:", navigator.userAgent), z.log("Screen resolution:", `${window.screen.width}x${window.screen.height}`), z.log("Permissions:", `Camera: ${E.hasCameraPermission()}, Mic: ${E.hasMicrophonePermission()}`), z.log("Simulcast:", `${t.simulcast} => ${N.simulcast}`);
|
|
13701
13808
|
}
|
|
13702
|
-
async function
|
|
13809
|
+
async function Jc(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
|
|
13703
13810
|
let c = [];
|
|
13704
|
-
return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]),
|
|
13811
|
+
return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Xc([], co.USER, t, n, r, i, a, c, o, s);
|
|
13705
13812
|
}
|
|
13706
|
-
function
|
|
13813
|
+
function Yc(e, t = []) {
|
|
13707
13814
|
let n = e.getIncomingCallerExternalId();
|
|
13708
13815
|
return n ? t.length === 1 && t[0].id === n.id && t[0].type === n.type : !1;
|
|
13709
13816
|
}
|
|
13710
|
-
async function
|
|
13817
|
+
async function Xc(e, t = co.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
|
|
13711
13818
|
if (!N.hold && B.getActive()) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
|
|
13712
13819
|
let u = B.getAll().find((e) => e.isIncomingRinging);
|
|
13713
|
-
if (!N.hold && u && !
|
|
13714
|
-
return new $(new
|
|
13820
|
+
if (!N.hold && u && !Yc(u, s)) throw z.error("There is already incoming call"), new k(O.HAS_ACTIVE_CALL);
|
|
13821
|
+
return new $(new Ac(), Rc).onStart({
|
|
13715
13822
|
opponentIds: e,
|
|
13716
13823
|
opponentType: t,
|
|
13717
13824
|
mediaOptions: n,
|
|
@@ -13724,49 +13831,49 @@ async function Jc(e, t = no.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
|
|
|
13724
13831
|
conversationId: l
|
|
13725
13832
|
});
|
|
13726
13833
|
}
|
|
13727
|
-
async function
|
|
13728
|
-
return
|
|
13834
|
+
async function Zc(e, t) {
|
|
13835
|
+
return Qc(e, j.USER, void 0, t);
|
|
13729
13836
|
}
|
|
13730
|
-
async function
|
|
13837
|
+
async function Qc(e, t = j.USER, n, r, i, a) {
|
|
13731
13838
|
if (e === $.id()) throw Error("Push has already been processed");
|
|
13732
|
-
return new $(new
|
|
13839
|
+
return new $(new Ac(), Rc).onPush(e, t, n, r, i, a);
|
|
13733
13840
|
}
|
|
13734
|
-
async function
|
|
13735
|
-
return
|
|
13841
|
+
async function $c() {
|
|
13842
|
+
return Lc.getInbounds();
|
|
13736
13843
|
}
|
|
13737
|
-
function
|
|
13844
|
+
function el() {
|
|
13738
13845
|
if (N.statQueueEnabled) {
|
|
13739
|
-
if (!
|
|
13846
|
+
if (!Lc) {
|
|
13740
13847
|
z.error("[CallsSDK] startStats() called before init()");
|
|
13741
13848
|
return;
|
|
13742
13849
|
}
|
|
13743
|
-
|
|
13850
|
+
zc || (zc = !0, Vs.start(Lc));
|
|
13744
13851
|
}
|
|
13745
13852
|
}
|
|
13746
|
-
async function
|
|
13747
|
-
return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t,
|
|
13853
|
+
async function tl(e, t) {
|
|
13854
|
+
return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, gs()), Lc.authorize();
|
|
13748
13855
|
}
|
|
13749
|
-
async function
|
|
13750
|
-
return
|
|
13856
|
+
async function nl(e = [S.AUDIO], t) {
|
|
13857
|
+
return Du(t).accept(e);
|
|
13751
13858
|
}
|
|
13752
|
-
async function
|
|
13753
|
-
let t =
|
|
13859
|
+
async function rl(e) {
|
|
13860
|
+
let t = wu(e?.conversationId);
|
|
13754
13861
|
if (t) return t.decline(e);
|
|
13755
13862
|
}
|
|
13756
|
-
async function
|
|
13757
|
-
return
|
|
13863
|
+
async function il(e, t = [S.AUDIO]) {
|
|
13864
|
+
return al(e, t);
|
|
13758
13865
|
}
|
|
13759
|
-
async function
|
|
13866
|
+
async function al(e, t, n) {
|
|
13760
13867
|
if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
|
|
13761
|
-
return new $(new
|
|
13868
|
+
return new $(new Ac(), Rc).onJoin({
|
|
13762
13869
|
conversationId: e,
|
|
13763
13870
|
mediaOptions: t,
|
|
13764
13871
|
chatId: n
|
|
13765
13872
|
});
|
|
13766
13873
|
}
|
|
13767
|
-
async function
|
|
13874
|
+
async function ol(e, t = [S.AUDIO], n, r, i, a) {
|
|
13768
13875
|
if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
|
|
13769
|
-
return n && (N.anonymToken = n), new $(new
|
|
13876
|
+
return n && (N.anonymToken = n), new $(new Ac(), Rc).onJoin({
|
|
13770
13877
|
joinLink: e,
|
|
13771
13878
|
mediaOptions: t,
|
|
13772
13879
|
observedIds: r,
|
|
@@ -13775,30 +13882,30 @@ async function il(e, t = [S.AUDIO], n, r, i, a) {
|
|
|
13775
13882
|
anonymous: !!N.anonymToken
|
|
13776
13883
|
});
|
|
13777
13884
|
}
|
|
13778
|
-
function
|
|
13779
|
-
let t =
|
|
13885
|
+
function sl(e) {
|
|
13886
|
+
let t = wu(e?.conversationId);
|
|
13780
13887
|
return t ? t.hangup(e) : ($.hangupAfterInit(e?.onFastHangup), Promise.resolve());
|
|
13781
13888
|
}
|
|
13782
|
-
async function
|
|
13889
|
+
async function cl(e, t) {
|
|
13783
13890
|
let n = Array.isArray(e) ? e : [e], r = $.current();
|
|
13784
13891
|
r && await r.addParticipant(n, t);
|
|
13785
13892
|
}
|
|
13786
|
-
async function
|
|
13893
|
+
async function ll(e, t) {
|
|
13787
13894
|
let n = $.current();
|
|
13788
13895
|
if (n) {
|
|
13789
13896
|
let r = e.map((e) => M.composeUserId(e));
|
|
13790
13897
|
await n.addParticipantLegacy(r, t);
|
|
13791
13898
|
}
|
|
13792
13899
|
}
|
|
13793
|
-
async function
|
|
13794
|
-
let n =
|
|
13900
|
+
async function ul(e, t = !1) {
|
|
13901
|
+
let n = Ou(e, "removeParticipant");
|
|
13795
13902
|
if (n) try {
|
|
13796
13903
|
await n.conversation.removeParticipant(M.decomposeParticipantId(n.participantId).compositeUserId, t);
|
|
13797
13904
|
} catch (e) {
|
|
13798
13905
|
z.warn(`Failed to remove participant ${n.participantId}. Perhaps he is no longer on the call. ${e}`);
|
|
13799
13906
|
}
|
|
13800
13907
|
}
|
|
13801
|
-
async function
|
|
13908
|
+
async function dl(e, t = !1) {
|
|
13802
13909
|
let n = $.current();
|
|
13803
13910
|
if (n) try {
|
|
13804
13911
|
await n.removeParticipant(M.composeUserId(e), t);
|
|
@@ -13806,13 +13913,13 @@ async function ll(e, t = !1) {
|
|
|
13806
13913
|
z.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
|
|
13807
13914
|
}
|
|
13808
13915
|
}
|
|
13809
|
-
async function
|
|
13916
|
+
async function fl(e, t) {
|
|
13810
13917
|
let n = $.current();
|
|
13811
13918
|
if (e === "videoinput" && jt.contains(t)) return N.videoFacingMode = t, n ? (E.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
|
|
13812
13919
|
if (!await E._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
|
|
13813
13920
|
if (n) return n.changeDevice(e);
|
|
13814
13921
|
}
|
|
13815
|
-
async function
|
|
13922
|
+
async function pl(e, t) {
|
|
13816
13923
|
let n = typeof e == "object" ? {
|
|
13817
13924
|
...e,
|
|
13818
13925
|
fastScreenSharing: e.captureScreen && e.fastScreenSharing,
|
|
@@ -13821,40 +13928,40 @@ async function dl(e, t) {
|
|
|
13821
13928
|
captureScreen: e,
|
|
13822
13929
|
fastScreenSharing: !1,
|
|
13823
13930
|
captureAudio: !1
|
|
13824
|
-
}, r =
|
|
13931
|
+
}, r = wu(t);
|
|
13825
13932
|
return r ? r.toggleScreenCapturing(n) : Promise.reject();
|
|
13826
13933
|
}
|
|
13827
|
-
function
|
|
13934
|
+
function ml(e) {
|
|
13828
13935
|
let t = $.current();
|
|
13829
13936
|
t && t.toggleAnimojiCapturing(e);
|
|
13830
13937
|
}
|
|
13831
|
-
async function
|
|
13938
|
+
async function hl(e, t = !1) {
|
|
13832
13939
|
let n = $.current();
|
|
13833
13940
|
n && await n.setVideoStream(e, t);
|
|
13834
13941
|
}
|
|
13835
|
-
async function
|
|
13836
|
-
let n =
|
|
13942
|
+
async function gl(e, t) {
|
|
13943
|
+
let n = wu(t);
|
|
13837
13944
|
n && await n.toggleLocalVideo(e);
|
|
13838
13945
|
}
|
|
13839
|
-
async function
|
|
13840
|
-
let n =
|
|
13946
|
+
async function _l(e, t) {
|
|
13947
|
+
let n = wu(t);
|
|
13841
13948
|
n && await n.toggleLocalAudio(e);
|
|
13842
13949
|
}
|
|
13843
|
-
async function
|
|
13950
|
+
async function vl(e) {
|
|
13844
13951
|
let t = $.current();
|
|
13845
13952
|
if (t) return t.setLocalResolution(e);
|
|
13846
13953
|
}
|
|
13847
|
-
async function
|
|
13954
|
+
async function yl(e) {
|
|
13848
13955
|
let t = $.current();
|
|
13849
13956
|
t && await t.changePriorities(e);
|
|
13850
13957
|
}
|
|
13851
|
-
async function
|
|
13958
|
+
async function bl(e, t) {
|
|
13852
13959
|
let n = $.current();
|
|
13853
13960
|
if (n) {
|
|
13854
13961
|
if (t) {
|
|
13855
13962
|
let r = n.getCachedParticipantIdByExternalId(t);
|
|
13856
13963
|
if (!r) {
|
|
13857
|
-
|
|
13964
|
+
Tu(t, "changeParticipantState", n);
|
|
13858
13965
|
return;
|
|
13859
13966
|
}
|
|
13860
13967
|
await n.changeParticipantState(e, r);
|
|
@@ -13863,161 +13970,161 @@ async function vl(e, t) {
|
|
|
13863
13970
|
await n.changeParticipantState(e);
|
|
13864
13971
|
}
|
|
13865
13972
|
}
|
|
13866
|
-
async function
|
|
13973
|
+
async function xl() {
|
|
13867
13974
|
let e = $.current();
|
|
13868
13975
|
e && await e.putHandsDown();
|
|
13869
13976
|
}
|
|
13870
|
-
async function
|
|
13977
|
+
async function Sl(e) {
|
|
13871
13978
|
let t = $.current();
|
|
13872
13979
|
t && await t.updateDisplayLayout(e);
|
|
13873
13980
|
}
|
|
13874
|
-
async function
|
|
13981
|
+
async function Cl(e) {
|
|
13875
13982
|
let t = $.current();
|
|
13876
13983
|
t && await t.requestDisplayLayout(e);
|
|
13877
13984
|
}
|
|
13878
|
-
async function
|
|
13879
|
-
let r =
|
|
13985
|
+
async function wl(e, t, n = !1) {
|
|
13986
|
+
let r = Ou(e, "grantRoles");
|
|
13880
13987
|
r && await r.conversation.grantRoles(r.participantId, t, n);
|
|
13881
13988
|
}
|
|
13882
|
-
async function
|
|
13989
|
+
async function Tl(e, t, n, r = !1) {
|
|
13883
13990
|
let i = $.current();
|
|
13884
13991
|
i && await i.grantRoles(M.composeParticipantId(e, j.USER, t), n, r);
|
|
13885
13992
|
}
|
|
13886
|
-
async function
|
|
13993
|
+
async function El({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
|
|
13887
13994
|
if (e) {
|
|
13888
|
-
let i =
|
|
13995
|
+
let i = Ou(e, "muteParticipant");
|
|
13889
13996
|
return i ? i.conversation.muteParticipant(i.participantId, t, n, r) : void 0;
|
|
13890
13997
|
}
|
|
13891
13998
|
let i = $.current();
|
|
13892
13999
|
i && await i.muteParticipant(null, t, n, r);
|
|
13893
14000
|
}
|
|
13894
|
-
async function
|
|
14001
|
+
async function Dl({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
|
|
13895
14002
|
let a = $.current();
|
|
13896
14003
|
if (a) {
|
|
13897
14004
|
let o = e ? M.composeParticipantId(e, j.USER, r) : null;
|
|
13898
14005
|
await a.muteParticipant(o, t, n, i);
|
|
13899
14006
|
}
|
|
13900
14007
|
}
|
|
13901
|
-
async function
|
|
13902
|
-
let r =
|
|
14008
|
+
async function Ol(e, t = !1, n = null) {
|
|
14009
|
+
let r = Ou(e, "pinParticipant");
|
|
13903
14010
|
r && await r.conversation.pinParticipant(r.participantId, t, n);
|
|
13904
14011
|
}
|
|
13905
|
-
async function
|
|
14012
|
+
async function kl(e, t = !1, n = 0, r = null) {
|
|
13906
14013
|
let i = $.current();
|
|
13907
14014
|
i && await i.pinParticipant(M.composeParticipantId(e, j.USER, n), t, r);
|
|
13908
14015
|
}
|
|
13909
|
-
async function
|
|
14016
|
+
async function Al(e) {
|
|
13910
14017
|
let t = $.current();
|
|
13911
14018
|
t && await t.updateMediaModifiers(e);
|
|
13912
14019
|
}
|
|
13913
|
-
async function
|
|
14020
|
+
async function jl(e) {
|
|
13914
14021
|
let t = $.current();
|
|
13915
14022
|
t && await t.enableVideoSuspend(e);
|
|
13916
14023
|
}
|
|
13917
|
-
async function
|
|
14024
|
+
async function Ml(e) {
|
|
13918
14025
|
let t = $.current();
|
|
13919
14026
|
t && await t.enableVideoSuspendSuggest(e);
|
|
13920
14027
|
}
|
|
13921
|
-
async function
|
|
14028
|
+
async function Nl(e) {
|
|
13922
14029
|
let t = $.current();
|
|
13923
14030
|
t && await t.changeOptions(e);
|
|
13924
14031
|
}
|
|
13925
|
-
async function
|
|
14032
|
+
async function Pl(e, t = null) {
|
|
13926
14033
|
if (t) {
|
|
13927
|
-
let n =
|
|
14034
|
+
let n = Ou(t, "chatMessage");
|
|
13928
14035
|
return n ? n.conversation.chatMessage(e, M.decomposeParticipantId(n.participantId).compositeUserId) : void 0;
|
|
13929
14036
|
}
|
|
13930
14037
|
let n = $.current();
|
|
13931
14038
|
n && await n.chatMessage(e, null);
|
|
13932
14039
|
}
|
|
13933
|
-
async function
|
|
14040
|
+
async function Fl(e, t = null) {
|
|
13934
14041
|
let n = $.current();
|
|
13935
14042
|
if (n) {
|
|
13936
14043
|
let r = t ? M.composeUserId(t) : null;
|
|
13937
14044
|
await n.chatMessage(e, r);
|
|
13938
14045
|
}
|
|
13939
14046
|
}
|
|
13940
|
-
async function
|
|
14047
|
+
async function Il(e = 10) {
|
|
13941
14048
|
let t = $.current();
|
|
13942
14049
|
if (t) return t.chatHistory(e);
|
|
13943
14050
|
}
|
|
13944
|
-
async function
|
|
14051
|
+
async function Ll(e, t = null) {
|
|
13945
14052
|
if (t) {
|
|
13946
|
-
let n =
|
|
14053
|
+
let n = Ou(t, "customData");
|
|
13947
14054
|
return n ? n.conversation.customData(e, n.participantId) : void 0;
|
|
13948
14055
|
}
|
|
13949
14056
|
let n = $.current();
|
|
13950
14057
|
n && await n.customData(e, null);
|
|
13951
14058
|
}
|
|
13952
|
-
async function
|
|
14059
|
+
async function Rl(e, t = null, n = 0) {
|
|
13953
14060
|
let r = $.current();
|
|
13954
14061
|
if (r) {
|
|
13955
14062
|
let i = t ? M.composeParticipantId(t, j.USER, n) : null;
|
|
13956
14063
|
await r.customData(e, i);
|
|
13957
14064
|
}
|
|
13958
14065
|
}
|
|
13959
|
-
async function
|
|
13960
|
-
return (await
|
|
14066
|
+
async function zl(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
|
|
14067
|
+
return (await Lc.createConversation(a ?? M.uuid(), e, t, {
|
|
13961
14068
|
onlyAdminCanShareMovie: n,
|
|
13962
14069
|
waitForAdmin: r,
|
|
13963
14070
|
closedConversation: i
|
|
13964
14071
|
})).join_link;
|
|
13965
14072
|
}
|
|
13966
|
-
async function
|
|
14073
|
+
async function Bl(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
|
|
13967
14074
|
let a = i.map((e) => Z.fromId(e));
|
|
13968
|
-
return (await
|
|
14075
|
+
return (await Lc.createConversation(M.uuid(), e, t, {
|
|
13969
14076
|
onlyAdminCanShareMovie: n,
|
|
13970
14077
|
audienceMode: !0,
|
|
13971
14078
|
audioOnly: r
|
|
13972
14079
|
}, a)).join_link;
|
|
13973
14080
|
}
|
|
13974
|
-
async function
|
|
14081
|
+
async function Vl() {
|
|
13975
14082
|
let e = $.current();
|
|
13976
14083
|
return e ? e.createJoinLink() : Promise.reject();
|
|
13977
14084
|
}
|
|
13978
|
-
async function
|
|
14085
|
+
async function Hl() {
|
|
13979
14086
|
let e = $.current();
|
|
13980
14087
|
return e ? e.removeJoinLink() : Promise.reject();
|
|
13981
14088
|
}
|
|
13982
|
-
async function
|
|
13983
|
-
return
|
|
14089
|
+
async function Ul(e, t) {
|
|
14090
|
+
return Lc.getAnonymTokenByLink(e, t);
|
|
13984
14091
|
}
|
|
13985
|
-
function
|
|
14092
|
+
function Wl(e) {
|
|
13986
14093
|
let t = $.current();
|
|
13987
14094
|
t && t.setVolume(e);
|
|
13988
14095
|
}
|
|
13989
|
-
function
|
|
14096
|
+
function Gl(e) {
|
|
13990
14097
|
N.forceRelayPolicy = e;
|
|
13991
14098
|
}
|
|
13992
|
-
async function
|
|
14099
|
+
async function Kl(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
|
|
13993
14100
|
let o = $.current();
|
|
13994
14101
|
return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
|
|
13995
14102
|
}
|
|
13996
|
-
async function
|
|
14103
|
+
async function ql(e = null, t) {
|
|
13997
14104
|
let n = $.current();
|
|
13998
14105
|
return n ? n.stopStream(e, t) : Promise.reject();
|
|
13999
14106
|
}
|
|
14000
|
-
async function
|
|
14107
|
+
async function Jl(e = null) {
|
|
14001
14108
|
let t = $.current();
|
|
14002
14109
|
return t ? t.publishStream(e) : Promise.reject();
|
|
14003
14110
|
}
|
|
14004
|
-
async function
|
|
14111
|
+
async function Yl() {
|
|
14005
14112
|
let e = $.current();
|
|
14006
14113
|
return e ? e.getStreamInfo() : Promise.reject();
|
|
14007
14114
|
}
|
|
14008
|
-
async function
|
|
14115
|
+
async function Xl(e) {
|
|
14009
14116
|
let t = $.current();
|
|
14010
14117
|
return t ? t.addMovie(e) : Promise.reject();
|
|
14011
14118
|
}
|
|
14012
|
-
async function
|
|
14119
|
+
async function Zl(e) {
|
|
14013
14120
|
let t = $.current();
|
|
14014
14121
|
return t ? t.updateMovie(e) : Promise.reject();
|
|
14015
14122
|
}
|
|
14016
|
-
async function
|
|
14123
|
+
async function Ql(e) {
|
|
14017
14124
|
let t = $.current();
|
|
14018
14125
|
return t ? t.removeMovie(e) : Promise.reject();
|
|
14019
14126
|
}
|
|
14020
|
-
async function
|
|
14127
|
+
async function $l(e, t) {
|
|
14021
14128
|
let n = $.current();
|
|
14022
14129
|
if (n) {
|
|
14023
14130
|
let r = [], i = [];
|
|
@@ -14039,46 +14146,46 @@ async function Zl(e, t) {
|
|
|
14039
14146
|
});
|
|
14040
14147
|
}
|
|
14041
14148
|
if (i.length) {
|
|
14042
|
-
|
|
14149
|
+
Eu(i, "updateRooms", n);
|
|
14043
14150
|
return;
|
|
14044
14151
|
}
|
|
14045
14152
|
return n.updateRooms(r, t);
|
|
14046
14153
|
}
|
|
14047
14154
|
return Promise.reject();
|
|
14048
14155
|
}
|
|
14049
|
-
async function
|
|
14156
|
+
async function eu(e, t) {
|
|
14050
14157
|
let n = $.current();
|
|
14051
14158
|
return n ? n.activateRooms(e, t) : Promise.reject();
|
|
14052
14159
|
}
|
|
14053
|
-
async function
|
|
14160
|
+
async function tu(e = null, t = null) {
|
|
14054
14161
|
let n = $.current();
|
|
14055
14162
|
if (!n) return Promise.reject();
|
|
14056
14163
|
let r;
|
|
14057
14164
|
if (t && (r = n.getCachedParticipantIdByExternalId(t) ?? void 0, !r)) {
|
|
14058
|
-
|
|
14165
|
+
Tu(t, "switchRoom", n);
|
|
14059
14166
|
return;
|
|
14060
14167
|
}
|
|
14061
14168
|
return n.switchRoom(e, r);
|
|
14062
14169
|
}
|
|
14063
|
-
async function
|
|
14170
|
+
async function nu(e) {
|
|
14064
14171
|
let t = $.current();
|
|
14065
14172
|
return t ? t.removeRooms(e) : Promise.reject();
|
|
14066
14173
|
}
|
|
14067
|
-
function
|
|
14174
|
+
function ru(e) {
|
|
14068
14175
|
N.statisticsInterval = e;
|
|
14069
14176
|
let t = $.current();
|
|
14070
14177
|
if (t) return t.updateStatisticsInterval();
|
|
14071
14178
|
}
|
|
14072
|
-
function
|
|
14179
|
+
function iu(t) {
|
|
14073
14180
|
e.disableLog(!t), z.toggle(t);
|
|
14074
14181
|
}
|
|
14075
|
-
function
|
|
14182
|
+
function au(e, ...t) {
|
|
14076
14183
|
N.debugLog && ($.debugMessage(e, "[external]", ...t) || z.send(e, "[external]", ...t));
|
|
14077
14184
|
}
|
|
14078
|
-
function
|
|
14185
|
+
function ou(e, t, ...n) {
|
|
14079
14186
|
N.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || z.send(e, "[external]", ...n));
|
|
14080
14187
|
}
|
|
14081
|
-
var
|
|
14188
|
+
var su = {
|
|
14082
14189
|
list: Ne,
|
|
14083
14190
|
get: Pe,
|
|
14084
14191
|
getJson: Fe,
|
|
@@ -14086,7 +14193,7 @@ var au = {
|
|
|
14086
14193
|
clear: Le,
|
|
14087
14194
|
stats: Re
|
|
14088
14195
|
};
|
|
14089
|
-
function
|
|
14196
|
+
function cu() {
|
|
14090
14197
|
let e = [
|
|
14091
14198
|
[`Calls SDK ${N.sdkVersion}`, N.toJSON()],
|
|
14092
14199
|
["UserAgent:", navigator.userAgent],
|
|
@@ -14104,139 +14211,139 @@ function ou() {
|
|
|
14104
14211
|
d: e
|
|
14105
14212
|
}));
|
|
14106
14213
|
}
|
|
14107
|
-
async function
|
|
14214
|
+
async function lu() {
|
|
14108
14215
|
let e = $.id(), t = $.debugSessionId();
|
|
14109
14216
|
if (!t || !e) throw z.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
|
|
14110
14217
|
let n = await Pe({ sessionId: t });
|
|
14111
14218
|
if (n.length === 0) throw z.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
|
|
14112
14219
|
let r = n[0].t, i = n[n.length - 1].t;
|
|
14113
14220
|
try {
|
|
14114
|
-
return
|
|
14221
|
+
return Lc?.uploadDebugLogs(e, r, i, JSON.stringify([...cu(), ...n]));
|
|
14115
14222
|
} catch (e) {
|
|
14116
14223
|
throw z.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
|
|
14117
14224
|
}
|
|
14118
14225
|
}
|
|
14119
|
-
async function
|
|
14226
|
+
async function uu(e) {
|
|
14120
14227
|
let t = $.current();
|
|
14121
14228
|
if (t) return t.videoEffect(e);
|
|
14122
14229
|
}
|
|
14123
|
-
async function
|
|
14230
|
+
async function du(e, t) {
|
|
14124
14231
|
let n = $.current();
|
|
14125
14232
|
if (n) return n.audioEffect(e.length > 0 ? e : null, t);
|
|
14126
14233
|
}
|
|
14127
|
-
async function
|
|
14234
|
+
async function fu(e) {
|
|
14128
14235
|
let t = $.current();
|
|
14129
14236
|
t && await t.setAudioStream(e);
|
|
14130
14237
|
}
|
|
14131
|
-
async function
|
|
14238
|
+
async function pu(e, t = null, n = null) {
|
|
14132
14239
|
let r = $.current();
|
|
14133
14240
|
if (!r) return;
|
|
14134
14241
|
let i = n ?? t?.id, a = null;
|
|
14135
14242
|
if (t && (a = r.getCachedParticipantIdByExternalId(t), !a)) {
|
|
14136
|
-
|
|
14243
|
+
Tu(t, "setVmojiSvg", r);
|
|
14137
14244
|
return;
|
|
14138
14245
|
}
|
|
14139
14246
|
r.setAnimojiSvg(e, a, i);
|
|
14140
14247
|
}
|
|
14141
|
-
function
|
|
14248
|
+
function mu(e) {
|
|
14142
14249
|
let t = $.current();
|
|
14143
14250
|
t && t.setAnimojiFill(e);
|
|
14144
14251
|
}
|
|
14145
|
-
async function
|
|
14146
|
-
return
|
|
14252
|
+
async function hu(e = null, t, n = !1) {
|
|
14253
|
+
return Du().getWaitingHall(e, t, n);
|
|
14147
14254
|
}
|
|
14148
|
-
async function
|
|
14149
|
-
return
|
|
14255
|
+
async function gu() {
|
|
14256
|
+
return Du().getAudienceModeHands();
|
|
14150
14257
|
}
|
|
14151
|
-
async function
|
|
14152
|
-
let n =
|
|
14258
|
+
async function _u(e, t = !1) {
|
|
14259
|
+
let n = Du(), r;
|
|
14153
14260
|
if (e) {
|
|
14154
14261
|
let t = n.getCachedParticipantIdByExternalId(e);
|
|
14155
14262
|
if (!t) {
|
|
14156
|
-
|
|
14263
|
+
Tu(e, "promoteParticipant", n);
|
|
14157
14264
|
return;
|
|
14158
14265
|
}
|
|
14159
14266
|
r = M.decomposeParticipantId(t).compositeUserId;
|
|
14160
14267
|
}
|
|
14161
14268
|
return n.promoteParticipant(r, t);
|
|
14162
14269
|
}
|
|
14163
|
-
async function
|
|
14164
|
-
return
|
|
14270
|
+
async function vu(e = !1) {
|
|
14271
|
+
return Du().requestPromotion(e);
|
|
14165
14272
|
}
|
|
14166
|
-
async function
|
|
14167
|
-
return
|
|
14273
|
+
async function yu(e = !1) {
|
|
14274
|
+
return Du().acceptPromotion(e);
|
|
14168
14275
|
}
|
|
14169
|
-
async function
|
|
14170
|
-
return
|
|
14276
|
+
async function bu(e) {
|
|
14277
|
+
return Du().getParticipantListChunk(e);
|
|
14171
14278
|
}
|
|
14172
|
-
async function
|
|
14173
|
-
return
|
|
14279
|
+
async function xu(e) {
|
|
14280
|
+
return Du().getParticipants(e);
|
|
14174
14281
|
}
|
|
14175
|
-
async function
|
|
14176
|
-
return
|
|
14282
|
+
async function Su(e) {
|
|
14283
|
+
return Du().feedback(e);
|
|
14177
14284
|
}
|
|
14178
|
-
async function
|
|
14179
|
-
return
|
|
14285
|
+
async function Cu(e, t, n) {
|
|
14286
|
+
return Du(n).enableFeatureForRoles(e, t);
|
|
14180
14287
|
}
|
|
14181
|
-
function
|
|
14288
|
+
function wu(e) {
|
|
14182
14289
|
return e ? B.get(e) ?? null : $.current() ?? B.getFirst();
|
|
14183
14290
|
}
|
|
14184
|
-
function
|
|
14291
|
+
function Tu(e, t, n) {
|
|
14185
14292
|
R.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external ID "${e.id}" while handling ${t}`), n.id);
|
|
14186
14293
|
}
|
|
14187
|
-
function
|
|
14294
|
+
function Eu(e, t, n) {
|
|
14188
14295
|
let r = Array.from(new Set(e));
|
|
14189
14296
|
R.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external IDs "${r.join("\", \"")}" while handling ${t}`), n.id);
|
|
14190
14297
|
}
|
|
14191
|
-
function
|
|
14192
|
-
let t =
|
|
14298
|
+
function Du(e) {
|
|
14299
|
+
let t = wu(e);
|
|
14193
14300
|
if (!t) throw Error("Conversation not found");
|
|
14194
14301
|
return t;
|
|
14195
14302
|
}
|
|
14196
|
-
function
|
|
14303
|
+
function Ou(e, t) {
|
|
14197
14304
|
let n = $.current();
|
|
14198
14305
|
if (!n) return null;
|
|
14199
14306
|
let r = n.getCachedParticipantIdByExternalId(e);
|
|
14200
14307
|
return r ? {
|
|
14201
14308
|
conversation: n,
|
|
14202
14309
|
participantId: r
|
|
14203
|
-
} : (
|
|
14310
|
+
} : (Tu(e, t, n), null);
|
|
14204
14311
|
}
|
|
14205
|
-
async function
|
|
14206
|
-
await
|
|
14312
|
+
async function ku(e) {
|
|
14313
|
+
await Lc.removeHistoryRecords(e);
|
|
14207
14314
|
}
|
|
14208
|
-
async function
|
|
14315
|
+
async function Au(e) {
|
|
14209
14316
|
let t = $.current() ?? B.getFirst();
|
|
14210
14317
|
t && await t.startAsr(e);
|
|
14211
14318
|
}
|
|
14212
|
-
async function
|
|
14319
|
+
async function ju(e) {
|
|
14213
14320
|
let t = $.current() ?? B.getFirst();
|
|
14214
14321
|
t && await t.stopAsr(e);
|
|
14215
14322
|
}
|
|
14216
|
-
async function
|
|
14323
|
+
async function Mu(e) {
|
|
14217
14324
|
let t = $.current() ?? B.getFirst();
|
|
14218
14325
|
t && await t.requestAsr(e);
|
|
14219
14326
|
}
|
|
14220
|
-
async function
|
|
14327
|
+
async function Nu(e) {
|
|
14221
14328
|
let t = $.current();
|
|
14222
14329
|
return t ? t.startUrlSharing(e) : Promise.reject();
|
|
14223
14330
|
}
|
|
14224
|
-
async function
|
|
14331
|
+
async function Pu() {
|
|
14225
14332
|
let e = $.current();
|
|
14226
14333
|
return e ? e.stopUrlSharing() : Promise.reject();
|
|
14227
14334
|
}
|
|
14228
|
-
async function
|
|
14335
|
+
async function Fu(e) {
|
|
14229
14336
|
await B.switchCall(e);
|
|
14230
14337
|
}
|
|
14231
|
-
function
|
|
14338
|
+
function Iu() {
|
|
14232
14339
|
return B.getActiveId();
|
|
14233
14340
|
}
|
|
14234
|
-
function
|
|
14341
|
+
function Lu() {
|
|
14235
14342
|
return $.getSyncedTime();
|
|
14236
14343
|
}
|
|
14237
|
-
function
|
|
14344
|
+
function Ru() {
|
|
14238
14345
|
return N.sdkVersion;
|
|
14239
14346
|
}
|
|
14240
14347
|
typeof window < "u" && (window.__CALLS_SDK = xn);
|
|
14241
14348
|
//#endregion
|
|
14242
|
-
export {
|
|
14349
|
+
export { Ac as Api, Ic as ApiExternal, Fc as ArrayDequeue, y as AuthData, f as BaseLogger, so as CallDirection, co as CallType, lo as ChatRoomEventType, uo as ConversationFeature, fo as ConversationOption, wn as DebugMessageType, Co as ExternalIdType, jt as FacingMode, x as FatalError, k as HangupReason, O as HangupType, S as MediaOption, A as MediaTrackKind, H as MediaType, ho as MuteState, X as ParticipantState, Pc as ParticipantStateDataValue, P as ParticipantStatus, Nc as RecordRole, go as RoomsEventType, oo as Signaling, V as SignalingCommandType, br as SignalingConnectionType, K as SignalingNotification, U as Stat, J as TransportTopology, yo as UserRole, j as UserType, Ko as VolumeDetector, nl as acceptCall, yu as acceptPromotion, eu as activateRooms, Xl as addMovie, cl as addParticipant, ll as addParticipantInternal, tl as authorize, Bc as browser, Xc as callInternal, Jc as callTo, pl as captureScreen, ml as captureVmoji, du as changeAudioEffect, Nl as changeConversationOptions, fl as changeDevice, bl as changeParticipantState, yl as changePriorities, uu as changeVideoEffect, Il as chatHistory, Pl as chatMessage, Fl as chatMessageInternal, Vl as createJoinLink, Ll as customData, Rl as customDataInternal, iu as debug, su as debugLogs, au as debugMessage, ou as debugMessageWithContext, rl as declineCall, Cu as enableFeatureForRoles, jl as enableVideoSuspend, Ml as enableVideoSuspendSuggest, Su as feedback, Gl as forceRelayPolicy, Iu as getActiveCallId, Ul as getAnonymTokenByLink, gu as getAudienceModeHands, $c as getInbounds, bu as getParticipantListChunk, xu as getParticipants, Yl as getStreamInfo, Lu as getSyncedTime, hu as getWaitingHall, wl as grantRoles, Tl as grantRolesInternal, sl as hangup, qc as init, il as joinCall, ol as joinCallByLink, al as joinCallInternal, El as muteParticipant, Dl as muteParticipantInternal, Ol as pinParticipant, kl as pinParticipantInternal, Zc as processPush, Qc as processPushInternal, _u as promoteParticipant, Jl as publishStream, xl as putHandsDown, ku as removeHistoryRecords, Hl as removeJoinLink, Ql as removeMovie, ul as removeParticipant, dl as removeParticipantInternal, nu as removeRooms, Mu as requestAsr, Cl as requestDisplayLayout, vu as requestPromotion, Wc as setAudioEffects, fu as setAudioStream, vl as setLocalResolution, Hc as setLogger, Al as setMediaModifiers, ru as setStatisticsInterval, Gc as setVad, Uc as setVideoEffects, hl as setVideoStream, Kc as setVmoji, mu as setVmojiFill, pu as setVmojiSvg, Wl as setVolume, Au as startAsr, Bl as startAudienceConversation, zl as startConversation, el as startStats, Kl as startStream, Nu as startUrlSharing, ju as stopAsr, ql as stopStream, Pu as stopUrlSharing, Fu as switchCall, tu as switchRoom, _l as toggleLocalAudio, gl as toggleLocalVideo, Sl as updateDisplayLayout, Zl as updateMovie, $l as updateRooms, lu as uploadDebugLogs, Vc as utils, Ru as version };
|