Skip to content

Commit

Permalink
CMCD update (#3420)
Browse files Browse the repository at this point in the history
* Updated CMCD feature according to new CMCD spec

- changed query key from 'Common-Media-Client-Data' to 'CMCD'
- omitting '=true' in query string for boolean parameters
- enclosing string values in double quotes, except tokens
- sorting CMCD metrics alphabetically by key name
- URL encoding CMCD metrics
- added new metrics: bl, bs, su, tb
- removed former metric: bs, did
- rounding metric values for dl and mtp
- added object type: o
- omitting CMCD version if it is 1
- extended CMCD sample

* Implemented unit test structure for CmcdModel class

* Implemented unit test for CMCD metrics of media request

* Implemented unit test for CMCD metrics for MPD requests

* Implemented unit test for CMCD metrics of init segments and other

* Forced deadline metric to be rounded

* Added playback rate parameter (pr)
Added tests for registered events of CmcdModel

* Report buffer level starved depending on mediatype

* Update index.d.ts and ref client sample

* Send CMCD isStartup depending on the mediatype and set it to true for all first media requests

* CMCD: Add initForMediaType and adjust unit tests

* CMCD: Update index.d.ts

Co-authored-by: dsilhavy <daniel.silhavy@fokus.fraunhofer.de>
  • Loading branch information
FritzHeiden and dsilhavy authored Oct 7, 2020
1 parent 23cf580 commit aa033ca
Show file tree
Hide file tree
Showing 11 changed files with 518 additions and 77 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,6 @@ pip-log.txt
# Mac crap
.DS_Store
build/typings/

# Vim
.vimrc
5 changes: 5 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ declare namespace dashjs {
audio?: boolean;
video?: boolean;
};
},
cmcd?: {
enabled?: boolean,
sid?: string,
cid?: string
}
}
}
Expand Down
53 changes: 40 additions & 13 deletions samples/advanced/cmcd.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<!--<script src="../../dist/dash.all.min.js"></script>-->

<script class="code">
var CMCD_DATA_GENERATED = dashjs.MetricsReporting.events.CMCD_DATA_GENERATED;
function init() {
var video,
player,
Expand All @@ -21,13 +22,14 @@
player.initialize();
version = player.getVersion();

player.on(CMCD_DATA_GENERATED, handleCmcdDataGeneratedEvent);

player.updateSettings({
streaming: {
cmcd: {
enabled: true, /* enable reporting of cmcd parameters */
sid: 'b248658d-1d1a-4039-91d0-8c08ba597da5', /* session id send with each request */
cid: '21cf726cfe3d937b5f974f72bb5bd06a', /* content id send with each request */
did: 'dash.js-v' + version/* device id send with each request */
}
}
});
Expand All @@ -36,6 +38,25 @@
player.attachSource(url);

}

function handleCmcdDataGeneratedEvent(event) {
log("type: " + event.mediaType);
log("file: " + event.url.split("/").pop())
var keys = Object.keys(event.cmcdData);
keys = keys.sort();
for (var key of keys) {
log(key.padEnd(4) + ": " + event.cmcdData[key]);
}
log("");
}

function log(msg) {
msg = msg.length > 200 ? msg.substring(0, 200) + "..." : msg; /* to avoid repeated wrapping with large objects */
var tracePanel = document.getElementById("trace");
tracePanel.innerHTML += msg + "\n";
tracePanel.scrollTop = tracePanel.scrollHeight;
console.log(msg);
}
</script>

<style>
Expand All @@ -44,18 +65,24 @@
height: 360px;
background-color: #666666;
}
textarea {
width: 500px;
height:360px;
font-size: 10px;
}
</style>
</head>
<body>
<div>
<video controls="true">
</video>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
init();
});
</script>
<script src="../highlighter.js"></script>
</body>
<body>
<div>
<video controls="true">
</video>
<textarea id="trace" placeholder="Sent CMCD data will be displayed here"></textarea>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
init();
});
</script>
<script src="../highlighter.js"></script>
</body>
</html>
1 change: 0 additions & 1 deletion samples/dash-if-reference-player/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,6 @@ app.controller('DashController', function ($scope, sources, contributors, dashif

config.streaming.cmcd.sid = $scope.cmcdSessionId ? $scope.cmcdSessionId : null;
config.streaming.cmcd.cid = $scope.cmcdContentId ? $scope.cmcdContentId : null;
config.streaming.cmcd.did = $scope.cmcdDeviceId ? $scope.cmcdDeviceId : null;

$scope.player.updateSettings(config);

Expand Down
2 changes: 0 additions & 2 deletions samples/dash-if-reference-player/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,6 @@
<input type="text" class="form-control" placeholder="mandatory session id" ng-model="cmcdSessionId">
<label class="options-label">Content ID:</label>
<input type="text" class="form-control" placeholder="content id" ng-model="cmcdContentId">
<label class="options-label">Device ID:</label>
<input type="text" class="form-control" placeholder="device id" ng-model="cmcdDeviceId">
</div>
</div>

Expand Down
3 changes: 1 addition & 2 deletions src/core/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,7 @@ function Settings() {
cmcd: {
enabled: false,
sid: null,
cid: null,
did: null
cid: null
}
}
};
Expand Down
6 changes: 6 additions & 0 deletions src/streaming/metrics/MetricsReportingEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class MetricsReportingEvents extends EventsBase {

this.METRICS_INITIALISATION_COMPLETE = 'internal_metricsReportingInitialized';
this.BECAME_REPORTING_PLAYER = 'internal_becameReportingPlayer';

/**
* Triggered when CMCD data was generated for a HTTP request
* @event MetricsReportingEvents#CMCD_DATA_GENERATED
*/
this.CMCD_DATA_GENERATED = 'cmcdDataGenerated';
}
}

Expand Down
Loading

0 comments on commit aa033ca

Please sign in to comment.