From b5d005c33bbaff2c6668bb3f87cc56d1b85bc6c4 Mon Sep 17 00:00:00 2001 From: MathieuPoux Date: Tue, 31 Mar 2026 17:56:03 +0200 Subject: [PATCH 1/4] chore(.gitignore): add .codex to ignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b2b0bdb..463304d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ coverage/ *.sublime-project *.tmproj .vscode/ +.codex From 9c74b31a511929647ed6c61f7505b15ca58e302b Mon Sep 17 00:00:00 2001 From: MathieuPoux Date: Tue, 31 Mar 2026 17:56:31 +0200 Subject: [PATCH 2/4] feat(PlayerStats): dissociate each byte rate type and adjust CMCD throughput calculation --- src/stats/PlayerStats.spec.ts | 5 +++-- src/stats/PlayerStats.ts | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/stats/PlayerStats.spec.ts b/src/stats/PlayerStats.spec.ts index b9ff36c..6340464 100644 --- a/src/stats/PlayerStats.spec.ts +++ b/src/stats/PlayerStats.spec.ts @@ -15,7 +15,8 @@ describe('PlayerStats', () => { stats.protocol = 'HLS'; stats.bufferAmount = 1000; stats.playbackRate = 1.5; - stats.recvByteRate = 50_000; + stats.audioByteRate = 60; + stats.videoByteRate = 1500; stats.waitingData = true; stats.stallCount = 3; stats.videoTrackId = 1; @@ -37,7 +38,7 @@ describe('PlayerStats', () => { br: 1500, bs: true, bl: 1000, - mtp: 50_000, + mtp: 1560, pr: 1.5, sf: 'h', su: true diff --git a/src/stats/PlayerStats.ts b/src/stats/PlayerStats.ts index 342b9cf..ce0fb4a 100644 --- a/src/stats/PlayerStats.ts +++ b/src/stats/PlayerStats.ts @@ -29,8 +29,9 @@ export class PlayerStats extends Loggable { playbackSpeed?: number; playbackRate?: number; - recvByteRate?: number; // Bps in reception - sendByteRate?: number; // Bps in sending + audioByteRate?: number; // current audio Bps + videoByteRate?: number; // current video Bps + dataByteRate?: number; // current data Bps videoTrackId?: number; // video track selected videoTrackBandwidth?: number; // video bandwidth currently playing @@ -86,8 +87,9 @@ export class PlayerStats extends Loggable { if (this.bufferAmount != null) { cmcd.bl = this.bufferAmount; // Buffer Length } - if (this.recvByteRate != null) { - cmcd.mtp = this.recvByteRate; // Measured mtp CMCD throughput + if (this.audioByteRate != null || this.videoByteRate != null || this.dataByteRate != null) { + // Measured mtp CMCD throughput + cmcd.mtp = (this.audioByteRate ?? 0) + (this.videoByteRate ?? 0) + (this.dataByteRate ?? 0); } if (playBack != null) { cmcd.pr = Number(playBack.toFixed(2)); // Playback Rate From 38ac6b8550546aa8e7d6c26d74b2e4fa06ad2d78 Mon Sep 17 00:00:00 2001 From: MathieuPoux Date: Tue, 31 Mar 2026 19:06:19 +0200 Subject: [PATCH 3/4] test(PlayerStats): fix coverage test for PlayerStats.ts --- package.json | 2 +- src/stats/PlayerStats.spec.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e9f81a9..25d258d 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "build:es5": "rollup -c --format umd", "build:docs": "typedoc index.ts", "test": "vitest", - "test:coverage": "vitest --coverage", + "test:coverage": "vitest --run --coverage", "lint": "eslint . && prettier --check .", "eslint": "eslint --fix .", "prettier": "prettier --write --ignore-unknown .", diff --git a/src/stats/PlayerStats.spec.ts b/src/stats/PlayerStats.spec.ts index 6340464..17bf8a4 100644 --- a/src/stats/PlayerStats.spec.ts +++ b/src/stats/PlayerStats.spec.ts @@ -45,6 +45,16 @@ describe('PlayerStats', () => { }); }); + it('should set mtp from dataByteRate when audio and video byte rates are missing', () => { + const stats = new PlayerStats(); + stats.dataByteRate = 512; + + const url = new URL('https://example.com/live/chunk.ts'); + const cmcd = stats.toCmcd(url, 99); + + expect(cmcd.mtp).toBe(512); + }); + it('should select the correct object type and bitrate for audio track', () => { const stats = new PlayerStats(); stats.audioTrackId = 2; From 883ae41cba9e2fb4b49c2ff04ccba13dd6b06e7c Mon Sep 17 00:00:00 2001 From: MathieuPoux Date: Tue, 31 Mar 2026 19:07:26 +0200 Subject: [PATCH 4/4] test(Util): adjust time expectation tolerance in time unit tests --- src/Util.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Util.spec.ts b/src/Util.spec.ts index 9126dfc..cb9a6b4 100644 --- a/src/Util.spec.ts +++ b/src/Util.spec.ts @@ -13,10 +13,10 @@ describe('Util', () => { const time0 = Util.time(); await new Promise(resolve => setTimeout(resolve, 100)); const time100 = Util.time(); - expect(time100).toBeGreaterThanOrEqual(time0 + 100); + expect(time100).toBeGreaterThanOrEqual(time0 + 95); const unixTime = Util.unixTime(); - expect(unixTime).toBeGreaterThanOrEqual(Math.floor(performance.timeOrigin + time0 + 100)); + expect(unixTime).toBeGreaterThanOrEqual(Math.floor(performance.timeOrigin + time0 + 95)); expect(unixTime).toBeGreaterThanOrEqual(Math.floor(performance.timeOrigin + time100)); }); });