decord/beta/source/lib/VoiceQuality.tsx
2026-10-07 22:43:51 +00:00

1032 lines
45 KiB
TypeScript

// Module ID: 13629
// Function ID: 13630
// Name: VoiceQuality
// Dependencies: [32, 7233, 4948, 13630, 7239, 4945, 12, 11, 4919, 2]
// Module 13629 (VoiceQuality)
import SnowflakeUtilsDefault from "SnowflakeUtils" /* 11 */;
import _modDef12 from "module_12" /* 12 */;
import BaseConnectionEvent from "BaseConnectionEvent" /* 4945 */;
import Histogram from "Histogram" /* 7233 */;
import SystemResourcesDefault from "SystemResources" /* 7239 */;
import NetworkQualityDefault from "NetworkQuality" /* 13630 */;
import _slicedToArray from "_slicedToArray" /* 32 */;
import TypedEventEmitter from "TypedEventEmitter" /* 4948 */;
import size from "module_2" /* 2 */;
const require = globalThis.__r;
let _require, emit;
function explodePlayoutMetrics(obj) {
obj = {};
for (const key10012 in obj) {
let obj2 = obj[key10012];
if (obj2 instanceof Histogram.Histogram) {
let report = obj2.getReport([75, 95, 99]);
let _Math = Math;
let text = `${key10012}_mean`;
obj[`${key10012}_mean`] = Math.round(report.mean);
let _Math2 = Math;
let text1 = `${key10012}_p75`;
obj[`${key10012}_p75`] = Math.round(report.percentiles[75]);
let _Math3 = Math;
let text2 = `${key10012}_p95`;
obj[`${key10012}_p95`] = Math.round(report.percentiles[95]);
let _Math4 = Math;
let text3 = `${key10012}_p99`;
obj[`${key10012}_p99`] = Math.round(report.percentiles[99]);
let _Math5 = Math;
let text4 = `${key10012}_max`;
obj[`${key10012}_max`] = Math.round(report.max);
continue;
} else {
let mean = null;
let text5 = `${key10012}_mean`;
if (null != obj2) {
mean = obj2.mean;
}
obj[text5] = mean;
let p75 = null;
let text6 = `${key10012}_p75`;
if (null != obj2) {
p75 = obj2.p75;
}
obj[text6] = p75;
let p95 = null;
let text7 = `${key10012}_p95`;
if (null != obj2) {
p95 = obj2.p95;
}
obj[text7] = p95;
let p99 = null;
let text8 = `${key10012}_p99`;
if (null != obj2) {
p99 = obj2.p99;
}
obj[text8] = p99;
let max = null;
let text9 = `${key10012}_max`;
if (null != obj2) {
max = obj2.max;
}
obj[text9] = max;
continue;
}
continue;
}
return obj;
}
const VoiceQualityEvent = { InputDeviceSampleRateChanged: "input-device-sample-rate-changed" };
class VoiceQuality extends TypedEventEmitter {
constructor(connection) {
let histogram;
let tmp;
const tmp3 = new VoiceQuality(tmp2, tmp);
_require = tmp3;
tmp3.sampleAudioDevice = function sampleAudioDevice(input, inputDeviceStats) {
let accumulated;
let accumulated2;
let lastValue;
let lastValue2;
if (undefined !== input) {
let restartCount;
if (undefined !== input.restartCount) {
let sum;
restartCount = input.restartCount;
let restartCount1 = inputDeviceStats.restartCount;
if (restartCount1 == null) {
restartCount1 = { accumulated: 0, lastValue: 0 };
}
({ accumulated, lastValue } = restartCount1);
if (lastValue > restartCount) {
sum = accumulated + restartCount;
} else {
sum = accumulated + (restartCount - lastValue);
}
restartCount = { accumulated: sum, lastValue: restartCount };
inputDeviceStats.restartCount = restartCount;
}
if (undefined !== input.bufferViolations) {
let sum1;
const bufferViolations = input.bufferViolations;
let bufferViolations1 = inputDeviceStats.bufferViolations;
if (bufferViolations1 == null) {
bufferViolations1 = { accumulated: 0, lastValue: 0 };
}
({ accumulated: accumulated2, lastValue: lastValue2 } = bufferViolations1);
if (lastValue2 > bufferViolations) {
sum1 = accumulated2 + bufferViolations;
} else {
sum1 = accumulated2 + (bufferViolations - lastValue2);
}
const obj2 = { accumulated: sum1, lastValue: bufferViolations };
inputDeviceStats.bufferViolations = obj2;
}
let num = input.timeToFirstCallbackMs;
if (num == null) {
num = 0;
}
const tmp6 = 0 !== num && undefined === inputDeviceStats.timeToFirstCallbackMs;
if (tmp6) {
inputDeviceStats.timeToFirstCallbackMs = input.timeToFirstCallbackMs;
}
let num3 = input.sessionSampleRate;
if (num3 == null) {
num3 = 0;
}
if (0 !== num3) {
if (inputDeviceStats.sessionSampleRate !== input.sessionSampleRate) {
let num4 = input.sessionSampleRate;
emit = emit.emit;
const InputDeviceSampleRateChanged = restartCount.InputDeviceSampleRateChanged;
if (num4 == null) {
num4 = 0;
}
emit(InputDeviceSampleRateChanged, num4);
}
inputDeviceStats.sessionSampleRate = input.sessionSampleRate;
}
const tmp10 = undefined !== input.timeFromConnectToFirstCallbackMs && undefined === inputDeviceStats.timeFromConnectToFirstCallbackMs;
if (tmp10) {
inputDeviceStats.timeFromConnectToFirstCallbackMs = input.timeFromConnectToFirstCallbackMs;
}
if (undefined !== input.delayMs) {
inputDeviceStats.delayMs = input.delayMs;
}
if (undefined !== input.totalDelayMs) {
inputDeviceStats.totalDelayMs = input.totalDelayMs;
}
}
};
tmp3.appendTargetRates = function appendTargetRates(previousTimestampMs) {
let num = arg1;
if (arg1 === undefined) {
num = 0;
}
let num2 = arg2;
if (arg2 === undefined) {
num2 = 0;
}
if (0 !== previousTimestampMs.previousTimestampMs) {
const _performance2 = performance;
const nowResult = performance.now();
previousTimestampMs.aggregationDurationMs = previousTimestampMs.aggregationDurationMs + (nowResult - previousTimestampMs.previousTimestampMs);
const result = (nowResult - previousTimestampMs.previousTimestampMs) / 1000;
previousTimestampMs.bytesAvailable = previousTimestampMs.bytesAvailable + num / 8 * result;
previousTimestampMs.bytesTarget = previousTimestampMs.bytesTarget + num2 / 8 * result;
previousTimestampMs.previousTimestampMs = nowResult;
} else {
const _performance = performance;
previousTimestampMs.previousTimestampMs = performance.now();
}
};
tmp3.sampleStats = function sampleStats(rtp) {
let num;
let outboundStats;
let transportDelayMs;
let transportPacketCount;
if (null != rtp) {
obj = num;
const networkQuality = num.networkQuality;
const incrementNetworkStats = networkQuality.incrementNetworkStats;
const obj2 = outboundStats(dependencyMap[8]);
const result = incrementNetworkStats(obj2.now());
const systemResources = num.systemResources;
systemResources.takeSample();
num = 0;
const arr2 = _modDef12;
let item = arr2.forEach(rtp.rtp.outbound, (type) => {
let apmFrameCount;
let apmProcessTimeMs;
let captureProcessingDelayMs;
let captureProcessingFrameCount;
let noiseCancellerFrames;
let noiseCancellerProcessTime;
let num2;
let num3;
let num4;
let num5;
let num6;
let num7;
let num8;
let packetsLost;
let sendDelayMs;
let sendPacketCount;
let totalPacketSendDelayMs;
if ("audio" === type.type) {
let num = type.bitrateTarget;
if (num == null) {
num = 0;
}
outboundStats = { packetsLost, passthroughCount: num2, encryptSuccessCount: num3, encryptFailureCount: num4, encryptDuration: num5, encryptAttempts: num6, encryptMaxAttempts: num7, encryptMissingKeyCount: num8, captureProcessingDelayMs, captureProcessingFrameCount, apmProcessTimeMs, apmFrameCount, sendDelayMs, sendPacketCount, totalPacketSendDelayMs, noiseCancellerProcessTime, noiseCancellerFrames, outboundStats };
const merged = Object.assign(outboundStats.outboundStats);
({ packetsSent: obj.packetsSent, bytesSent: obj.bytesSent, packetsLost } = type);
if (packetsLost == null) {
packetsLost = 0;
}
num2 = type.passthroughCount;
if (num2 == null) {
num2 = 0;
}
num3 = type.encryptSuccessCount;
if (num3 == null) {
num3 = 0;
}
num4 = type.encryptFailureCount;
if (num4 == null) {
num4 = 0;
}
num5 = type.encryptDuration;
if (num5 == null) {
num5 = 0;
}
num6 = type.encryptAttempts;
if (num6 == null) {
num6 = 0;
}
num7 = type.encryptMaxAttempts;
if (num7 == null) {
num7 = 0;
}
num8 = type.encryptMissingKeyCount;
if (num8 == null) {
num8 = 0;
}
captureProcessingDelayMs = type.captureProcessingDelayMs;
if (captureProcessingDelayMs == null) {
captureProcessingDelayMs = tmp.outboundStats.captureProcessingDelayMs;
}
captureProcessingFrameCount = type.captureProcessingFrameCount;
if (captureProcessingFrameCount == null) {
captureProcessingFrameCount = tmp.outboundStats.captureProcessingFrameCount;
}
apmProcessTimeMs = type.apmProcessTimeMs;
if (apmProcessTimeMs == null) {
apmProcessTimeMs = tmp.outboundStats.apmProcessTimeMs;
}
apmFrameCount = type.apmFrameCount;
if (apmFrameCount == null) {
apmFrameCount = tmp.outboundStats.apmFrameCount;
}
sendDelayMs = type.sendDelayMs;
if (sendDelayMs == null) {
sendDelayMs = tmp.outboundStats.sendDelayMs;
}
sendPacketCount = type.sendPacketCount;
if (sendPacketCount == null) {
sendPacketCount = tmp.outboundStats.sendPacketCount;
}
totalPacketSendDelayMs = type.totalPacketSendDelayMs;
if (totalPacketSendDelayMs == null) {
totalPacketSendDelayMs = tmp.outboundStats.totalPacketSendDelayMs;
}
noiseCancellerProcessTime = type.noiseCancellerProcessTime;
if (noiseCancellerProcessTime == null) {
noiseCancellerProcessTime = tmp.outboundStats.noiseCancellerProcessTime;
}
noiseCancellerFrames = type.noiseCancellerFrames;
if (noiseCancellerFrames == null) {
noiseCancellerFrames = tmp.outboundStats.noiseCancellerFrames;
}
const _Boolean = Boolean;
const tmp5 = true === Boolean(type.audioDetected) && null != type.audioLevel;
if (tmp5) {
const speakingAudioLevel = tmp.outboundStats.speakingAudioLevel;
const _Math = Math;
speakingAudioLevel.addSample(20 * Math.log(type.audioLevel));
}
}
});
let obj3 = { decryptionFailures: rtp.transport.decryptionFailures, routingFailures: rtp.transport.routingFailures, transportDelayMs, transportPacketCount };
transportDelayMs = rtp.transport.transportDelayMs;
const tmp10 = importDefault;
const tmp7 = dependencyMap;
if (transportDelayMs == null) {
transportDelayMs = obj.transportStats.transportDelayMs;
}
transportPacketCount = rtp.transport.transportPacketCount;
if (transportPacketCount == null) {
transportPacketCount = obj.transportStats.transportPacketCount;
}
obj.transportStats = obj3;
const tmp = num;
obj.appendTargetRates(obj.outboundStats, rtp.transport.availableOutgoingBitrate, num);
const tmp10Result = tmp10(tmp7[6]);
const item1 = tmp10Result.forEach(rtp.rtp.inbound, (arg0, arg1) => {
let closure_0 = arg1;
const arr = closure_1_1(closure_1_2[6]);
const item = arr.forEach(arg0, function(type) {
let accelerateRateSum;
let bytesReceived;
let disconnectedAtMs;
let expandRateSum;
let fecPacketsReceived;
let nackCount;
let num10;
let num11;
let num12;
let num14;
let num15;
let num16;
let num17;
let num2;
let num3;
let num4;
let num5;
let num6;
let num7;
let num8;
let num9;
let packetsLost;
let packetsReceived;
let passthroughCount;
let preemptiveExpandRateSum;
let prop;
let prop1;
let prop2;
let speechExpandRateSum;
if ("audio" === type.type) {
({ packetsReceived, packetsLost, bytesReceived, nackCount, fecPacketsReceived } = type);
if (fecPacketsReceived == null) {
fecPacketsReceived = 0;
}
let num = type.fecPacketsDiscarded;
if (num == null) {
num = 0;
}
const bufferStats = { audioJitterBuffer: type.audioJitterBuffer, audioJitterBufferHistogram: prop, audioJitterTarget: type.audioJitterTarget, audioJitterTargetHistogram: prop1, audioJitterDelay: type.audioJitterDelay, audioJitterDelayHistogram: prop2, relativeReceptionDelay: null, relativePlayoutDelay: null };
prop = undefined;
if (num.inboundStats[closure_0] != null) {
prop = tmp29.bufferStats.audioJitterBufferHistogram;
}
if (prop == null) {
const self = this;
const self2 = this;
prop = new closure_0(dependencyMap[1]).Histogram();
}
prop1 = undefined;
if (num.inboundStats[closure_0] != null) {
prop1 = tmp29.bufferStats.audioJitterTargetHistogram;
}
if (prop1 == null) {
const self3 = this;
const self4 = this;
prop1 = new closure_0(dependencyMap[1]).Histogram();
}
prop2 = undefined;
if (num.inboundStats[closure_0] != null) {
prop2 = tmp29.bufferStats.audioJitterDelayHistogram;
}
if (prop2 == null) {
const self5 = this;
const self6 = this;
prop2 = new closure_0(dependencyMap[1]).Histogram();
}
({ relativeReceptionDelay: obj.relativeReceptionDelay, relativePlayoutDelay: obj.relativePlayoutDelay } = type);
const audioJitterBufferHistogram = bufferStats.audioJitterBufferHistogram;
let prop3 = type.audioJitterBufferSamples;
const addSamples = audioJitterBufferHistogram.addSamples;
if (prop3 == null) {
prop3 = [];
}
addSamples(prop3);
const audioJitterDelayHistogram = bufferStats.audioJitterDelayHistogram;
let prop4 = type.audioJitterDelaySamples;
const addSamples2 = audioJitterDelayHistogram.addSamples;
if (prop4 == null) {
prop4 = [];
}
addSamples2(prop4);
const audioJitterTargetHistogram = bufferStats.audioJitterTargetHistogram;
let prop5 = type.audioJitterTargetSamples;
const addSamples3 = audioJitterTargetHistogram.addSamples;
if (prop5 == null) {
prop5 = [];
}
addSamples3(prop5);
const obj3 = { silent: null, normal: null, merged: null, expanded: null, accelerated: null, preemptiveExpanded: null, cng: null };
({ opSilence: obj2.silent, opNormal: obj2.normal, opMerge: obj2.merged, opExpand: obj2.expanded, opAccelerate: obj2.accelerated, opPreemptiveExpand: obj2.preemptiveExpanded, opCNG: obj2.cng, passthroughCount } = type);
if (passthroughCount == null) {
passthroughCount = 0;
}
const obj4 = { passthroughCount, decryptSuccessCount: num2, decryptFailureCount: num3, decryptDuration: num4, decryptAttempts: num5, decryptMissingKeyCount: num6, decryptInvalidNonceCount: num7 };
num2 = type.decryptSuccessCount;
if (num2 == null) {
num2 = 0;
}
num3 = type.decryptFailureCount;
if (num3 == null) {
num3 = 0;
}
num4 = type.decryptDuration;
if (num4 == null) {
num4 = 0;
}
num5 = type.decryptAttempts;
if (num5 == null) {
num5 = 0;
}
num6 = type.decryptMissingKeyCount;
if (num6 == null) {
num6 = 0;
}
num7 = type.decryptInvalidNonceCount;
if (num7 == null) {
num7 = 0;
}
let audioReceiverDelayMs = type.audioReceiverDelayMs;
if (audioReceiverDelayMs == null) {
let audioReceiverDelayMs1;
if (num.inboundStats[closure_0] != null) {
audioReceiverDelayMs1 = tmp29.audioReceiverDelayMs;
}
audioReceiverDelayMs = audioReceiverDelayMs1;
}
let audioReceiverPacketCount = type.audioReceiverPacketCount;
if (audioReceiverPacketCount == null) {
let prop6;
if (num.inboundStats[closure_0] != null) {
prop6 = tmp29.audioReceiverPacketCount;
}
audioReceiverPacketCount = prop6;
}
if (null != num.inboundStats[closure_0]) {
let connectedAtMs;
let tmp19;
if (packetsReceived >= num.inboundStats[closure_0].packetsReceived) {
let decryptFailureBeforeSuccessCount = tmp29.decryptFailureBeforeSuccessCount;
if (decryptFailureBeforeSuccessCount == null) {
let decryptFailureCount;
if (obj4.decryptSuccessCount > 0) {
decryptFailureCount = obj4.decryptFailureCount;
}
decryptFailureBeforeSuccessCount = decryptFailureCount;
}
tmp19 = decryptFailureBeforeSuccessCount;
}
const inboundStats = tmp27.inboundStats;
if (packetsReceived < num.inboundStats[closure_0].packetsReceived) {
const _performance3 = performance;
connectedAtMs = performance.now();
} else {
connectedAtMs = tmp29.connectedAtMs;
}
const obj5 = { connectedAtMs, disconnectedAtMs, packetsReceived, bytesReceived, packetsLost, nackCount, fecPacketsReceived, fecPacketsDiscarded: num, bufferStats, frameOpStats: obj3, decryptFailureBeforeSuccessCount: tmp19, audioReceiverDelayMs, audioReceiverPacketCount };
disconnectedAtMs = undefined;
if (packetsReceived >= num.inboundStats[closure_0].packetsReceived) {
disconnectedAtMs = tmp29.disconnectedAtMs;
}
if (nackCount == null) {
nackCount = 0;
}
const merged = Object.assign(obj4);
inboundStats[closure_0] = obj5;
const _performance4 = performance;
const periodicInboundStats2 = tmp27.periodicInboundStats;
const obj6 = { previousTimestampMs: num.periodicInboundStats[closure_0].previousTimestampMs, previous: num.periodicInboundStats[closure_0].previous, currentTimestampMs: performance.now(), current: obj3, accelerateRateSum: accelerateRateSum + num14, expandRateSum: expandRateSum + num15, preemptiveExpandRateSum: preemptiveExpandRateSum + num16, speechExpandRateSum: speechExpandRateSum + num17, numRateSamples: num.periodicInboundStats[closure_0].numRateSamples + 1 };
num14 = type.accelerateRate;
accelerateRateSum = tmp27.periodicInboundStats[tmp28].accelerateRateSum;
if (num14 == null) {
num14 = 0;
}
num15 = type.expandRate;
expandRateSum = tmp27.periodicInboundStats[tmp28].expandRateSum;
if (num15 == null) {
num15 = 0;
}
num16 = type.preemptiveExpandRate;
preemptiveExpandRateSum = tmp27.periodicInboundStats[tmp28].preemptiveExpandRateSum;
if (num16 == null) {
num16 = 0;
}
num17 = type.speechExpandRate;
speechExpandRateSum = tmp27.periodicInboundStats[tmp28].speechExpandRateSum;
if (num17 == null) {
num17 = 0;
}
periodicInboundStats2[closure_0] = obj6;
} else {
const _performance5 = performance;
const inboundStats2 = tmp27.inboundStats;
const obj7 = { connectedAtMs: performance.now(), packetsReceived, bytesReceived, packetsLost, nackCount: num8, fecPacketsReceived, fecPacketsDiscarded: num, bufferStats, frameOpStats: obj3, audioReceiverDelayMs, audioReceiverPacketCount };
num8 = nackCount;
if (nackCount == null) {
num8 = 0;
}
const merged1 = Object.assign(obj4);
inboundStats2[closure_0] = obj7;
const _performance = performance;
const periodicInboundStats = tmp27.periodicInboundStats;
const _performance2 = performance;
const obj13 = { previousTimestampMs: performance.now(), previous: obj3, currentTimestampMs: performance.now(), current: obj3, accelerateRateSum: num9, expandRateSum: num10, preemptiveExpandRateSum: num11, speechExpandRateSum: num12, numRateSamples: 1 };
num9 = type.accelerateRate;
if (num9 == null) {
num9 = 0;
}
num10 = type.expandRate;
if (num10 == null) {
num10 = 0;
}
num11 = type.preemptiveExpandRate;
if (num11 == null) {
num11 = 0;
}
num12 = type.speechExpandRate;
if (num12 == null) {
num12 = 0;
}
periodicInboundStats[closure_0] = obj13;
}
}
});
});
if (undefined !== rtp.audioDevice) {
obj.sampleAudioDevice(rtp.audioDevice.input, obj.inputDeviceStats);
obj.sampleAudioDevice(rtp.audioDevice.output, obj.outputDeviceStats);
}
}
};
tmp3.connection = connection;
tmp3.networkQuality = new NetworkQualityDefault();
const tmp4 = new NetworkQualityDefault();
let tmp5 = new SystemResourcesDefault();
tmp3.systemResources = tmp5;
tmp3.inboundStats = {};
let outboundStats = { packetsSent: 0, bytesSent: 0, packetsLost: 0, passthroughCount: 0, encryptSuccessCount: 0, encryptFailureCount: 0, encryptDuration: 0, encryptAttempts: 0, encryptMaxAttempts: 0, encryptMissingKeyCount: 0, bytesAvailable: 0, bytesTarget: 0, previousTimestampMs: 0, aggregationDurationMs: 0, speakingAudioLevel: histogram };
histogram = new require("Histogram").Histogram();
tmp3.outboundStats = outboundStats;
tmp3.transportStats = {};
tmp3.periodicInboundStats = {};
tmp3.inputDeviceStats = {};
tmp3.outputDeviceStats = {};
return tmp3;
}
start() {
const connection = this.connection;
connection.on(BaseConnectionEvent.BaseConnectionEvent.Stats, this.sampleStats);
}
stop() {
const connection = this.connection;
connection.off(BaseConnectionEvent.BaseConnectionEvent.Stats, this.sampleStats);
}
getPacketStats() {
const arr = _modDef12;
const reduced = arr.reduce(this.inboundStats, (packetsReceived, packetsReceived2) => {
packetsReceived.packetsReceived = packetsReceived.packetsReceived + packetsReceived2.packetsReceived;
packetsReceived.packetsReceivedLost = packetsReceived.packetsReceivedLost + packetsReceived2.packetsLost;
packetsReceived.nackCount = packetsReceived.nackCount + packetsReceived2.nackCount;
packetsReceived.fecPacketsReceived = packetsReceived.fecPacketsReceived + packetsReceived2.fecPacketsReceived;
packetsReceived.fecPacketsDiscarded = packetsReceived.fecPacketsDiscarded + packetsReceived2.fecPacketsDiscarded;
return packetsReceived;
}, { packetsReceived: 0, packetsReceivedLost: 0, nackCount: 0, fecPacketsReceived: 0, fecPacketsDiscarded: 0 });
return { packets_sent: this.outboundStats.packetsSent, packets_sent_lost: this.outboundStats.packetsLost, packets_received: reduced.packetsReceived, packets_received_lost: reduced.packetsReceivedLost, num_nacks_sent: reduced.nackCount, fec_packets_received: reduced.fecPacketsReceived, fec_packets_discarded: reduced.fecPacketsDiscarded };
}
getInboundPacketsStats(sender_user_id) {
if (null == this.inboundStats[sender_user_id]) {
obj = {};
} else {
obj = { num_packets: null, num_packets_lost: null };
({ packetsReceived: obj.num_packets, packetsLost: obj.num_packets_lost } = this.inboundStats[sender_user_id]);
}
return obj;
}
getOutboundPacketsStats() {
return { num_packets: this.outboundStats.packetsSent, num_packets_lost: this.outboundStats.packetsLost };
}
getBytesStats() {
let num;
let num3;
const self = this;
const result = this.outboundStats.aggregationDurationMs / 1000;
const arr = _modDef12;
obj = { bytes_sent: this.outboundStats.bytesSent, bytes_received: arr.reduce(this.inboundStats, (arg0, bytesReceived) => arg0 + bytesReceived.bytesReceived, 0), outbound_bandwidth_estimate: num, audio_target_bitrate: num3 };
num = 0;
if (0 < result) {
const _Math = Math;
num = Math.round(8 * self.outboundStats.bytesAvailable / result);
}
num3 = 0;
if (0 < result) {
const _Math2 = Math;
num3 = Math.round(8 * self.outboundStats.bytesTarget / result);
}
return obj;
}
getInboundBytesStats(sender_user_id) {
if (null == this.inboundStats[sender_user_id]) {
obj = {};
} else {
obj = { num_bytes: this.inboundStats[sender_user_id].bytesReceived };
}
return obj;
}
getOutboundBytesStats() {
return { num_bytes: this.outboundStats.bytesSent };
}
getOutboundLatencyStats() {
return { capture_processing_delay_ms: this.outboundStats.captureProcessingDelayMs, capture_processing_frame_count: this.outboundStats.captureProcessingFrameCount, apm_process_time_ms: this.outboundStats.apmProcessTimeMs, apm_frame_count: this.outboundStats.apmFrameCount, send_delay_ms: this.outboundStats.sendDelayMs, send_packet_count: this.outboundStats.sendPacketCount, total_packet_send_delay_ms: this.outboundStats.totalPacketSendDelayMs, noise_canceller_process_time_ms: this.outboundStats.noiseCancellerProcessTime, noise_canceller_frame_count: this.outboundStats.noiseCancellerFrames };
}
getInboundDurationStats(sender_user_id) {
if (null == this.inboundStats[sender_user_id]) {
obj = {};
} else {
let disconnectedAtMs = tmp.disconnectedAtMs;
const _Math = Math;
if (disconnectedAtMs == null) {
const _performance = performance;
disconnectedAtMs = performance.now();
}
obj = { duration_connected_ms: round(disconnectedAtMs - this.inboundStats[sender_user_id].connectedAtMs) };
}
return obj;
}
getInboundLatencyStats(sender_user_id) {
if (null == this.inboundStats[sender_user_id]) {
obj = {};
} else {
obj = { audio_receiver_delay_ms: null, audio_receiver_packet_count: null };
({ audioReceiverDelayMs: obj.audio_receiver_delay_ms, audioReceiverPacketCount: obj.audio_receiver_packet_count } = this.inboundStats[sender_user_id]);
}
return obj;
}
getInboundJitterStats(sender_user_id) {
let audioJitterDelay;
let audioJitterTarget;
let obj2;
if (null == this.inboundStats[sender_user_id]) {
obj2 = {};
} else {
let audioJitterBuffer;
const audioJitterBufferHistogram = tmp.bufferStats.audioJitterBufferHistogram;
const tmp2 = explodePlayoutMetrics;
if (audioJitterBufferHistogram.getSamples() > 0) {
audioJitterBuffer = tmp.bufferStats.audioJitterBufferHistogram;
} else {
audioJitterBuffer = tmp.bufferStats.audioJitterBuffer;
}
const audioJitterDelayHistogram = tmp.bufferStats.audioJitterDelayHistogram;
obj = { audio_jitter_buffer: audioJitterBuffer, audio_jitter_delay: audioJitterDelay, audio_jitter_target: audioJitterTarget };
if (audioJitterDelayHistogram.getSamples() > 0) {
audioJitterDelay = tmp.bufferStats.audioJitterDelayHistogram;
} else {
audioJitterDelay = tmp.bufferStats.audioJitterDelay;
}
const audioJitterTargetHistogram = tmp.bufferStats.audioJitterTargetHistogram;
if (audioJitterTargetHistogram.getSamples() > 0) {
audioJitterTarget = tmp.bufferStats.audioJitterTargetHistogram;
} else {
audioJitterTarget = tmp.bufferStats.audioJitterTarget;
}
obj2 = tmp2(obj);
}
return obj2;
}
getNetworkStats() {
const networkQuality = this.networkQuality;
return networkQuality.getStats();
}
getSystemResourceStats() {
const systemResources = this.systemResources;
return systemResources.getStats();
}
getBufferStats() {
let prop3;
let relativePlayoutDelay;
const arr = _modDef12;
const reduced = arr.reduce(this.inboundStats, (arg0, bufferStats) => {
let percentile;
const audioJitterBufferHistogram = bufferStats.bufferStats.audioJitterBufferHistogram;
if (audioJitterBufferHistogram.getSamples() > 0) {
const audioJitterBufferHistogram2 = bufferStats.bufferStats.audioJitterBufferHistogram;
percentile = audioJitterBufferHistogram2.getPercentile(75);
} else {
percentile = null;
if (null != bufferStats.bufferStats.audioJitterBuffer) {
percentile = bufferStats.bufferStats.audioJitterBuffer.p75;
}
}
bufferStats = arg0;
let percentile1 = null;
if (null != arg0) {
const audioJitterBufferHistogram3 = bufferStats.audioJitterBufferHistogram;
if (audioJitterBufferHistogram3.getSamples() > 0) {
const audioJitterBufferHistogram4 = bufferStats.audioJitterBufferHistogram;
percentile1 = audioJitterBufferHistogram4.getPercentile(75);
} else {
percentile1 = null;
if (null != bufferStats.audioJitterBuffer) {
percentile1 = bufferStats.audioJitterBuffer.p75;
}
}
}
let tmp3 = null == bufferStats || null == percentile1;
if (!tmp3) {
tmp3 = null != percentile && percentile > percentile1;
}
if (tmp3) {
bufferStats = bufferStats.bufferStats;
}
return bufferStats;
}, null);
let tmp2 = null;
if (null != reduced) {
let prop;
let audioJitterBufferHistogram = reduced.audioJitterBufferHistogram;
if (audioJitterBufferHistogram.getSamples() > 0) {
prop = reduced.audioJitterBufferHistogram;
} else {
prop = null;
if (null != reduced.audioJitterBuffer) {
prop = reduced.audioJitterBuffer;
}
}
tmp2 = prop;
}
let tmp4 = null;
if (null != reduced) {
let prop1;
const audioJitterTargetHistogram = reduced.audioJitterTargetHistogram;
if (audioJitterTargetHistogram.getSamples() > 0) {
prop1 = reduced.audioJitterTargetHistogram;
} else {
prop1 = null;
if (null != reduced.audioJitterTarget) {
prop1 = reduced.audioJitterTarget;
}
}
tmp4 = prop1;
}
let tmp6 = null;
if (null != reduced) {
let prop2;
const audioJitterDelayHistogram = reduced.audioJitterDelayHistogram;
if (audioJitterDelayHistogram.getSamples() > 0) {
prop2 = reduced.audioJitterDelayHistogram;
} else {
prop2 = null;
if (null != reduced.audioJitterDelay) {
prop2 = reduced.audioJitterDelay;
}
}
tmp6 = prop2;
}
obj = { audio_jitter_buffer: tmp2, audio_jitter_target: tmp4, audio_jitter_delay: tmp6, relative_reception_delay: prop3, relative_playout_delay: relativePlayoutDelay };
prop3 = undefined;
const tmp8 = explodePlayoutMetrics;
if (reduced != null) {
prop3 = reduced.relativeReceptionDelay;
}
if (prop3 == null) {
prop3 = null;
}
relativePlayoutDelay = undefined;
if (reduced != null) {
relativePlayoutDelay = reduced.relativePlayoutDelay;
}
if (relativePlayoutDelay == null) {
relativePlayoutDelay = null;
}
const obj2 = {};
const merged = Object.assign(tmp8(obj));
return obj2;
}
getFrameOpStats() {
const arr = _modDef12;
const reduced = arr.reduce(this.inboundStats, (silent, frameOpStats) => {
if (null != frameOpStats.frameOpStats.silent) {
silent.silent = silent.silent + frameOpStats.frameOpStats.silent;
}
if (null != frameOpStats.frameOpStats.normal) {
silent.normal = silent.normal + frameOpStats.frameOpStats.normal;
}
if (null != frameOpStats.frameOpStats.merged) {
silent.merged = silent.merged + frameOpStats.frameOpStats.merged;
}
if (null != frameOpStats.frameOpStats.expanded) {
silent.expanded = silent.expanded + frameOpStats.frameOpStats.expanded;
}
if (null != frameOpStats.frameOpStats.accelerated) {
silent.accelerated = silent.accelerated + frameOpStats.frameOpStats.accelerated;
}
if (null != frameOpStats.frameOpStats.preemptiveExpanded) {
silent.preemptiveExpanded = silent.preemptiveExpanded + frameOpStats.frameOpStats.preemptiveExpanded;
}
if (null != frameOpStats.frameOpStats.cng) {
silent.cng = silent.cng + frameOpStats.frameOpStats.cng;
}
return silent;
}, { silent: 0, normal: 0, merged: 0, expanded: 0, accelerated: 0, preemptiveExpanded: 0, cng: 0 });
return { frame_op_silent: reduced.silent, frame_op_normal: reduced.normal, frame_op_merged: reduced.merged, frame_op_expanded: reduced.expanded, frame_op_accelerated: reduced.accelerated, frame_op_preemptive_expanded: reduced.preemptiveExpanded, frame_op_cng: reduced.cng };
}
getTransportStats() {
return { decryption_failures: this.transportStats.decryptionFailures, routing_failures: this.transportStats.routingFailures, transport_delay_ms: this.transportStats.transportDelayMs, transport_packet_count: this.transportStats.transportPacketCount };
}
getE2EEStats() {
const arr = _modDef12;
const reduced = arr.reduce(this.inboundStats, (passthroughCount, passthroughCount2) => {
let num = passthroughCount2.passthroughCount;
passthroughCount = passthroughCount.passthroughCount;
if (num == null) {
num = 0;
}
passthroughCount.passthroughCount = passthroughCount + num;
let num2 = passthroughCount2.decryptSuccessCount;
const decryptSuccessCount = passthroughCount.decryptSuccessCount;
if (num2 == null) {
num2 = 0;
}
passthroughCount.decryptSuccessCount = decryptSuccessCount + num2;
let num3 = passthroughCount2.decryptFailureCount;
const decryptFailureCount = passthroughCount.decryptFailureCount;
if (num3 == null) {
num3 = 0;
}
passthroughCount.decryptFailureCount = decryptFailureCount + num3;
let num4 = passthroughCount2.decryptDuration;
const decryptDuration = passthroughCount.decryptDuration;
if (num4 == null) {
num4 = 0;
}
passthroughCount.decryptDuration = decryptDuration + num4;
let num5 = passthroughCount2.decryptAttempts;
const decryptAttempts = passthroughCount.decryptAttempts;
if (num5 == null) {
num5 = 0;
}
passthroughCount.decryptAttempts = decryptAttempts + num5;
let num6 = passthroughCount2.decryptMissingKeyCount;
const decryptMissingKeyCount = passthroughCount.decryptMissingKeyCount;
if (num6 == null) {
num6 = 0;
}
passthroughCount.decryptMissingKeyCount = decryptMissingKeyCount + num6;
let num7 = passthroughCount2.decryptInvalidNonceCount;
const decryptInvalidNonceCount = passthroughCount.decryptInvalidNonceCount;
if (num7 == null) {
num7 = 0;
}
passthroughCount.decryptInvalidNonceCount = decryptInvalidNonceCount + num7;
let num8 = passthroughCount2.decryptFailureCount;
const decryptFailureAfterSuccessCount = passthroughCount.decryptFailureAfterSuccessCount;
if (num8 == null) {
num8 = 0;
}
let num9 = passthroughCount2.decryptFailureBeforeSuccessCount;
if (num9 == null) {
num9 = 0;
}
passthroughCount.decryptFailureAfterSuccessCount = decryptFailureAfterSuccessCount + (num8 - num9);
return passthroughCount;
}, { passthroughCount: 0, decryptSuccessCount: 0, decryptFailureCount: 0, decryptDuration: 0, decryptAttempts: 0, decryptMissingKeyCount: 0, decryptInvalidNonceCount: 0, decryptFailureAfterSuccessCount: 0 });
return { decrypt_passthrough_count: reduced.passthroughCount, decrypt_success_count: reduced.decryptSuccessCount, decrypt_failure_count: reduced.decryptFailureCount, decrypt_duration: reduced.decryptDuration, decrypt_attempts: reduced.decryptAttempts, decrypt_missing_key_count: reduced.decryptMissingKeyCount, decrypt_invalid_nonce_count: reduced.decryptInvalidNonceCount, decrypt_failure_after_success_count: reduced.decryptFailureAfterSuccessCount, encrypt_passthrough_count: this.outboundStats.passthroughCount, encrypt_success_count: this.outboundStats.encryptSuccessCount, encrypt_failure_count: this.outboundStats.encryptFailureCount, encrypt_duration: this.outboundStats.encryptDuration, encrypt_attempts: this.outboundStats.encryptAttempts, encrypt_max_attempts: this.outboundStats.encryptMaxAttempts, encrypt_missing_key_count: this.outboundStats.encryptMissingKeyCount };
}
getAudioDeviceStats() {
let accumulated1;
let accumulated2;
let accumulated3;
const self = this;
const restartCount = this.inputDeviceStats.restartCount;
let accumulated;
if (restartCount != null) {
accumulated = restartCount.accumulated;
}
const restartCount2 = self.outputDeviceStats.restartCount;
obj = { input_device_restart_count: accumulated, output_device_restart_count: accumulated1, input_device_time_to_first_audio: self.inputDeviceStats.timeToFirstCallbackMs, output_device_time_to_first_audio: self.outputDeviceStats.timeToFirstCallbackMs, input_device_buffer_overfull_count: accumulated2, output_device_buffer_underrun_count: accumulated3, input_device_session_sample_rate: self.inputDeviceStats.sessionSampleRate, output_device_session_sample_rate: self.outputDeviceStats.sessionSampleRate, input_device_time_from_connect_to_first_audio_ms: self.inputDeviceStats.timeFromConnectToFirstCallbackMs, output_device_time_from_connect_to_first_audio_ms: self.outputDeviceStats.timeFromConnectToFirstCallbackMs, audio_device_delay_ms: self.outputDeviceStats.delayMs, audio_device_total_delay_ms: self.inputDeviceStats.totalDelayMs };
accumulated1 = undefined;
if (restartCount2 != null) {
accumulated1 = restartCount2.accumulated;
}
const bufferViolations = self.inputDeviceStats.bufferViolations;
accumulated2 = undefined;
if (bufferViolations != null) {
accumulated2 = bufferViolations.accumulated;
}
const bufferViolations2 = self.outputDeviceStats.bufferViolations;
accumulated3 = undefined;
if (bufferViolations2 != null) {
accumulated3 = bufferViolations2.accumulated;
}
return obj;
}
getAudioLevelStats() {
const speakingAudioLevel = this.outboundStats.speakingAudioLevel;
const report = speakingAudioLevel.getReport([1, 5, 10, 25, 50, 75, 90, 95, 99]);
return { outbound_audio_level_db_p1: report.percentiles[1], outbound_audio_level_db_p5: report.percentiles[5], outbound_audio_level_db_p10: report.percentiles[10], outbound_audio_level_db_p25: report.percentiles[25], outbound_audio_level_db_p50: report.percentiles[50], outbound_audio_level_db_p75: report.percentiles[75], outbound_audio_level_db_p90: report.percentiles[90], outbound_audio_level_db_p95: report.percentiles[95], outbound_audio_level_db_p99: report.percentiles[99], outbound_audio_level_db_max: report.max, outbound_audio_level_db_mean: report.mean };
}
getPeriodicStats() {
let accelerated;
let cng;
let current;
let currentTimestampMs;
let expanded;
let merged;
let normal;
let preemptiveExpanded;
let previous;
let previousTimestampMs;
let silent;
let tmp6;
let tmp7;
const self = this;
const items = [];
const entries = Object.entries(this.periodicInboundStats);
const tmp2 = entries[Symbol.iterator]();
while (tmp2 !== undefined) {
let tmp5 = _slicedToArray(tmp3, 2);
[tmp6, tmp7] = tmp5;
let tmp8 = tmp7;
({ previous, current, currentTimestampMs, previousTimestampMs } = tmp7);
let tmp9 = previousTimestampMs;
let numRateSamples = tmp7.numRateSamples;
if (undefined !== previousTimestampMs) {
if (currentTimestampMs > tmp9) {
let diff = currentTimestampMs - tmp9;
obj = { userId: tmp6, silent, normal, merged, expanded, accelerated, preemptiveExpanded, cng, accelerateRate: tmp8.accelerateRateSum / numRateSamples, expandRate: tmp8.expandRateSum / numRateSamples, preemptiveExpandRate: tmp8.preemptiveExpandRateSum / numRateSamples, speechExpandRate: tmp8.speechExpandRateSum / numRateSamples, durationMs: diff };
silent = current.silent;
if (silent == null) {
let num = previous.silent;
if (num == null) {
num = 0;
}
silent = 0 - num;
}
normal = current.normal;
if (normal == null) {
let num2 = previous.normal;
if (num2 == null) {
num2 = 0;
}
normal = 0 - num2;
}
merged = current.merged;
if (merged == null) {
let num3 = previous.merged;
if (num3 == null) {
num3 = 0;
}
merged = 0 - num3;
}
expanded = current.expanded;
if (expanded == null) {
let num4 = previous.expanded;
if (num4 == null) {
num4 = 0;
}
expanded = 0 - num4;
}
accelerated = current.accelerated;
if (accelerated == null) {
let num5 = previous.accelerated;
if (num5 == null) {
num5 = 0;
}
accelerated = 0 - num5;
}
preemptiveExpanded = current.preemptiveExpanded;
if (preemptiveExpanded == null) {
let num6 = previous.preemptiveExpanded;
if (num6 == null) {
num6 = 0;
}
preemptiveExpanded = 0 - num6;
}
cng = current.cng;
if (cng == null) {
let num7 = previous.cng;
if (num7 == null) {
num7 = 0;
}
cng = 0 - num7;
}
if (obj.normal + obj.merged + obj.expanded + obj.accelerated + obj.preemptiveExpanded > 0) {
let arr = items.push(tmp26);
}
}
}
self.periodicInboundStats[tmp6].accelerateRateSum = 0;
self.periodicInboundStats[tmp6].expandRateSum = 0;
self.periodicInboundStats[tmp6].preemptiveExpandRateSum = 0;
self.periodicInboundStats[tmp6].speechExpandRateSum = 0;
self.periodicInboundStats[tmp6].numRateSamples = 0;
self.periodicInboundStats[tmp6].previous = current;
self.periodicInboundStats[tmp6].previousTimestampMs = currentTimestampMs;
continue;
}
return items;
}
markUserDisconnected(sender_user_id) {
if (null != this.inboundStats[sender_user_id]) {
const _performance = performance;
this.inboundStats[sender_user_id].disconnectedAtMs = performance.now();
}
}
getInboundParticipants() {
obj = SnowflakeUtilsDefault;
return obj.keys(this.inboundStats);
}
}
const prototype = VoiceQuality.prototype;
let result = size.fileFinishedImporting("lib/VoiceQuality.tsx");
export default VoiceQuality;
export { VoiceQualityEvent };