Skip to content

Commit

Permalink
DVB Metrics Reporting 'withCredentials' (#3898)
Browse files Browse the repository at this point in the history
* Add way to set withCredentials for DVB Metrics Reporting

* Use constant for request type
  • Loading branch information
mattjuggins authored Mar 21, 2022
1 parent e0048cc commit 0cc7834
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/streaming/MediaPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,7 @@ function MediaPlayer() {
mediaElement: getVideoElement(),
adapter: adapter,
dashMetrics: dashMetrics,
mediaPlayerModel: mediaPlayerModel,
events: Events,
constants: Constants,
metricsConstants: MetricsConstants
Expand Down
1 change: 1 addition & 0 deletions src/streaming/constants/MetricsConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class MetricsConstants {
this.MANIFEST_UPDATE_TRACK_INFO = 'ManifestUpdateRepresentationInfo';
this.PLAY_LIST = 'PlayList';
this.DVB_ERRORS = 'DVBErrors';
this.HTTP_REQUEST_DVB_REPORTING_TYPE = 'DVBReporting';
}

constructor() {
Expand Down
3 changes: 2 additions & 1 deletion src/streaming/metrics/controllers/MetricsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ function MetricsController(config) {

reportingController = ReportingController(context).create({
debug: config.debug,
metricsConstants: config.metricsConstants
metricsConstants: config.metricsConstants,
mediaPlayerModel: config.mediaPlayerModel
});

reportingController.initialize(metricsEntry.Reporting, rangeController);
Expand Down
4 changes: 3 additions & 1 deletion src/streaming/metrics/reporting/ReportingFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ function ReportingFactory(config) {
let instance;
const logger = config.debug ? config.debug.getLogger(instance) : {};
const metricsConstants = config.metricsConstants;
const mediaPlayerModel = config.mediaPlayerModel || {};

function create(entry, rangeController) {
let reporting;

try {
reporting = knownReportingSchemeIdUris[entry.schemeIdUri](context).create({
metricsConstants: metricsConstants
metricsConstants: metricsConstants,
mediaPlayerModel: mediaPlayerModel
});

reporting.initialize(entry, rangeController);
Expand Down
2 changes: 2 additions & 0 deletions src/streaming/metrics/reporting/reporters/DVBReporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function DVBReporting(config) {
let pendingRequests = [];

const metricsConstants = config.metricsConstants;
const mediaPlayerModel = config.mediaPlayerModel;

function setup() {
metricSerialiser = MetricSerialiser(context).getInstance();
Expand All @@ -59,6 +60,7 @@ function DVBReporting(config) {

function doGetRequest(url, successCB, failureCB) {
let req = new XMLHttpRequest();
req.withCredentials = mediaPlayerModel.getXHRWithCredentialsForType(metricsConstants.HTTP_REQUEST_DVB_REPORTING_TYPE);
const oncomplete = function () {
let reqIndex = pendingRequests.indexOf(req);

Expand Down
1 change: 1 addition & 0 deletions src/streaming/vo/metrics/HTTPRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ HTTPRequest.INDEX_SEGMENT_TYPE = 'IndexSegment';
HTTPRequest.MEDIA_SEGMENT_TYPE = 'MediaSegment';
HTTPRequest.BITSTREAM_SWITCHING_SEGMENT_TYPE = 'BitstreamSwitchingSegment';
HTTPRequest.MSS_FRAGMENT_INFO_SEGMENT_TYPE = 'FragmentInfoSegment';
HTTPRequest.DVB_REPORTING_TYPE = 'DVBReporting';
HTTPRequest.LICENSE = 'license';
HTTPRequest.OTHER_TYPE = 'other';

Expand Down
1 change: 1 addition & 0 deletions test/unit/streaming.constants.MetricsConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ describe('MetricsConstants', function () {
expect(MetricsConstants.MANIFEST_UPDATE_TRACK_INFO).to.equal('ManifestUpdateRepresentationInfo');
expect(MetricsConstants.PLAY_LIST).to.equal('PlayList');
expect(MetricsConstants.DVB_ERRORS).to.equal('DVBErrors');
expect(MetricsConstants.HTTP_REQUEST_DVB_REPORTING_TYPE).to.equal('DVBReporting');
});
});

0 comments on commit 0cc7834

Please sign in to comment.