feat: complete Ancestor quote bot with production-ready Docker support

This commit is contained in:
unfunny
2026-09-13 14:14:38 -04:00
parent f2016da05a
commit fe7351a7dc
1145 changed files with 30890 additions and 97684 deletions

View File

@@ -1,5 +1,11 @@
import { ValueFormatter } from "./valueFormatter.js";
export class TrackStatsBuilder {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TrackStatsBuilder = void 0;
var _valueFormatter = require("./valueFormatter");
class TrackStatsBuilder {
static buildFramerateResolution(trackStats, now) {
const resolution = {
height: now.frameHeight,
@@ -31,7 +37,7 @@ export class TrackStatsBuilder {
trackStats.setFramerate(frameRate);
}
static buildCodec(report, trackStats, now) {
const codec = report?.get(now.codecId);
const codec = report === null || report === void 0 ? void 0 : report.get(now.codecId);
if (codec) {
/**
* The mime type has the following form: video/VP8 or audio/ISAC,
@@ -39,7 +45,7 @@ export class TrackStatsBuilder {
* keys will be added on the processing side.
*/
const codecShortType = codec.mimeType.split("/")[1];
if (codecShortType) trackStats.setCodec(codecShortType);
codecShortType && trackStats.setCodec(codecShortType);
}
}
static buildBitrateReceived(trackStats, now, before) {
@@ -60,10 +66,10 @@ export class TrackStatsBuilder {
if (!packetsNow || packetsNow < 0) {
packetsNow = 0;
}
const packetsBefore = ValueFormatter.getNonNegativeValue(before[key]);
const packetsBefore = _valueFormatter.ValueFormatter.getNonNegativeValue(before[key]);
const packetsDiff = Math.max(0, packetsNow - packetsBefore);
const packetsLostNow = ValueFormatter.getNonNegativeValue(now.packetsLost);
const packetsLostBefore = ValueFormatter.getNonNegativeValue(before.packetsLost);
const packetsLostNow = _valueFormatter.ValueFormatter.getNonNegativeValue(now.packetsLost);
const packetsLostBefore = _valueFormatter.ValueFormatter.getNonNegativeValue(before.packetsLost);
const packetsLostDiff = Math.max(0, packetsLostNow - packetsLostBefore);
trackStats.setLoss({
packetsTotal: packetsDiff + packetsLostDiff,
@@ -72,8 +78,8 @@ export class TrackStatsBuilder {
});
}
static calculateBitrate(bytesNowAny, bytesBeforeAny, nowTimestamp, beforeTimestamp) {
const bytesNow = ValueFormatter.getNonNegativeValue(bytesNowAny);
const bytesBefore = ValueFormatter.getNonNegativeValue(bytesBeforeAny);
const bytesNow = _valueFormatter.ValueFormatter.getNonNegativeValue(bytesNowAny);
const bytesBefore = _valueFormatter.ValueFormatter.getNonNegativeValue(bytesBeforeAny);
const bytesProcessed = Math.max(0, bytesNow - bytesBefore);
const timeMs = nowTimestamp - beforeTimestamp;
let bitrateKbps = 0;
@@ -83,11 +89,12 @@ export class TrackStatsBuilder {
return bitrateKbps;
}
static setTrackStatsState(trackStats, transceiver) {
var _transceiver$sender;
if (transceiver === undefined) {
trackStats.alive = false;
return;
}
const track = trackStats.getType() === "remote" ? transceiver.receiver.track : transceiver?.sender?.track;
const track = trackStats.getType() === "remote" ? transceiver.receiver.track : transceiver === null || transceiver === void 0 || (_transceiver$sender = transceiver.sender) === null || _transceiver$sender === void 0 ? void 0 : _transceiver$sender.track;
if (track === undefined || track === null) {
trackStats.alive = false;
return;
@@ -132,8 +139,9 @@ export class TrackStatsBuilder {
trackSummary.maxPacketLoss = stats.getLoss().packetsLost;
}
if (audioTrackList.length > 0) {
trackSummary.concealedAudio += stats.getAudioConcealment()?.concealedAudio;
trackSummary.totalAudio += stats.getAudioConcealment()?.totalAudioDuration;
var _stats$getAudioConcea, _stats$getAudioConcea2;
trackSummary.concealedAudio += (_stats$getAudioConcea = stats.getAudioConcealment()) === null || _stats$getAudioConcea === void 0 ? void 0 : _stats$getAudioConcea.concealedAudio;
trackSummary.totalAudio += (_stats$getAudioConcea2 = stats.getAudioConcealment()) === null || _stats$getAudioConcea2 === void 0 ? void 0 : _stats$getAudioConcea2.totalAudioDuration;
}
});
return {
@@ -145,9 +153,9 @@ export class TrackStatsBuilder {
if (statsReport.type !== "inbound-rtp") {
return;
}
const jitterStr = statsReport?.jitter;
const jitterStr = statsReport === null || statsReport === void 0 ? void 0 : statsReport.jitter;
if (jitterStr !== undefined) {
const jitter = ValueFormatter.getNonNegativeValue(jitterStr);
const jitter = _valueFormatter.ValueFormatter.getNonNegativeValue(jitterStr);
trackStats.setJitter(Math.round(jitter * 1000));
} else {
trackStats.setJitter(-1);
@@ -157,10 +165,11 @@ export class TrackStatsBuilder {
if (statsReport.type !== "inbound-rtp") {
return;
}
const msPerSample = 1000 * statsReport?.totalSamplesDuration / statsReport?.totalSamplesReceived;
const concealedAudioDuration = msPerSample * statsReport?.concealedSamples;
const totalAudioDuration = 1000 * statsReport?.totalSamplesDuration;
const msPerSample = 1000 * (statsReport === null || statsReport === void 0 ? void 0 : statsReport.totalSamplesDuration) / (statsReport === null || statsReport === void 0 ? void 0 : statsReport.totalSamplesReceived);
const concealedAudioDuration = msPerSample * (statsReport === null || statsReport === void 0 ? void 0 : statsReport.concealedSamples);
const totalAudioDuration = 1000 * (statsReport === null || statsReport === void 0 ? void 0 : statsReport.totalSamplesDuration);
trackStats.setAudioConcealment(concealedAudioDuration, totalAudioDuration);
}
}
exports.TrackStatsBuilder = TrackStatsBuilder;
//# sourceMappingURL=trackStatsBuilder.js.map