Skip to content

Commit

Permalink
Implemented requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FritzHeiden committed Jan 25, 2021
1 parent 66308e7 commit 3ac5873
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/streaming/MediaPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,8 @@ function MediaPlayer() {
eventBus: eventBus,
events: Events,
BASE64: BASE64,
constants: Constants
constants: Constants,
cmcdModel: cmcdModel
});
return protectionController;
}
Expand Down
19 changes: 8 additions & 11 deletions src/streaming/models/CmcdModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,13 @@ function CmcdModel() {
}
data.rtp = rtp;

let nrr = request.range;
let nrr;

if (nextRequest) {
data.nor = nextRequest.url;
if (nextRequest.range) {
nrr = nextRequest.range;
let url = new URL(nextRequest.url);
data.nor = url.pathname;
if (request.url === nextRequest.url && nextRequest.range) {
nrr = nextRequest.nrr;
}
}

Expand Down Expand Up @@ -274,11 +275,6 @@ function CmcdModel() {
data.pr = pr;
}

// Assuming nor field is never set: If the ‘nor’ field is not set, then the object is assumed to match the object currently being requested.
if (request.range) {
data.nrr = request.range;
}

if (_bufferLevelStarved[request.mediaType]) {
data.bs = true;
_bufferLevelStarved[request.mediaType] = false;
Expand Down Expand Up @@ -506,8 +502,9 @@ function CmcdModel() {
function _probeNextRequest(mediaType) {
if (!streamProcessors || streamProcessors.length === 0) return;
for (let streamProcessor of streamProcessors) {
if (streamProcessor.getType() !== mediaType) continue;
return streamProcessor.probeNextRequest();
if (streamProcessor.getType() === mediaType) {
return streamProcessor.probeNextRequest();
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/streaming/protection/Protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ function Protection() {
debug: config.debug,
events: config.events,
BASE64: config.BASE64,
constants: config.constants
constants: config.constants,
cmcdModel: config.cmcdModel
});
config.capabilities.setEncryptedMediaSupported(true);
}
Expand Down
15 changes: 4 additions & 11 deletions src/streaming/protection/controllers/ProtectionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import MediaCapability from '../vo/MediaCapability';
import KeySystemConfiguration from '../vo/KeySystemConfiguration';
import ProtectionErrors from '../errors/ProtectionErrors';
import DashJSError from '../../vo/DashJSError';
import CmcdModel from '../../models/CmcdModel';
import { HTTPRequest } from '../../vo/metrics/HTTPRequest';
import Utils from '../../../core/Utils';

const NEEDKEY_BEFORE_INITIALIZE_RETRIES = 5;
const NEEDKEY_BEFORE_INITIALIZE_TIMEOUT = 500;
Expand Down Expand Up @@ -69,7 +69,7 @@ function ProtectionController(config) {
const BASE64 = config.BASE64;
const constants = config.constants;
let needkeyRetries = [];
const context = this.context;
const cmcdModel = config.cmcdModel;

let instance,
logger,
Expand All @@ -78,16 +78,14 @@ function ProtectionController(config) {
protDataSet,
sessionType,
robustnessLevel,
keySystem,
cmcdModel;
keySystem;

function setup() {
logger = debug.getLogger(instance);
pendingNeedKeyData = [];
mediaInfoArr = [];
sessionType = 'temporary';
robustnessLevel = '';
cmcdModel = CmcdModel(context).getInstance();
}

function checkConfig() {
Expand Down Expand Up @@ -784,12 +782,7 @@ function ProtectionController(config) {
});

if (cmcdParams) {
let queryPrefix = '?';
if (url.indexOf('?') !== -1) {
queryPrefix = '&';
}
const query = queryPrefix + cmcdParams.key + '=' + cmcdParams.value;
url = url + query;
Utils.addAditionalQueryParameterToUrl(url, cmcdParams);
}

xhr.open(method, url, true);
Expand Down

0 comments on commit 3ac5873

Please sign in to comment.