mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-04 20:43:02 +08:00
Add v3 batched downlink with tick-aligned timestamps, audio-clock playback and PLC; add adaptive Opus/PCM uplink and one-shot TURN relay retry. Expose frame size, automatic relay retry and Cloudflare ingress assumptions in the admin console, with persistence, i18n, docs and regression tests.
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import {
|
|
computeTargetAheadMs,
|
|
JitterEstimator,
|
|
shouldRecover,
|
|
shouldResetSchedule,
|
|
} from "../src/voice/jitter-buffer.ts";
|
|
|
|
test("target buffer maps p95 jitter to the 80-300 ms adaptive range", () => {
|
|
assert.equal(computeTargetAheadMs(0), 80);
|
|
assert.equal(computeTargetAheadMs(30), 90);
|
|
assert.equal(computeTargetAheadMs(100), 160);
|
|
assert.equal(computeTargetAheadMs(1_000), 300);
|
|
});
|
|
|
|
test("a configured 80 ms ceiling restores the old buffer bound", () => {
|
|
assert.equal(computeTargetAheadMs(100, 80), 80);
|
|
assert.equal(computeTargetAheadMs(0, 80), 80);
|
|
});
|
|
|
|
test("jitter estimator raises the target after a late burst", () => {
|
|
const estimator = new JitterEstimator();
|
|
assert.equal(estimator.observe(0, 1_000), 80);
|
|
assert.equal(estimator.observe(20, 1_020), 80);
|
|
const target = estimator.observe(40, 1_080);
|
|
assert.ok(target > 80, `expected target above 80 ms, received ${target}`);
|
|
assert.ok(target <= 300);
|
|
});
|
|
|
|
test("schedule reset and recovery thresholds keep hysteresis", () => {
|
|
assert.equal(shouldResetSchedule(400, 80), true);
|
|
assert.equal(shouldResetSchedule(300, 80), false);
|
|
assert.equal(shouldRecover(10), true);
|
|
assert.equal(shouldRecover(30), false);
|
|
});
|