Skip to content

Conversation

@Wolvad
Copy link

@Wolvad Wolvad commented Jan 20, 2026

https://linear.app/ceeblue/issue/ENG-1187

🚀 Features

  • (index,stats/playerstats) Add playerstats.ts with tocmcd method

⚙️ Miscellaneous Tasks

  • (index,package,rollup.config) Add @svta/common-media-library and @rollup/plugin-node-resolve

Copilot AI review requested due to automatic review settings January 20, 2026 10:16
@Wolvad
Copy link
Author

Wolvad commented Jan 20, 2026

PlayerStats might need to be updated with our needs, it is expected to be extensible.

@Wolvad Wolvad changed the title Eng 1187 bis Add PlayerStats to web-utils, with tocmcd method Jan 20, 2026
@MathieuPOUX MathieuPOUX requested review from MathieuPOUX and thomasjammet and removed request for Copilot January 20, 2026 10:19
@MathieuPOUX MathieuPOUX self-assigned this Jan 20, 2026
@MathieuPOUX MathieuPOUX requested a review from jobl January 20, 2026 10:53
Copilot AI review requested due to automatic review settings January 20, 2026 10:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new PlayerStats class to the web-utils library with a toCmcd method for converting player statistics to CMCD (Common Media Client Data) format. It also adds the @svta/common-media-library dependency and configures rollup to bundle external dependencies.

Changes:

  • Adds PlayerStats class with properties for tracking media player metrics and a toCmcd conversion method
  • Includes @svta/common-media-library as a new production dependency and adds @rollup/plugin-node-resolve as a dev dependency
  • Migrates from simple-git-hooks to husky for git hooks management (undocumented change)

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
stats/PlayerStats.ts New class with media player statistics properties and CMCD conversion method
index.ts Exports new PlayerStats class and re-exports CMCD types from @svta/common-media-library
package.json Adds @svta/common-media-library dependency, @rollup/plugin-node-resolve, removes simple-git-hooks, updates prepare script to use husky
rollup.config.js Adds nodeResolve plugin to bundle external dependencies
package-lock.json Lock file updates reflecting dependency changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 43 to 70
toCmcd(trackId: number, prevStats?: PlayerStats): Cmcd {
const sfByProtocol = {
dash: 'd',
hls: 'h',
smooth: 's'
};

const sf = this.protocol?.toLowerCase()
? sfByProtocol[this.protocol?.toLowerCase() as keyof typeof sfByProtocol]
: undefined;

const cmcd: Cmcd = {
bl: this.bufferAmount,
bs: (this.stallCount ?? 0) - (prevStats?.stallCount ?? 0) > 0,
br: (this.audioTrackBandwidth ?? 0) + (this.videoTrackBandwidth ?? 0),
mtp: this.recvByteRate,
pr: this.playbackRate ?? this.playbackSpeed,
sf: sf as CmcdStreamingFormat | undefined,
su: this.waitingData
};
if (trackId === this.videoTrackId) {
cmcd.br = this.videoTrackBandwidth ?? 0;
} else if (trackId === this.audioTrackId) {
cmcd.br = this.audioTrackBandwidth ?? 0;
}
return cmcd;
}
}
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new PlayerStats class and its toCmcd method lack test coverage. This repository has comprehensive test files for other modules (e.g., Connect.spec.ts, EventEmitter.spec.ts, NetAddress.spec.ts), but no corresponding test file exists for PlayerStats. Consider adding stats/PlayerStats.spec.ts to test the toCmcd method logic, especially edge cases like undefined protocol values, missing track IDs, and the stall count calculation.

Copilot uses AI. Check for mistakes.
@MathieuPOUX MathieuPOUX changed the title Add PlayerStats to web-utils, with tocmcd method Add a PlayerStats base interface with Cmcd conversion support Jan 20, 2026
pr: this.playbackRate ?? this.playbackSpeed,
sf: sf as CML.CmcdStreamingFormat | undefined,
su: this.waitingData
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is missing it =>

cmcd.cid = url.pathname.split('/').pop();
                cmcd.dl = this._playing.bufferAmount * this._playing.playbackRate;
                cmcd.ot =
                    type === Media.Type.AUDIO
                        ? CmcdObjectType.AUDIO
                        : type === Media.Type.VIDEO
                          ? CmcdObjectType.VIDEO
                          : CmcdObjectType.OTHER;
                cmcd.st = CmcdStreamType.LIVE;
                cmcd.v = 1;

and I get a doubt also for cmcd.sid, maybe need to demystify it with IA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants