Skip to content

Commit

Permalink
Fix linting errors for "no-multi-space" (#4177)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsilhavy committed Apr 24, 2023
1 parent 698b5e7 commit eb91e6b
Show file tree
Hide file tree
Showing 47 changed files with 829 additions and 797 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Expand Up @@ -21,6 +21,7 @@
"no-use-before-define": 0,
"strict": 0,
"no-loop-func": 0,
"no-multi-spaces": "error",
"quotes": [
"error",
"single",
Expand Down
23 changes: 12 additions & 11 deletions src/core/errors/Errors.js
Expand Up @@ -29,12 +29,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
import ErrorsBase from './ErrorsBase';

/**
* Errors declaration
* @class
*/
class Errors extends ErrorsBase {
constructor () {
constructor() {
super();

/**
Expand Down Expand Up @@ -100,53 +101,53 @@ class Errors extends ErrorsBase {
/**
* Error code returned when Protected contents are not supported
*/
this.CAPABILITY_MEDIAKEYS_ERROR_CODE = 24;
this.CAPABILITY_MEDIAKEYS_ERROR_CODE = 24;

/**
* Error code returned when loading the manifest failed
*/
this.DOWNLOAD_ERROR_ID_MANIFEST_CODE = 25;
this.DOWNLOAD_ERROR_ID_MANIFEST_CODE = 25;

/**
* Error code returned when loading the sidx failed
*/
this.DOWNLOAD_ERROR_ID_SIDX_CODE = 26;
this.DOWNLOAD_ERROR_ID_SIDX_CODE = 26;

/**
* Error code returned when loading the media content failed
*/
this.DOWNLOAD_ERROR_ID_CONTENT_CODE = 27;
this.DOWNLOAD_ERROR_ID_CONTENT_CODE = 27;

/**
* Error code returned when loading the init segment failed
*/
this.DOWNLOAD_ERROR_ID_INITIALIZATION_CODE = 28;
this.DOWNLOAD_ERROR_ID_INITIALIZATION_CODE = 28;

/**
* Error code returned when loading the XLink content failed
*/
this.DOWNLOAD_ERROR_ID_XLINK_CODE = 29;
this.DOWNLOAD_ERROR_ID_XLINK_CODE = 29;

/**
* Error code returned when parsing the MPD resulted in a logical error
*/
this.MANIFEST_ERROR_ID_PARSE_CODE = 31;
this.MANIFEST_ERROR_ID_PARSE_CODE = 31;

/**
* Error code returned when no stream (period) has been detected in the manifest
*/
this.MANIFEST_ERROR_ID_NOSTREAMS_CODE = 32;
this.MANIFEST_ERROR_ID_NOSTREAMS_CODE = 32;

/**
* Error code returned when something wrong has happened during parsing and appending subtitles (TTML or VTT)
*/
this.TIMED_TEXT_ERROR_ID_PARSE_CODE = 33;
this.TIMED_TEXT_ERROR_ID_PARSE_CODE = 33;

/**
* Error code returned when a 'muxed' media type has been detected in the manifest. This type is not supported
*/

this.MANIFEST_ERROR_ID_MULTIPLEXED_CODE = 34;
this.MANIFEST_ERROR_ID_MULTIPLEXED_CODE = 34;

/**
* Error code returned when a media source type is not supported
Expand Down
16 changes: 8 additions & 8 deletions src/dash/parser/DashParser.js
Expand Up @@ -58,18 +58,18 @@ function DashParser(config) {
new DateTimeMatcher(),
new NumericMatcher(),
new LangMatcher(),
new StringMatcher() // last in list to take precedence over NumericMatcher
new StringMatcher()// last in list to take precedence over NumericMatcher
];

converter = new X2JS({
escapeMode: false,
attributePrefix: '',
arrayAccessForm: 'property',
emptyNodeForm: 'object',
stripWhitespaces: false,
escapeMode: false,
attributePrefix: '',
arrayAccessForm: 'property',
emptyNodeForm: 'object',
stripWhitespaces: false,
enableToStringFunc: true,
ignoreRoot: false,
matchers: matchers
ignoreRoot: false,
matchers: matchers
});

objectIron = ObjectIron(context).create({
Expand Down
5 changes: 2 additions & 3 deletions src/mss/MssFragmentMoofProcessor.js
Expand Up @@ -151,8 +151,7 @@ function MssFragmentMoofProcessor(config) {
}
}
return;
}
else {
} else {
// In case of live streams, update segment timeline according to DVR window
if (manifest.timeShiftBufferDepth && manifest.timeShiftBufferDepth > 0) {
// Get timestamp of the last segment
Expand All @@ -173,7 +172,7 @@ function MssFragmentMoofProcessor(config) {
// logger.debug('Remove segment - t = ' + (segment.t / timescale));
segments.splice(0, 1);
segment = segments[0];
endTime = (segment.t + segment.d) / timescale;
endTime = (segment.t + segment.d) / timescale;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/streaming/XlinkLoader.js
Expand Up @@ -42,7 +42,7 @@ function XlinkLoader(config) {
config = config || {};
const RESOLVE_TO_ZERO = 'urn:mpeg:dash:resolve-to-zero:2013';

const context = this.context;
const context = this.context;
const eventBus = EventBus(context).getInstance();

let urlLoader = URLLoader(context).create({
Expand Down
12 changes: 6 additions & 6 deletions src/streaming/controllers/CatchupController.js
Expand Up @@ -179,10 +179,10 @@ function CatchupController() {
*/
function _onPlaybackProgression() {
if (
playbackController.getIsDynamic() &&
mediaPlayerModel.getCatchupModeEnabled() &&
((mediaPlayerModel.getCatchupPlaybackRates().max > 0) || (mediaPlayerModel.getCatchupPlaybackRates().min < 0)) &&
!playbackController.isPaused() &&
playbackController.getIsDynamic() &&
mediaPlayerModel.getCatchupModeEnabled() &&
((mediaPlayerModel.getCatchupPlaybackRates().max > 0) || (mediaPlayerModel.getCatchupPlaybackRates().min < 0)) &&
!playbackController.isPaused() &&
!playbackController.isSeeking() && _shouldStartCatchUp()
) {
_startPlaybackCatchUp();
Expand Down Expand Up @@ -234,7 +234,7 @@ function CatchupController() {
const minPlaybackRateChange = isSafari ? 0.25 : 0.02 / (0.5 / liveCatchupPlaybackRates.max);

// Obtain newRate and apply to video model. Don't change playbackrate for small variations (don't overload element with playbackrate changes)
if (newRate && Math.abs(currentPlaybackRate - newRate) >= minPlaybackRateChange) { // non-null
if (newRate && Math.abs(currentPlaybackRate - newRate) >= minPlaybackRateChange) { // non-null
logger.debug(`[CatchupController]: Setting playback rate to ${newRate}`);
videoModel.setPlaybackRate(newRate);
}
Expand Down Expand Up @@ -382,7 +382,7 @@ function CatchupController() {
if (bufferLevel < playbackBufferMin) {
// Buffer in danger, slow down
const cpr = Math.abs(liveCatchUpPlaybackRates.min); // Absolute value as negative delta value will be used.
const deltaBuffer = bufferLevel - playbackBufferMin; // -ve value
const deltaBuffer = bufferLevel - playbackBufferMin; // -ve value
const d = deltaBuffer * 5;

// Playback rate must be between (1 - cpr) - (1 + cpr)
Expand Down
4 changes: 2 additions & 2 deletions src/streaming/metrics/utils/DVBErrorsTranslator.js
Expand Up @@ -89,10 +89,10 @@ function DVBErrorsTranslator(config) {
}

function handleHttpMetric(vo) {
if ((vo.responsecode === 0) || // connection failure - unknown
if ((vo.responsecode === 0) || // connection failure - unknown
(vo.responsecode == null) || // Generated on .catch() and when uninitialized
(vo.responsecode >= 400) || // HTTP error status code
(vo.responsecode < 100) || // unknown status codes
(vo.responsecode < 100) || // unknown status codes
(vo.responsecode >= 600)) { // unknown status codes
report({
errorcode: vo.responsecode || DVBErrors.CONNECTION_ERROR,
Expand Down
16 changes: 8 additions & 8 deletions src/streaming/metrics/vo/DVBErrors.js
Expand Up @@ -85,13 +85,13 @@ class DVBErrors {
}

DVBErrors.SSL_CONNECTION_FAILED_PREFIX = 'SSL';
DVBErrors.DNS_RESOLUTION_FAILED = 'C00';
DVBErrors.HOST_UNREACHABLE = 'C01';
DVBErrors.CONNECTION_REFUSED = 'C02';
DVBErrors.CONNECTION_ERROR = 'C03';
DVBErrors.CORRUPT_MEDIA_ISOBMFF = 'M00';
DVBErrors.CORRUPT_MEDIA_OTHER = 'M01';
DVBErrors.BASE_URL_CHANGED = 'F00';
DVBErrors.BECAME_REPORTER = 'S00';
DVBErrors.DNS_RESOLUTION_FAILED = 'C00';
DVBErrors.HOST_UNREACHABLE = 'C01';
DVBErrors.CONNECTION_REFUSED = 'C02';
DVBErrors.CONNECTION_ERROR = 'C03';
DVBErrors.CORRUPT_MEDIA_ISOBMFF = 'M00';
DVBErrors.CORRUPT_MEDIA_OTHER = 'M01';
DVBErrors.BASE_URL_CHANGED = 'F00';
DVBErrors.BECAME_REPORTER = 'S00';

export default DVBErrors;
2 changes: 1 addition & 1 deletion src/streaming/models/ManifestModel.js
Expand Up @@ -47,7 +47,7 @@ function ManifestModel() {
function setValue(value) {
manifest = value;
if (value) {
eventBus.trigger(Events.MANIFEST_LOADED, { data: value });
eventBus.trigger(Events.MANIFEST_LOADED, { data: value });
}
}

Expand Down
25 changes: 20 additions & 5 deletions src/streaming/protection/Protection.js
Expand Up @@ -119,7 +119,7 @@ function Protection() {
protectionKeyController.setConfig({ debug: config.debug, BASE64: config.BASE64, settings: config.settings });
protectionKeyController.initialize();

let protectionModel = _getProtectionModel(config);
let protectionModel = _getProtectionModel(config);

if (!controller && protectionModel) {//TODO add ability to set external controller if still needed at all?
controller = ProtectionController(context).create({
Expand All @@ -131,7 +131,7 @@ function Protection() {
BASE64: config.BASE64,
constants: config.constants,
cmcdModel: config.cmcdModel,
customParametersModel : config.customParametersModel,
customParametersModel: config.customParametersModel,
settings: config.settings
});
config.capabilities.setEncryptedMediaSupported(true);
Expand All @@ -149,13 +149,28 @@ function Protection() {
if ((!videoElement || videoElement.onencrypted !== undefined) &&
(!videoElement || videoElement.mediaKeys !== undefined)) {
logger.info('EME detected on this user agent! (ProtectionModel_21Jan2015)');
return ProtectionModel_21Jan2015(context).create({ debug: debug, eventBus: eventBus, events: config.events });
return ProtectionModel_21Jan2015(context).create({
debug: debug,
eventBus: eventBus,
events: config.events
});
} else if (_getAPI(videoElement, APIS_ProtectionModel_3Feb2014)) {
logger.info('EME detected on this user agent! (ProtectionModel_3Feb2014)');
return ProtectionModel_3Feb2014(context).create({ debug: debug, eventBus: eventBus, events: config.events, api: _getAPI(videoElement, APIS_ProtectionModel_3Feb2014) });
return ProtectionModel_3Feb2014(context).create({
debug: debug,
eventBus: eventBus,
events: config.events,
api: _getAPI(videoElement, APIS_ProtectionModel_3Feb2014)
});
} else if (_getAPI(videoElement, APIS_ProtectionModel_01b)) {
logger.info('EME detected on this user agent! (ProtectionModel_01b)');
return ProtectionModel_01b(context).create({ debug: debug, eventBus: eventBus, errHandler: errHandler, events: config.events, api: _getAPI(videoElement, APIS_ProtectionModel_01b) });
return ProtectionModel_01b(context).create({
debug: debug,
eventBus: eventBus,
errHandler: errHandler,
events: config.events,
api: _getAPI(videoElement, APIS_ProtectionModel_01b)
});
} else {
logger.warn('No supported version of EME detected on this user agent! - Attempts to play encrypted content will fail!');
return null;
Expand Down
7 changes: 4 additions & 3 deletions src/streaming/protection/ProtectionEvents.js
Expand Up @@ -29,16 +29,17 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
import EventsBase from '../../core/events/EventsBase';

/**
* @class
*/
*/
class ProtectionEvents extends EventsBase {
/**
* @description Public facing external events to be used when including protection package.
* All public events will be aggregated into the MediaPlayerEvents Class and can be accessed
* via MediaPlayer.events. public_ is the prefix that we use to move event names to MediaPlayerEvents.
*/
constructor () {
constructor() {
super();

/**
Expand Down Expand Up @@ -164,7 +165,7 @@ class ProtectionEvents extends EventsBase {
* a protection set has completed
* @ignore
*/
this.TEARDOWN_COMPLETE = 'protectionTeardownComplete';
this.TEARDOWN_COMPLETE = 'protectionTeardownComplete';

/**
* Event ID for events delivered when a HTMLMediaElement has been
Expand Down
10 changes: 5 additions & 5 deletions src/streaming/rules/abr/BolaRule.js
Expand Up @@ -34,7 +34,7 @@
import MetricsConstants from '../../constants/MetricsConstants';
import SwitchRequest from '../SwitchRequest';
import FactoryMaker from '../../../core/FactoryMaker';
import { HTTPRequest } from '../../vo/metrics/HTTPRequest';
import {HTTPRequest} from '../../vo/metrics/HTTPRequest';
import EventBus from '../../../core/EventBus';
import Events from '../../../core/events/Events';
import Debug from '../../../core/Debug';
Expand All @@ -45,9 +45,9 @@ import Constants from '../../constants/Constants';
// BOLA_STATE_STARTUP : Set placeholder buffer such that we download fragments at most recently measured throughput.
// BOLA_STATE_STEADY : Buffer primed, we switch to steady operation.
// TODO: add BOLA_STATE_SEEK and tune BOLA behavior on seeking
const BOLA_STATE_ONE_BITRATE = 0;
const BOLA_STATE_STARTUP = 1;
const BOLA_STATE_STEADY = 2;
const BOLA_STATE_ONE_BITRATE = 0;
const BOLA_STATE_STARTUP = 1;
const BOLA_STATE_STEADY = 2;

const MINIMUM_BUFFER_S = 10; // BOLA should never add artificial delays if buffer is less than MINIMUM_BUFFER_S.
const MINIMUM_BUFFER_PER_BITRATE_LEVEL_S = 2;
Expand Down Expand Up @@ -107,7 +107,7 @@ function BolaRule(config) {
const Vp = MINIMUM_BUFFER_S / gp;
// note that expressions for gp and Vp assume utilities[0] === 1, which is true because of normalization

return {gp: gp, Vp: Vp};
return { gp: gp, Vp: Vp };
}

function getInitialBolaState(rulesContext) {
Expand Down
2 changes: 1 addition & 1 deletion src/streaming/rules/abr/lolp/LearningAbrController.js
Expand Up @@ -354,7 +354,7 @@ function LearningAbrController() {
}
// Dynamic Weights Selector (step 2/2: find weights)
let weightVector = dynamicWeightsSelector.findWeightVector(somElements, currentLatency, currentBuffer, rebuffer, currentThroughput, playbackRate);
if (weightVector !== null && weightVector !== -1) { // null: something went wrong, -1: constraints not met
if (weightVector !== null && weightVector !== -1) { // null: something went wrong, -1: constraints not met
weights = weightVector;
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/streaming/rules/abr/lolp/LoLpQoEEvaluator.js
Expand Up @@ -83,8 +83,7 @@ function LoLpQoeEvaluator() {
// set some safe value, else consider throwing error
if (!fragmentDuration) {
qoeInfo.weights.bitrateReward = 1;
}
else {
} else {
qoeInfo.weights.bitrateReward = fragmentDuration;
}

Expand All @@ -96,8 +95,7 @@ function LoLpQoeEvaluator() {
// set some safe value, else consider throwing error
if (!maxBitrateKbps) {
qoeInfo.weights.rebufferPenalty = 1000;
}
else {
} else {
qoeInfo.weights.rebufferPenalty = maxBitrateKbps;
}

Expand All @@ -107,7 +105,7 @@ function LoLpQoeEvaluator() {
qoeInfo.weights.latencyPenalty.push({ threshold: 100000000, penalty: (maxBitrateKbps * 0.1) });

// Set weight: playbackSpeedPenalty
if (!minBitrateKbps) qoeInfo.weights.playbackSpeedPenalty = 200; // set some safe value, else consider throwing error
if (!minBitrateKbps) qoeInfo.weights.playbackSpeedPenalty = 200; // set some safe value, else consider throwing error
else qoeInfo.weights.playbackSpeedPenalty = minBitrateKbps;

return qoeInfo;
Expand Down
8 changes: 4 additions & 4 deletions src/streaming/rules/abr/lolp/LoLpRule.js
Expand Up @@ -103,11 +103,11 @@ function LoLPRule(config) {
}

// QoE parameters
let bitrateList = mediaInfo.bitrateList; // [{bandwidth: 200000, width: 640, height: 360}, ...]
let bitrateList = mediaInfo.bitrateList; // [{bandwidth: 200000, width: 640, height: 360}, ...]
let segmentDuration = rulesContext.getRepresentationInfo().fragmentDuration;
let minBitrateKbps = bitrateList[0].bandwidth / 1000.0; // min bitrate level
let maxBitrateKbps = bitrateList[bitrateList.length - 1].bandwidth / 1000.0; // max bitrate level
for (let i = 0; i < bitrateList.length; i++) { // in case bitrateList is not sorted as expected
let minBitrateKbps = bitrateList[0].bandwidth / 1000.0; // min bitrate level
let maxBitrateKbps = bitrateList[bitrateList.length - 1].bandwidth / 1000.0; // max bitrate level
for (let i = 0; i < bitrateList.length; i++) { // in case bitrateList is not sorted as expected
let b = bitrateList[i].bandwidth / 1000.0;
if (b > maxBitrateKbps)
maxBitrateKbps = b;
Expand Down
10 changes: 5 additions & 5 deletions src/streaming/rules/abr/lolp/QoeInfo.js
Expand Up @@ -51,11 +51,11 @@ class QoeInfo {
this.weights.playbackSpeedPenalty = null;

// Weighted Sum for each Qoe factor
this.bitrateWSum = 0; // kbps
this.bitrateSwitchWSum = 0; // kbps
this.rebufferWSum = 0; // seconds
this.latencyWSum = 0; // seconds
this.playbackSpeedWSum = 0; // e.g. 0.95, 1.0, 1.05
this.bitrateWSum = 0;// kbps
this.bitrateSwitchWSum = 0;// kbps
this.rebufferWSum = 0;// seconds
this.latencyWSum = 0;// seconds
this.playbackSpeedWSum = 0;// e.g. 0.95, 1.0, 1.05

// Store total Qoe value based on current Weighted Sum values
this.totalQoe = 0;
Expand Down

0 comments on commit eb91e6b

Please sign in to comment.