Feature Cmcdv2#72
Open
cotid-qualabs wants to merge 99 commits into
Open
Conversation
littlespex
reviewed
May 22, 2025
littlespex
reviewed
Jun 23, 2025
littlespex
reviewed
Jul 2, 2025
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
…rum#4925) * Catch errors triggered by changeType * If changeType() triggers a NotSupportedError then disable changeType and resetSourceBuffer for track switches * Remove firstFragmentedSubtitleStart from cts calculation as it leads to wrong buffered ranges for multiperiod content * Refactoring
* 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>
* Run npm audit fix * Sort by k attribute in case all parameters like bandwidth etc are the same to avoid oscillating ABR switches * For SegmentSequenceProperties use information about bootstrap representations when ordering * Refactor _getMaxFragmentDurationForLiveDelayCalculation * Fix a typo
…m#4937) * perf(abr): replace Object.keys().forEach with for..in loop Replace nested Object.keys().forEach calls with for..in loops in _onVideoElementResized to avoid array allocations on video resize events. This reduces memory pressure on devices with limited resources like Smart TVs. * perf(net): replace Object.keys().map with for..in loop Replace Object.keys().map() with a for..in loop in _addPathwayCloningParameters to reduce array allocations during HTTP requests with query parameters. This optimization benefits devices with constrained memory like Smart TVs. * perf(events): optimize Object.keys usage in hot paths - Add _isEmptyObject() helper to avoid array allocation for length check - Replace Object.keys() loops with for..in in _iterateAndTriggerCallback - Replace .forEach() with standard for loop for array iteration These functions are called every 100ms during playback, so reducing allocations helps minimize garbage collection on resource-constrained devices like Smart TVs.
…ash-Industry-Forum#4943) Replace hardcoded 100ms GAP_HANDLER_INTERVAL with configurable settings.get().streaming.gaps.checkInterval (default 250ms), replace Object.keys().some() with for..in loop, and cache settings.get().streaming.gaps in _jumpGap to eliminate redundant property traversals. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…mer cleanup (Dash-Industry-Forum#4946) The `1` was incorrectly passed as the `fromIndex` parameter to `indexOf()` instead of as the `deleteCount` parameter to `splice()`. This caused two bugs: 1. `indexOf(timer, 1)` skips index 0, so timers at position 0 are never found 2. `splice(index)` without a second argument removes ALL elements from that index onward, instead of removing just the one timer This results in timer references leaking in the array and valid timers being incorrectly removed, causing memory leaks during long content steering sessions. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…try-Forum#4947) The while loop that removes segments prior to the DVR availability start time did not check if the segments array became empty after each splice. When all segments fall before availabilityStartTime, the array is fully emptied and accessing segments[0] throws a TypeError. Add array length checks both in the loop condition and after the loop before accessing segments[0] for the DVR range update. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…ore the last period was played (Dash-Industry-Forum#5029)
* abort retrieve manifest requests when tearing down * Hold a function to clear the retrieveManifest loader on reset/finish * Guard against retrieveManifest callback being missing --------- Co-authored-by: Coel Aspey <68205939+terminal-overflow@users.noreply.github.com>
…fig to prevent future occurences. (Dash-Industry-Forum#5020)
…ions (Dash-Industry-Forum#4983) * Add a setting blacklistExpiryTime to allow baseUrls to be returned to after a failure; refactor ContentSteering TTL to use blacklistController expiry * Change blacklist controller to take enableExpiry flag, only enable it for BaseURL blacklist * Amend comment on blacklistExpiryTime setting * Make BlacklistController pull the ContentSteering ttl direct from the controller so it picks up a 429 response ttl * Fix reading the retry-after header on the content steering 429 response * Explicitly set enableExpiry to false for BlacklistController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: