-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Is your feature request related to a problem? Please describe.
hls.js currently implements CMCD version 1 (CTA-5004). The CTA-5004 specification has been updated to version 2 which introduces new keys, event-mode reporting, and structured field value encoding. Without v2 support, hls.js users cannot take advantage of the latest analytics and observability capabilities defined by the specification.
Related open issues that would be addressed:
- Implement CMCD deadline (dl) property #6100 - Implement CMCD deadline (
dl) property - Implement CMCD requested maximum throughput (rtp) property #6090 - Implement CMCD requested maximum throughput (
rtp) property - Implement CMCD next range request (nrr) property #6089 - Implement CMCD next range request (
nrr) property
Describe the solution you'd like
Add opt-in CMCD v2 support with the following scope:
Configuration
A version option on CMCDControllerConfig (1 | 2, default 1) to enable v2 behavior, and an eventTargets array for event-mode reporting endpoints:
const hls = new Hls({
cmcd: {
version: 2,
sessionId: 'session-123',
contentId: 'content-456',
useHeaders: true,
eventTargets: [
{
url: 'https://analytics.example.com/cmcd',
events: ['ps', 'e', 'br'],
interval: 30,
},
],
},
});New v2 keys
| Key | Name | Description |
|---|---|---|
v |
Version | CMCD version identifier (included when version >= 2) |
st |
Stream Type | "v" (VOD), "l" (LIVE), "ll" (LOW_LATENCY) — auto-detected from level details |
sta |
Player State | "s" (STARTING), "p" (PLAYING), "k" (SEEKING), "r" (REBUFFERING), "a" (PAUSED), "e" (ENDED), "f" (FATAL_ERROR) — tracked from media element events |
v2 data format changes
Per the v2 spec, several existing keys use array values via Structured Field Value encoding: br, bl, mtp, tb, nor.
Event-mode reporting
CMCD v2 introduces event-mode reporting via CmcdReporter, where playback events (play state transitions, fatal errors, bitrate changes) are sent to configured endpoints independently from segment/playlist requests. This enables richer observability without coupling analytics to media request timing.
Dependency migration
Migrate CMCD encoding from @svta/common-media-library (which ships hundreds of individual files and causes source map issues — see #7718) to the dedicated @svta/cml-cmcd package, which provides a single bundled entry point with proper source maps.
Public type exports
Export v2 constants and types for TypeScript consumers: CMCD_V1, CMCD_V2, CmcdObjectType, CmcdStreamType, CmcdStreamingFormat, CmcdPlayerState, CmcdEventType, CmcdHeaderField, Cmcd, CmcdEncodeOptions, CmcdEventReportConfig, CmcdVersion.
Additional context
- Non-breaking: Default remains v1; v2 is entirely opt-in
- V1 Spec reference: CTA-5004 Common Media Client Data
- V2 Spec reference: CTA-5004-A Common Media Client Data
- Reference implementation:
@svta/cml-cmcdv2.1.1