-
Notifications
You must be signed in to change notification settings - Fork 0
Feature Cmcdv2 #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Feature Cmcdv2 #72
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of DASH specific terms like mpd, should this just be a list of CmcdObjectType values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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: