460 lines
17 KiB
TypeScript
460 lines
17 KiB
TypeScript
// Metro module 10830 (f10831).
|
|
import _slicedToArray from "../_bundle/_slicedToArray";
|
|
import MediaEngineStore from "./MediaEngineStore";
|
|
import UserStore from "./UserStore";
|
|
import { RTCDebugSections } from "../Constants";
|
|
import { MediaEngineContextTypes, SimulcastOverrideQuality, Features } from "../_bundle/Module4250";
|
|
import { chooseReplayPath, open } from "../actions/RTCDebugActionCreators";
|
|
import { BaseConnectionEvent } from "../_bundle/Module4286";
|
|
import Dispatcher from "../Dispatcher";
|
|
import Module589 from "../_bundle/Module589";
|
|
import { HermesBuiltin } from "../_hermes/prelude";
|
|
function $mk85596($env) {
|
|
return (a0) => {
|
|
c7277_12[a0] = {};
|
|
};
|
|
}
|
|
let c7277_10, c7277_12, c7277_13, c7277_14, c7277_20, c7277_18, c7277_21;
|
|
let env7277;
|
|
const r3 = env7277 = {};
|
|
const updateStats = function updateStats(a0, r18 = {}, time = Date.now()) {
|
|
const r41 = {};
|
|
loop5: for (const r21 of Object.entries(a0)) {
|
|
const [r51, value] = r21;
|
|
const r54 = r18[r51];
|
|
const isArray = Array.isArray(value);
|
|
if (isArray) {
|
|
if (typeof value[0] === "object") {
|
|
const r94 = Array.isArray(r54) ? r54 : [];
|
|
const r96 = [];
|
|
r41[r51] = r96;
|
|
let r98 = 0;
|
|
if (0 < value.length) {
|
|
while (true) {
|
|
const r103 = r94[r98];
|
|
const r26 = typeof r103 === "object" ? r103 : {};
|
|
const r108 = r98;
|
|
r96.push(updateStats(value[r108], r26, time));
|
|
const r112 = r108 + 1;
|
|
r98 = r112;
|
|
if (!(r112 < value.length)) {
|
|
continue loop5;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
r41[r51] = value;
|
|
}
|
|
} else {
|
|
if (typeof value === "object" && value !== null) {
|
|
r41[r51] = updateStats(value, typeof r54 === "object" && r54 !== null ? r54 : {}, time);
|
|
continue;
|
|
}
|
|
if (r51 in c7277_14 && typeof value === "number") {
|
|
const r69 = Array.isArray(r54) ? r54 : [];
|
|
r41[r51] = r69;
|
|
r69.push({
|
|
value,
|
|
time
|
|
});
|
|
if (!(r69.length > 600)) {
|
|
continue;
|
|
}
|
|
r69.shift();
|
|
continue;
|
|
}
|
|
r41[r51] = value;
|
|
}
|
|
}
|
|
return r41;
|
|
};
|
|
const MediaEngineContextTypes2 = MediaEngineContextTypes;
|
|
c7277_10 = `${MediaEngineContextTypes2.DEFAULT}:${RTCDebugSections.TRANSPORT}:${0}`;
|
|
env7277[11] = c7277_10;
|
|
c7277_12 = {};
|
|
c7277_13 = new Map();
|
|
c7277_14 = {
|
|
availableOutgoingBitrate: true,
|
|
bitrate: true,
|
|
bitrateTarget: true,
|
|
bytesReceived: true,
|
|
bytesSent: true,
|
|
encoderQualityPsnr: true,
|
|
encoderQualityVmaf: true,
|
|
encodeUsage: true,
|
|
frameRateDecode: true,
|
|
frameRateEncode: true,
|
|
frameRateInput: true,
|
|
frameRateNetwork: true,
|
|
frameRateRender: true,
|
|
keyFramesEncoded: true,
|
|
keyFramesDecoded: true,
|
|
inboundBitrateEstimate: true,
|
|
packetsLost: true,
|
|
packetsReceived: true,
|
|
packetsSent: true,
|
|
ping: true,
|
|
qpSum: true,
|
|
videoEntropy: true,
|
|
audioLevel: true,
|
|
screenshareCapturedFps: true,
|
|
screenshareCapturedFpsUnique: true
|
|
};
|
|
c7277_20 = void 0;
|
|
export class RTCDebugVideoOutputMap {
|
|
constructor(a0) {
|
|
this.state = a0;
|
|
}
|
|
static empty() {
|
|
const state = {};
|
|
const r7 = {
|
|
__proto__: c7277_20.prototype
|
|
};
|
|
r7.state = state;
|
|
return r7;
|
|
}
|
|
put(a0, a1, a2, a3) {
|
|
if (a3 === "") {
|
|
const state2 = {
|
|
...this.state
|
|
};
|
|
delete state2[`${a0}:${a1}:${a2}`];
|
|
const r49 = {
|
|
__proto__: c7277_20.prototype
|
|
};
|
|
r49.state = state2;
|
|
return r49;
|
|
}
|
|
const state = {};
|
|
state[`${a0}:${a1}:${a2}`] = a3;
|
|
HermesBuiltin.copyDataProperties(state, this.state);
|
|
const r28 = {
|
|
__proto__: c7277_20.prototype
|
|
};
|
|
r28.state = state;
|
|
return r28;
|
|
}
|
|
get(a0, a1, a2) {
|
|
const r17 = this.state[`${a0}:${a1}:${a2}`];
|
|
return r17 ?? null;
|
|
}
|
|
}
|
|
c7277_20 = RTCDebugVideoOutputMap;
|
|
env7277[15] = RTCDebugVideoOutputMap.empty();
|
|
env7277[16] = false;
|
|
env7277[17] = null;
|
|
c7277_18 = new Map();
|
|
Object.values(MediaEngineContextTypes2).forEach($mk85596(r3));
|
|
class RTCDebugStore extends Module589.Store {
|
|
static displayName = "RTCDebugStore";
|
|
constructor() {
|
|
super(...arguments);
|
|
}
|
|
initialize() {
|
|
this.waitFor(MediaEngineStore, UserStore);
|
|
}
|
|
getSection() {
|
|
return env7277[11];
|
|
}
|
|
getInboundStats(a0, a1) {
|
|
const r9 = this.getAllStats(a1)[0];
|
|
const r2 = r9 == null;
|
|
let r7 = void 0;
|
|
if (!r2) {
|
|
const rtp = r9.rtp;
|
|
r7 = rtp == null ? void 0 : rtp.inbound[a0];
|
|
}
|
|
const r6 = r7 == null ? void 0 : r7.find((item) => item.type === "video");
|
|
const codec = r6 == null ? void 0 : r6.codec.name;
|
|
const resolution = r6?.resolution;
|
|
const frameRateRender = r6?.frameRateRender;
|
|
const isArray = Array.isArray(frameRateRender);
|
|
return {
|
|
codec,
|
|
resolution,
|
|
bitrateEstimate: void 0,
|
|
fps: isArray ? frameRateRender.at(-1)?.value : frameRateRender
|
|
};
|
|
}
|
|
getOutboundStats(a0) {
|
|
const allStats = this.getAllStats(a0);
|
|
const transport = allStats[0]?.transport;
|
|
const r13 = allStats[0];
|
|
const r8 = r13 == null ? void 0 : r13.rtp?.outbound;
|
|
const r7 = r8 == null ? void 0 : r8.find((item) => item.type === "video");
|
|
const codec = r7 == null ? void 0 : r7.codec.name;
|
|
const resolution = r7?.resolution;
|
|
const availableOutgoingBitrate = transport?.availableOutgoingBitrate;
|
|
const isArray = Array.isArray(availableOutgoingBitrate);
|
|
const bitrateEstimate = isArray ? availableOutgoingBitrate.at(-1)?.value : availableOutgoingBitrate;
|
|
const frameRateEncode = r7?.frameRateEncode;
|
|
const isArray2 = Array.isArray(frameRateEncode);
|
|
return {
|
|
codec,
|
|
resolution,
|
|
bitrateEstimate,
|
|
fps: isArray2 ? frameRateEncode.at(-1)?.value : frameRateEncode
|
|
};
|
|
}
|
|
getAllStats(r4 = MediaEngineContextTypes.DEFAULT) {
|
|
return Object.values(c7277_12[r4]);
|
|
}
|
|
getVideoStreams() {
|
|
return env7277[15];
|
|
}
|
|
shouldRecordNextConnection() {
|
|
return env7277[16];
|
|
}
|
|
getSimulcastDebugOverride(a0, a1) {
|
|
const r8 = `${a0}:${a1}`;
|
|
return c7277_13.has(r8) ? c7277_13.get(r8) : SimulcastOverrideQuality.NO_OVERRIDE;
|
|
}
|
|
}
|
|
c7277_21 = RTCDebugStore;
|
|
const r109 = new RTCDebugStore(Dispatcher, {
|
|
RTC_DEBUG_MODAL_OPEN: function handleOpen({ section }) {
|
|
if (section == null) {
|
|
section = c7277_10;
|
|
}
|
|
env7277[11] = section;
|
|
},
|
|
RTC_DEBUG_MODAL_CLOSE: function handleFormClose() {
|
|
if (env7277[17] != null) {
|
|
env7277[17].destroy();
|
|
env7277[17] = null;
|
|
}
|
|
},
|
|
RTC_DEBUG_MODAL_SET_SECTION: function handleSetSection(a0) {
|
|
env7277[11] = a0.section;
|
|
},
|
|
RTC_DEBUG_MODAL_OPEN_REPLAY: function handleOpenReplay() {
|
|
chooseReplayPath();
|
|
},
|
|
RTC_DEBUG_MODAL_OPEN_REPLAY_AT_PATH: function handleOpenReplayAtPath({ path }) {
|
|
let replayConnection;
|
|
replayConnection = void 0;
|
|
const mediaEngine = MediaEngineStore.getMediaEngine();
|
|
if (env7277[17] != null) {
|
|
env7277[17].destroy();
|
|
env7277[17] = null;
|
|
}
|
|
if (mediaEngine.supports(Features.CONNECTION_REPLAY) && path.length !== 0) {
|
|
replayConnection = mediaEngine.createReplayConnection(MediaEngineContextTypes.DEFAULT, path);
|
|
if (replayConnection != null) {
|
|
env7277[17] = replayConnection;
|
|
replayConnection.on(BaseConnectionEvent.Video, (a0, a1, a2, a3) => {
|
|
Dispatcher.dispatch({
|
|
type: "RTC_DEBUG_MODAL_UPDATE_VIDEO_OUTPUT",
|
|
mediaEngineConnectionId: replayConnection.mediaEngineConnectionId,
|
|
userId: a0,
|
|
videoSsrc: a3 == null ? 0 : a3,
|
|
streamId: a1 == null ? "" : a1
|
|
});
|
|
});
|
|
Dispatcher.wait(() => open());
|
|
}
|
|
}
|
|
},
|
|
RTC_DEBUG_MODAL_UPDATE_VIDEO_OUTPUT: function handleUpdateVideoOutput(a0) {
|
|
env7277[15] = env7277[15].put(a0.mediaEngineConnectionId, a0.userId, a0.videoSsrc, a0.streamId);
|
|
},
|
|
RTC_DEBUG_SET_RECORDING_FLAG: function handleSetRecordingFlag(a0) {
|
|
env7277[16] = a0.value;
|
|
},
|
|
RTC_DEBUG_SET_SIMULCAST_OVERRIDE: function handleSetSimulcastDebugOverride(a0) {
|
|
c7277_13.set(`${a0.userId}:${a0.context}`, a0.quality);
|
|
},
|
|
VOICE_CHANNEL_SELECT: function handleVoiceChannelSelect(a0) {
|
|
if (a0.channelId != null) {
|
|
const r6 = env7277;
|
|
Object.values(MediaEngineContextTypes).forEach($mk85596(r6));
|
|
c7277_13.clear();
|
|
c7277_18.clear();
|
|
}
|
|
},
|
|
RTC_CONNECTION_VIDEO: function handleVideo(a0) {
|
|
if (a0.streamId === null) {
|
|
c7277_13.set(`${a0.userId}:${a0.context}`, SimulcastOverrideQuality.NO_OVERRIDE);
|
|
}
|
|
},
|
|
MEDIA_ENGINE_CONNECTION_STATS: function handleMediaEngineConnectionStats({ connectionStats }) {
|
|
Object.values(MediaEngineContextTypes).forEach((c26813_0) => {
|
|
connectionStats.filter((connectionStat) => connectionStat.context === c26813_0).forEach(({ stats }, index) => {
|
|
const r26 = c7277_12[c26813_0];
|
|
if (stats != null) {
|
|
const [r30, r11, r12] = env7277[11].split(":");
|
|
if (r30 === c26813_0 && parseInt(r12) === index && UserStore.getUser(r11) != null && !Object.keys(stats.rtp.inbound).includes(r11)) {
|
|
env7277[11] = c7277_10;
|
|
}
|
|
const r47 = Date.now();
|
|
const screenshare = stats.screenshare;
|
|
let r49 = stats;
|
|
if (screenshare != null) {
|
|
const r17 = `${c26813_0}:${index}`;
|
|
const r55 = c7277_18.get(r17);
|
|
const screenshare2 = r26[index]?.screenshare;
|
|
c7277_18.set(r17, r47);
|
|
r49 = stats;
|
|
if (r55 != null) {
|
|
r49 = stats;
|
|
if (screenshare2 != null) {
|
|
const r63 = (r47 - r55) / 1000;
|
|
r49 = stats;
|
|
if (0 < r63) {
|
|
const screenshare4 = {
|
|
...stats.screenshare
|
|
};
|
|
const screenshare3 = stats.screenshare;
|
|
let videohookFrames = screenshare3.videohookFrames;
|
|
if (videohookFrames == null) {
|
|
videohookFrames = 0;
|
|
}
|
|
let hybridDxgiFrames = screenshare3.hybridDxgiFrames;
|
|
if (hybridDxgiFrames == null) {
|
|
hybridDxgiFrames = 0;
|
|
}
|
|
const r73 = videohookFrames + hybridDxgiFrames;
|
|
let hybridGdiFrames = screenshare3.hybridGdiFrames;
|
|
if (hybridGdiFrames == null) {
|
|
hybridGdiFrames = 0;
|
|
}
|
|
const r75 = r73 + hybridGdiFrames;
|
|
let hybridVideohookFrames = screenshare3.hybridVideohookFrames;
|
|
if (hybridVideohookFrames == null) {
|
|
hybridVideohookFrames = 0;
|
|
}
|
|
const r77 = r75 + hybridVideohookFrames;
|
|
let hybridGraphicsCaptureFrames = screenshare3.hybridGraphicsCaptureFrames;
|
|
if (hybridGraphicsCaptureFrames == null) {
|
|
hybridGraphicsCaptureFrames = 0;
|
|
}
|
|
const r79 = r77 + hybridGraphicsCaptureFrames;
|
|
let quartzFrames = screenshare3.quartzFrames;
|
|
if (quartzFrames == null) {
|
|
quartzFrames = 0;
|
|
}
|
|
const r81 = r79 + quartzFrames;
|
|
let screenCaptureKitFrames = screenshare3.screenCaptureKitFrames;
|
|
if (screenCaptureKitFrames == null) {
|
|
screenCaptureKitFrames = 0;
|
|
}
|
|
const r20 = r81 + screenCaptureKitFrames;
|
|
let videohookFrames2 = screenshare2.videohookFrames;
|
|
if (videohookFrames2 == null) {
|
|
videohookFrames2 = 0;
|
|
}
|
|
let hybridDxgiFrames2 = screenshare2.hybridDxgiFrames;
|
|
if (hybridDxgiFrames2 == null) {
|
|
hybridDxgiFrames2 = 0;
|
|
}
|
|
const r85 = videohookFrames2 + hybridDxgiFrames2;
|
|
let hybridGdiFrames2 = screenshare2.hybridGdiFrames;
|
|
if (hybridGdiFrames2 == null) {
|
|
hybridGdiFrames2 = 0;
|
|
}
|
|
const r87 = r85 + hybridGdiFrames2;
|
|
let hybridVideohookFrames2 = screenshare2.hybridVideohookFrames;
|
|
if (hybridVideohookFrames2 == null) {
|
|
hybridVideohookFrames2 = 0;
|
|
}
|
|
const r89 = r87 + hybridVideohookFrames2;
|
|
let hybridGraphicsCaptureFrames2 = screenshare2.hybridGraphicsCaptureFrames;
|
|
if (hybridGraphicsCaptureFrames2 == null) {
|
|
hybridGraphicsCaptureFrames2 = 0;
|
|
}
|
|
const r91 = r89 + hybridGraphicsCaptureFrames2;
|
|
let quartzFrames2 = screenshare2.quartzFrames;
|
|
if (quartzFrames2 == null) {
|
|
quartzFrames2 = 0;
|
|
}
|
|
const r93 = r91 + quartzFrames2;
|
|
let screenCaptureKitFrames2 = screenshare2.screenCaptureKitFrames;
|
|
if (screenCaptureKitFrames2 == null) {
|
|
screenCaptureKitFrames2 = 0;
|
|
}
|
|
const r19 = r93 + screenCaptureKitFrames2;
|
|
let hybridDxgiFramesUnique = screenshare3.hybridDxgiFramesUnique;
|
|
if (hybridDxgiFramesUnique == null) {
|
|
hybridDxgiFramesUnique = 0;
|
|
}
|
|
let hybridGdiBitBltFramesUnique = screenshare3.hybridGdiBitBltFramesUnique;
|
|
if (hybridGdiBitBltFramesUnique == null) {
|
|
hybridGdiBitBltFramesUnique = 0;
|
|
}
|
|
const r97 = hybridDxgiFramesUnique + hybridGdiBitBltFramesUnique;
|
|
let hybridGdiPrintWindowFramesUnique = screenshare3.hybridGdiPrintWindowFramesUnique;
|
|
if (hybridGdiPrintWindowFramesUnique == null) {
|
|
hybridGdiPrintWindowFramesUnique = 0;
|
|
}
|
|
const r99 = r97 + hybridGdiPrintWindowFramesUnique;
|
|
let hybridVideohookFramesUnique = screenshare3.hybridVideohookFramesUnique;
|
|
if (hybridVideohookFramesUnique == null) {
|
|
hybridVideohookFramesUnique = 0;
|
|
}
|
|
const r101 = r99 + hybridVideohookFramesUnique;
|
|
let hybridGraphicsCaptureFramesUnique = screenshare3.hybridGraphicsCaptureFramesUnique;
|
|
if (hybridGraphicsCaptureFramesUnique == null) {
|
|
hybridGraphicsCaptureFramesUnique = 0;
|
|
}
|
|
const r103 = r101 + hybridGraphicsCaptureFramesUnique;
|
|
let hybridDxgiFramesUnique2 = screenshare2.hybridDxgiFramesUnique;
|
|
if (hybridDxgiFramesUnique2 == null) {
|
|
hybridDxgiFramesUnique2 = 0;
|
|
}
|
|
let hybridGdiBitBltFramesUnique2 = screenshare2.hybridGdiBitBltFramesUnique;
|
|
if (hybridGdiBitBltFramesUnique2 == null) {
|
|
hybridGdiBitBltFramesUnique2 = 0;
|
|
}
|
|
const r106 = hybridDxgiFramesUnique2 + hybridGdiBitBltFramesUnique2;
|
|
let hybridGdiPrintWindowFramesUnique2 = screenshare2.hybridGdiPrintWindowFramesUnique;
|
|
if (hybridGdiPrintWindowFramesUnique2 == null) {
|
|
hybridGdiPrintWindowFramesUnique2 = 0;
|
|
}
|
|
const r108 = r106 + hybridGdiPrintWindowFramesUnique2;
|
|
let hybridVideohookFramesUnique2 = screenshare2.hybridVideohookFramesUnique;
|
|
if (hybridVideohookFramesUnique2 == null) {
|
|
hybridVideohookFramesUnique2 = 0;
|
|
}
|
|
const r110 = r108 + hybridVideohookFramesUnique2;
|
|
let hybridGraphicsCaptureFramesUnique2 = screenshare2.hybridGraphicsCaptureFramesUnique;
|
|
if (hybridGraphicsCaptureFramesUnique2 == null) {
|
|
hybridGraphicsCaptureFramesUnique2 = 0;
|
|
}
|
|
const r112 = r110 + hybridGraphicsCaptureFramesUnique2;
|
|
HermesBuiltin.copyDataProperties(screenshare4, {
|
|
screenshareCapturedFps: Math.max(0, (r20 - r19) / r63),
|
|
screenshareCapturedFpsUnique: Math.max(0, (r103 - r112) / r63)
|
|
});
|
|
r49 = {
|
|
...stats,
|
|
screenshare: screenshare4
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
r26[index] = updateStats(r49, r26[index], r47);
|
|
} else {
|
|
delete r26[index];
|
|
}
|
|
});
|
|
});
|
|
}
|
|
});
|
|
export default r109;
|
|
export { c7277_10 as DEFAULT_SECTION };
|
|
export { c7277_14 as graphs };
|
|
export function keySection(a0, a1, a2) {
|
|
return `${a0}:${a1}:${a2}`;
|
|
}
|
|
export function parseSection(a0) {
|
|
const r8 = _slicedToArray(a0.split(":"), 2);
|
|
return {
|
|
context: r8[0],
|
|
section: r8[1]
|
|
};
|
|
}
|
|
export function getLastGraphValue(a0) {
|
|
return Array.isArray(a0) ? a0.at(-1)?.value : a0;
|
|
}
|