Skip to content

Commit

Permalink
Fix a bug that was adding CMCD parameters multiple times to the reque… (
Browse files Browse the repository at this point in the history
Dash-Industry-Forum#4684)

* Fix a bug that was adding CMCD parameters multiple times to the request URL in case of request retries

* Add correct description of constant
  • Loading branch information
dsilhavy authored Feb 4, 2025
1 parent 7d0d1d0 commit 9cddbe5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/streaming/ManifestUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import Errors from '../core/errors/Errors.js';
import DashConstants from '../dash/constants/DashConstants.js';
import URLUtils from './utils/URLUtils.js';
import LocationSelector from './utils/LocationSelector.js';
import Constants from './constants/Constants.js';
import Utils from '../core/Utils.js';

function ManifestUpdater() {
Expand Down Expand Up @@ -157,7 +158,7 @@ function ManifestUpdater() {

// Remove previous CMCD parameters from URL
if (url) {
url = Utils.removeQueryParameterFromUrl(url, 'CMCD');
url = Utils.removeQueryParameterFromUrl(url, Constants.CMCD_QUERY_KEY);
}

// Check for PatchLocation and Location alternatives
Expand Down
8 changes: 8 additions & 0 deletions src/streaming/constants/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ export default {
*/
TRACK_SELECTION_MODE_HIGHEST_SELECTION_PRIORITY: 'highestSelectionPriority',


/**
* @constant {string} CMCD_QUERY_KEY specifies the key that is used for the CMCD query parameter.
* @memberof Constants#
* @static
*/
CMCD_QUERY_KEY: 'CMCD',

/**
* @constant {string} CMCD_MODE_QUERY specifies to attach CMCD metrics as query parameters.
* @memberof Constants#
Expand Down
2 changes: 2 additions & 0 deletions src/streaming/net/HTTPLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,12 @@ function HTTPLoader(cfg) {
const currentAdaptationSetId = request?.mediaInfo?.id?.toString();
const isIncludedFilters = clientDataReportingController.isServiceLocationIncluded(request.type, currentServiceLocation) &&
clientDataReportingController.isAdaptationsIncluded(currentAdaptationSetId);

if (isIncludedFilters && cmcdModel.isCmcdEnabled()) {
const cmcdParameters = cmcdModel.getCmcdParametersFromManifest();
const cmcdMode = cmcdParameters.mode ? cmcdParameters.mode : settings.get().streaming.cmcd.mode;
if (cmcdMode === Constants.CMCD_MODE_QUERY) {
request.url = Utils.removeQueryParameterFromUrl(request.url, Constants.CMCD_QUERY_KEY);
const additionalQueryParameter = _getAdditionalQueryParameter(request);
request.url = Utils.addAdditionalQueryParameterToUrl(request.url, additionalQueryParameter);
} else if (cmcdMode === Constants.CMCD_MODE_HEADER) {
Expand Down

0 comments on commit 9cddbe5

Please sign in to comment.