Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/CeeblueTV/wrts-client/llms.txt

Use this file to discover all available pages before exploring further.

Common Media Client Data (CMCD) is a CTA-5004 standard for embedding client-side playback metrics in each media request so the origin server or CDN can make informed caching and routing decisions. The WebRTS Client implements CMCD on HTTPAdaptiveSource, allowing you to enable telemetry with a single property assignment on the Player or Source instance. The three enums and interface below define what data is sent and how it is delivered.
import { CMCD, CMCDMode, ICMCD } from '@ceeblue/wrts-client';

CMCD Enum

Controls whether CMCD telemetry is enabled and how much data is included in each request.
CMCD.NONE
'none'
CMCD is disabled. No extra headers or query parameters are added to media requests. This is the default value.
CMCD.SHORT
'short'
Sends only the essential CMCD keys, omitting verbose fields such as cid (content ID), dl (deadline), ot (object type), and st (stream type). Use this mode in production to reduce per-request header overhead while retaining useful signal for the CDN.
CMCD.FULL
'full'
Sends all available CMCD keys on every media request. Useful for development and debugging when you want the complete telemetry picture.

CMCDMode Enum

Controls the transport mechanism used to deliver CMCD data to the server.
CMCDMode.HEADER
'header'
CMCD data is delivered via structured HTTP request headers (e.g. CMCD-Request, CMCD-Object, CMCD-Status, CMCD-Session). This is the default mode and is preferred for most deployments because headers are not cached and do not pollute CDN cache keys.
CMCDMode.QUERY
'query'
CMCD data is delivered by appending a cmcd=… query parameter to every segment URL. Use this mode when your CDN or proxy cannot read custom request headers but can inspect query strings.

ICMCD Interface

ICMCD is the interface implemented by both Player and HTTPAdaptiveSource. Setting any property to undefined resets it to its documented default.
cmcd
CMCD (get/set)
Gets or sets the CMCD reporting level.
  • Getter returns the current CMCD enum value.
  • Setter accepts a CMCD value or undefined. Setting undefined resets to CMCD.NONE.
player.cmcd = CMCD.FULL;
player.cmcd = undefined; // resets to CMCD.NONE
cmcdMode
CMCDMode (get/set)
Gets or sets the CMCD delivery mechanism.
  • Getter returns the current CMCDMode enum value.
  • Setter accepts a CMCDMode value or undefined. Setting undefined resets to CMCDMode.HEADER.
player.cmcdMode = CMCDMode.QUERY;
player.cmcdMode = undefined; // resets to CMCDMode.HEADER
cmcdSid
string (get/set)
Gets or sets the CMCD session ID (sid key). The session ID correlates multiple requests belonging to the same playback session.
  • Getter returns the current session ID string (empty string if unset).
  • Setter accepts a string or undefined. Setting undefined resets to ''.
player.cmcdSid = 'session-abc123';
player.cmcdSid = undefined; // resets to ''

Enabling CMCD on a Player

import { Player, CMCD, CMCDMode } from '@ceeblue/wrts-client';

const player = new Player(document.querySelector('video')!);
player.start({ endPoint: 'https://live.example.com/stream' });

// Enable CMCD after start (the underlying HTTPAdaptiveSource is now available)
player.cmcd = CMCD.FULL;
player.cmcdMode = CMCDMode.HEADER;
player.cmcdSid = 'session-abc123';

Reading CMCD Settings from URL Parameters

When building a player page that must be configurable via URL, you can pass URL parameters directly to the CMCD setters. Because the setters treat undefined as a reset-to-default signal, missing parameters are handled gracefully without any extra null-checks:
const options = Object.fromEntries(new URLSearchParams(location.search));

// Each setter accepts string | undefined — undefined resets to the default value
player.cmcd = options.cmcd as CMCD | undefined;       // undefined → CMCD.NONE
player.cmcdMode = options.cmcdMode as CMCDMode | undefined; // undefined → CMCDMode.HEADER
player.cmcdSid = options.cmcdSid;                     // undefined → ''
For example, navigating to ?cmcd=full&cmcdMode=query&cmcdSid=abc enables full CMCD over query string with session ID abc.
CMCD is only supported by HTTPAdaptiveSource (HLS/DASH adaptive streams). Setting cmcd to any value other than CMCD.NONE on WSSource (WebSocket-based playback) or the abstract Source base class will have no effect or may throw. Check the source type before setting CMCD properties if you are writing code that works with multiple source types.
Prefer CMCD.SHORT over CMCD.FULL in production. The short mode omits less-actionable fields and reduces per-segment header size, which is especially important for streams with very short segment durations where request overhead is significant.

Build docs developers (and LLMs) love