Conversation
src/core/Settings.js
Outdated
| * @property {Array.<string>} [includeOnRequests] | ||
| * Types of requests CMCD should be included on (e.g., 'mpd', 'segment'). |
There was a problem hiding this comment.
Instead of DASH specific terms like mpd, should this just be a list of CmcdObjectType values?
There was a problem hiding this comment.
That is a good observation, the only catch I see is that not all the request types that we need are present on the CmcdObjectType. Here are the values that we use for filtering:
const filtersTypes = {
[HTTPRequest.INIT_SEGMENT_TYPE]: 'segment',
[HTTPRequest.MEDIA_SEGMENT_TYPE]: 'segment',
[HTTPRequest.XLINK_EXPANSION_TYPE]: 'xlink',
[HTTPRequest.MPD_TYPE]: 'mpd',
[HTTPRequest.CONTENT_STEERING_TYPE]: 'steering',
[HTTPRequest.OTHER_TYPE]: 'other',
};
src/streaming/models/CmcdModel.js:607
Some types like xlink or steering seems like are not being mapped into CmcdObjectType, so we would only be able to replace some of the values (like mpd, other and init) for the CmcdObjectType.
There was a problem hiding this comment.
Wouldn't they be listed as CmcdObjectType.OTHER? Steering is an interesting use case. @nicolaslevy Should that be added to spec as another object type?
| function _createCmcdV2HeadersCustomMap() { | ||
| const cmcdVersion = settings.get().streaming.cmcd.version; | ||
| return cmcdVersion === 1 ? {} : { | ||
| customHeaderMap: { | ||
| [CmcdHeaderField.REQUEST]: ['ltc'], | ||
| [CmcdHeaderField.SESSION]: ['msd'] | ||
| } | ||
| }; | ||
| } |
There was a problem hiding this comment.
The header mapping in CML was updated with the new CMCD v2 keys in version 0.15.1. This function should no longer be needed.
cdbf737 to
18964ea
Compare
042af7e to
7a9cff6
Compare
* cmcd reporter initialization * request mode migration * event mode migration * cmcd model migration * fix cmcd model unit tests * fixes for cmcd parameters and cleanup - protection controller fixes WIP * cleanup and update unit tests * refactor unit tests and fixes * fix unit tests and remove batchTimer
* ab, lab and tab inner list and request mode * ab, tab and lab inner list for v2 * bl inner list and event mode * br inner list and event mode * toInnerList helper * bsd inner list * mtp inner list and event mode * nor inner list * pb inner list and event mode * tp inner list and event mode * tpb inner list and event mode * fix unit tests
* chore: update CML dependencies * fix: update common media request * fix: update resourceTiming properties to use performance.now() * fix: update cmcd data formatting * fix: remove redundant rr values * refactor: simplify cmcd reporting * fix: test mock requests missing parameters * chore: update cml cmcd version * should not send report if events are undefined * fix unit tests --------- Co-authored-by: cotid-qualabs <constanzad@qualabs.com>
This Pull Request introduces comprehensive support for CMCD (Common Media Client Data) Version 2, significantly expanding the player's capabilities for media analytics and client-side data reporting. The changes allow for more granular control over what data is sent, how it's sent, and to where, aligning with the latest CMCD specifications.
Key Features & Enhancements:
CMCD v2 Specification Adherence:
ltc-rc-bg-sta-ttfb-ttlb-ts-url-ec-msd-e-cmsdd-cmsds-df-sn-pb-tpb-bsdNew CMCD Reporting Modes:
event): Enables CMCD data reporting triggered by specific player events (e.g., playback state changes, errors) or at configurable time intervals. This allows for real-time or near real-time feedback on player behavior.ps-e-ts-p-k-r-a-w-e-fresponse): Facilitates CMCD data reporting after a media segment or manifest response is received. This mode includes response-specific metrics like Time To First Byte (ttfb), Time To Last Byte (ttlb), and response code (rc).Multiple Reporting Targets & Granular Configuration:
streaming.cmcd.targetsarray in the player settings. This allows developers to configure multiple CMCD reporting endpoints.url: The destination URL for the CMCD report.mode: The data transmission mode to use for this target (queryorheader).cmcdMode: The reporting mode to use for this target (eventorresponse).enabledKeys: A specific list of CMCD keys to include for this target. If not defined, sends all available keys for the target. If the list is empty, no keys are sent.events(for event mode): An array of player events that should trigger a CMCD report. If events is not defined, all available events trigger a CMCD report. If the array is empty, no event-specific CMCD data will be sent.timeInterval(for event mode): The interval in seconds for periodic CMCD reports. If value is 0, periodic reports are disabled.includeInRequests(for request/response modes): Specifies which types of HTTP requests (e.g.,manifest,mediaSegmentInit,mediaSegment) should include CMCD data for this target.Refined Orchestration of CMCD data via
CmcdController:CmcdControlleris responsible for orchestrating all CMCD v2 data collection, formatting, and reporting.Refined State Management via
CmcdModel:CmcdModelhas been updated to manage and provide the necessary player and media state for all supported CMCD modes and keys, including new v2 parameters.Request/Response Interceptors:
_cmcdRequestModeInterceptorinjects CMCD data into outgoing requests (forqueryandheadermodes)._cmcdResponseModeInterceptorprocesses incoming responses to gather data forresponsemode and triggers reports.New Sample Pages
CMCD v2 Reportingsample page showcases how to set up CMCD v2 and its new target configurations for each new mode.CMCD v2 Callbacks with Network Interceptorssample page introduces a demonstration of using Interceptors to add custom keys as a callback before a report and also processing CMCD data on a callback after the server response.Batching
The CmcdBatchController is a new component designed to efficiently manage and send Common Media Client Data (CMCD) reports. Instead of sending each report as a separate HTTP request, this controller aggregates them into batches, reducing network traffic and server load.
batchTimer): You can configure abatchTimer(in seconds) for a reporting target. When the first report for a target is received, a timer is started. When the timer expires, all collected reports for that target are sent as a single batch.batchSize): You can configure abatchSizefor a reporting target. The controller tracks the number of reports in the current batch. Once the count reaches thebatchSize, the batch is sent immediately, even if thebatchTimerhas not expired.CmcdBatchControllerincludes logic to handle specific HTTP error responsesUnit Testing
Common Media Library Integration
Main Files Affected:
src/streaming/controllers/CmcdController.js: Contains the core logic for CMCD v2, including handling for new modes, multiple targets, key filtering, and integration with the CMCD library.src/streaming/models/CmcdModel.js: Updated to store and manage state for new CMCD v2 parameters and reporting modes.src/core/Settings.js(implied changes): Updated to include new configuration options for CMCD v2, particularly thestreaming.cmcd.targetsarray and CMCD version selection.These changes provide a much more flexible and powerful CMCD implementation, enabling richer analytics and better interoperability with CDNs and other services that consume CMCD data.
Future Work
While the current implementation of CMCD v2 in dash.js provides basic functionality, there are several areas identified for future enhancements and development: