shaka-player
shaka-player copied to clipboard
feat: CMCD v2 LTC and MSD keys
This PR introduces two new CMCD v2 keys to shaka player:
- ltc (live stream latency): The time delta between when a given media timestamp was made available at the origin and when it was rendered by the client.
- msd (media start delay): Measures the initial delay in wall-clock time from when a player is instructed to play media for a given session to when any media begins playback. (This is sent only once when it is calculated)
While this update does not implement full CMCD v2 support, it extends the CMCD v1 implementation to handle these two new values when requested.
Summary:
- Updated the player settings:
cmcd.reporting.requestMode.version
must be set to 2 to use these new CMCD v2 keys. - Implemented logic to retrieve the values for ltc and msd if requested and if the version is set to 2.
- Implemented logic to send the msd value only once.
- Created
getLiveLatency()
method in player to calculate the latency and use it for ltc. - Created unit tests for the two new keys (ltc and msd) to ensure their correct behavior when
cmcd.reporting.requestMode.version
is set to 2.
Testing:
- Verified that the ltc and msd keys are included when the reporting version is set to 2 and these keys are requested. And the msd key is sent only once when it is calculated.
- Verified that these keys are not included when the version is set to 1 or it is not set.
How to Test manually:
Test that msd and ltc values are sent correctly
Set the following configuration to the player:
player.configure({
cmcd: {
enabled: true,
reporting: {
requestMode: {
version: 2,
},
},
includeKeys: ['sid', 'cid', 'v', 'msd', 'ltc'],
}
});
Verify that the msd value is sent only once after being calculated, and the ltc value is sent with every request.
Test the msd value is calculated correctly
Use throttling in your browser to slow down your connection and reproduce the streaming.
The msd value should be higher than usual.
Notes:
- This PR adds support for the ltc and msd keys but does not implement the entire CMCD v2