diff --git a/.eslintrc b/.eslintrc index 53972d50a4..16b86609bc 100644 --- a/.eslintrc +++ b/.eslintrc @@ -47,6 +47,11 @@ { "SwitchCase": 1 } - ] + ], + "curly": [ + "error", + "all" + ], + "space-infix-ops": ["error", { "int32Hint": true }] } } diff --git a/package.json b/package.json index 50ff9cf11a..d6555c786f 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "scripts": { "dev": "tsc && webpack --config build/webpack.dev.cjs --mode development --watch --progress", "start": "webpack serve --config build/webpack.dev.cjs", - "lint": "eslint src/**/*.js test/unit/mocks/*.js test/unit/test/**/*.js", + "lint": "eslint \"src/**/*.js\" \"test/unit/mocks/*.js\" \"test/unit/test/**/*.js\"", "build": "tsc && npm run test && npm run lint && npm run webpack-build", "doc": "jsdoc -c build/jsdoc/jsdoc_conf.json -d docs/jsdoc", "test": "karma start test/unit/config/karma.unit.conf.cjs", diff --git a/src/core/EventBus.js b/src/core/EventBus.js index ec734b2501..aa2e20b7e1 100644 --- a/src/core/EventBus.js +++ b/src/core/EventBus.js @@ -49,7 +49,9 @@ function EventBus() { let priority = options.priority || EVENT_PRIORITY_LOW; - if (getHandlerIdx(type, listener, scope) >= 0) return; + if (getHandlerIdx(type, listener, scope) >= 0) { + return; + } handlers[type] = handlers[type] || []; @@ -82,18 +84,26 @@ function EventBus() { } function off(type, listener, scope) { - if (!type || !listener || !handlers[type]) return; + if (!type || !listener || !handlers[type]) { + return; + } const idx = getHandlerIdx(type, listener, scope); - if (idx < 0) return; + if (idx < 0) { + return; + } handlers[type][idx] = null; } function trigger(type, payload = {}, filters = {}) { - if (!type || !handlers[type]) return; + if (!type || !handlers[type]) { + return; + } payload = payload || {}; - if (payload.hasOwnProperty('type')) throw new Error('\'type\' is a reserved word for event dispatching'); + if (payload.hasOwnProperty('type')) { + throw new Error('\'type\' is a reserved word for event dispatching'); + } payload.type = type; @@ -128,7 +138,9 @@ function EventBus() { let idx = -1; - if (!handlers[type]) return idx; + if (!handlers[type]) { + return idx; + } handlers[type].some((item, index) => { if (item && item.callback === listener && (!scope || scope === item.scope)) { diff --git a/src/core/errors/ErrorsBase.js b/src/core/errors/ErrorsBase.js index 824d74d94f..13cd4d0db8 100644 --- a/src/core/errors/ErrorsBase.js +++ b/src/core/errors/ErrorsBase.js @@ -33,20 +33,26 @@ * @ignore */ class ErrorsBase { - extend (errors, config) { - if (!errors) return; + extend(errors, config) { + if (!errors) { + return; + } let override = config ? config.override : false; let publicOnly = config ? config.publicOnly : false; for (const err in errors) { - if (!errors.hasOwnProperty(err) || (this[err] && !override)) continue; - if (publicOnly && errors[err].indexOf('public_') === -1) continue; + if (!errors.hasOwnProperty(err) || (this[err] && !override)) { + continue; + } + if (publicOnly && errors[err].indexOf('public_') === -1) { + continue; + } this[err] = errors[err]; } } } -export default ErrorsBase; \ No newline at end of file +export default ErrorsBase; diff --git a/src/core/events/EventsBase.js b/src/core/events/EventsBase.js index 91a6797870..6c1b9468e2 100644 --- a/src/core/events/EventsBase.js +++ b/src/core/events/EventsBase.js @@ -33,20 +33,26 @@ * @ignore */ class EventsBase { - extend (events, config) { - if (!events) return; + extend(events, config) { + if (!events) { + return; + } let override = config ? config.override : false; let publicOnly = config ? config.publicOnly : false; for (const evt in events) { - if (!events.hasOwnProperty(evt) || (this[evt] && !override)) continue; - if (publicOnly && events[evt].indexOf('public_') === -1) continue; + if (!events.hasOwnProperty(evt) || (this[evt] && !override)) { + continue; + } + if (publicOnly && events[evt].indexOf('public_') === -1) { + continue; + } this[evt] = events[evt]; } } } -export default EventsBase; \ No newline at end of file +export default EventsBase; diff --git a/src/dash/DashAdapter.js b/src/dash/DashAdapter.js index 9696334949..b71b85ecd1 100644 --- a/src/dash/DashAdapter.js +++ b/src/dash/DashAdapter.js @@ -68,7 +68,9 @@ function DashAdapter() { // #region PUBLIC FUNCTIONS // -------------------------------------------------- function setConfig(config) { - if (!config) return; + if (!config) { + return; + } if (config.constants) { constants = config.constants; @@ -100,12 +102,16 @@ function DashAdapter() { } let selectedVoPeriod = getPeriodForStreamInfo(streamInfo, voPeriods); - if (!selectedVoPeriod) return null; + if (!selectedVoPeriod) { + return null; + } const voAdaptations = dashManifestModel.getAdaptationsForPeriod(selectedVoPeriod); let realAdaptation = getMainAdaptationForType(type, streamInfo); - if (!realAdaptation) return null; + if (!realAdaptation) { + return null; + } let idx = dashManifestModel.getIndexForAdaptation(realAdaptation, voPeriods[0].mpd.manifest, streamInfo.index); return convertAdaptationToMediaInfo(voAdaptations[idx]); @@ -137,7 +143,9 @@ function DashAdapter() { const index = streamInfo ? streamInfo.index : 0; const adaptations = dashManifestModel.getAdaptationsForType(voPeriods[index].mpd.manifest, index, type); - if (!adaptations || adaptations.length === 0) return null; + if (!adaptations || adaptations.length === 0) { + return null; + } if (adaptations.length > 1 && streamInfo) { for (let i = 0, ln = adaptations.length; i < ln; i++) { @@ -292,7 +300,9 @@ function DashAdapter() { * @ignore */ function updatePeriods(newManifest) { - if (!newManifest) return null; + if (!newManifest) { + return null; + } checkConfig(); @@ -371,7 +381,9 @@ function DashAdapter() { realAdaptation = id ? dashManifestModel.getAdaptationForId(id, voPeriods[0].mpd.manifest, selectedVoPeriod.index) : dashManifestModel.getAdaptationForIndex(mediaInfo ? mediaInfo.index : null, voPeriods[0].mpd.manifest, selectedVoPeriod.index); } - if (!realAdaptation) return []; + if (!realAdaptation) { + return []; + } return dashManifestModel.getProducerReferenceTimesForAdaptation(realAdaptation); } @@ -934,7 +946,9 @@ function DashAdapter() { const selectedVoPeriod = getPeriodForStreamInfo(mediaInfo.streamInfo, voPeriods); const voAdaptations = dashManifestModel.getAdaptationsForPeriod(selectedVoPeriod); - if (!mediaInfo || !mediaInfo.streamInfo || mediaInfo.streamInfo.id === undefined || !voAdaptations) return null; + if (!mediaInfo || !mediaInfo.streamInfo || mediaInfo.streamInfo.id === undefined || !voAdaptations) { + return null; + } return voAdaptations[mediaInfo.index]; } catch (e) { return null; @@ -947,7 +961,9 @@ function DashAdapter() { for (let i = 0; i < ln; i++) { let voPeriod = voPeriodsArray[i]; - if (streamInfo && streamInfo.id === voPeriod.id) return voPeriod; + if (streamInfo && streamInfo.id === voPeriod.id) { + return voPeriod; + } } return null; @@ -973,8 +989,12 @@ function DashAdapter() { mediaInfo.viewpoint = dashManifestModel.getViewpointForAdaptation(realAdaptation); mediaInfo.accessibility = dashManifestModel.getAccessibilityForAdaptation(realAdaptation); if (mediaInfo.accessibility.filter(function (accessibility) { - if (accessibility.schemeIdUri && (accessibility.schemeIdUri.search('cea-608') >= 0) && typeof (cea608parser) !== 'undefined') return true; - })[0]) mediaInfo.embeddedCaptions = true; + if (accessibility.schemeIdUri && (accessibility.schemeIdUri.search('cea-608') >= 0) && typeof (cea608parser) !== 'undefined') { + return true; + } + })[0]) { + mediaInfo.embeddedCaptions = true; + } mediaInfo.audioChannelConfiguration = dashManifestModel.getAudioChannelConfigurationForAdaptation(realAdaptation); if (mediaInfo.audioChannelConfiguration.length === 0 && realAdaptation.Representation && realAdaptation.Representation.length > 0) { mediaInfo.audioChannelConfiguration = dashManifestModel.getAudioChannelConfigurationForRepresentation(realAdaptation.Representation[0]); diff --git a/src/dash/DashHandler.js b/src/dash/DashHandler.js index 12c094f3a4..7c628dbc51 100644 --- a/src/dash/DashHandler.js +++ b/src/dash/DashHandler.js @@ -126,7 +126,9 @@ function DashHandler(config) { } function getInitRequest(mediaInfo, representation) { - if (!representation) return null; + if (!representation) { + return null; + } return _generateInitRequest(mediaInfo, representation, getType()); } @@ -261,7 +263,9 @@ function DashHandler(config) { indexToRequest, lastSegment ? lastSegment.mediaStartTime : -1 ); - if (!segment) return null; + if (!segment) { + return null; + } request = _getRequestForSegment(mediaInfo, segment); return request; } diff --git a/src/dash/controllers/ContentSteeringController.js b/src/dash/controllers/ContentSteeringController.js index 1270f26e30..2d051b7196 100644 --- a/src/dash/controllers/ContentSteeringController.js +++ b/src/dash/controllers/ContentSteeringController.js @@ -75,7 +75,9 @@ function ContentSteeringController() { } function setConfig(config) { - if (!config) return; + if (!config) { + return; + } if (config.adapter) { adapter = config.adapter; diff --git a/src/dash/controllers/RepresentationController.js b/src/dash/controllers/RepresentationController.js index a5969338f5..5f6308446c 100644 --- a/src/dash/controllers/RepresentationController.js +++ b/src/dash/controllers/RepresentationController.js @@ -168,7 +168,9 @@ function RepresentationController(config) { } function _onSegmentsLoaded(representation, e) { - if (!e || e.error) return; + if (!e || e.error) { + return; + } const fragments = e.segments; const segments = []; diff --git a/src/dash/controllers/ServiceDescriptionController.js b/src/dash/controllers/ServiceDescriptionController.js index 888e20b41d..e7878b2a23 100644 --- a/src/dash/controllers/ServiceDescriptionController.js +++ b/src/dash/controllers/ServiceDescriptionController.js @@ -56,7 +56,9 @@ function ServiceDescriptionController() { } function setConfig(config) { - if (!config) return; + if (!config) { + return; + } if (config.adapter) { adapter = config.adapter; @@ -108,7 +110,9 @@ function ServiceDescriptionController() { let sd = (supportedServiceDescriptions.length > 0) ? supportedServiceDescriptions[supportedServiceDescriptions.length - 1] : allClientsServiceDescriptions[allClientsServiceDescriptions.length - 1]; - if (!sd) return; + if (!sd) { + return; + } if (sd.latency && sd.latency.target > 0) { _applyServiceDescriptionLatency(sd); diff --git a/src/dash/models/DashManifestModel.js b/src/dash/models/DashManifestModel.js index c311d139d9..f811bb5646 100644 --- a/src/dash/models/DashManifestModel.js +++ b/src/dash/models/DashManifestModel.js @@ -235,7 +235,9 @@ function DashManifestModel() { } function getViewpointForAdaptation(adaptation) { - if (!adaptation || !adaptation.hasOwnProperty(DashConstants.VIEWPOINT) || !adaptation[DashConstants.VIEWPOINT].length) return []; + if (!adaptation || !adaptation.hasOwnProperty(DashConstants.VIEWPOINT) || !adaptation[DashConstants.VIEWPOINT].length) { + return []; + } return adaptation[DashConstants.VIEWPOINT].map(viewpoint => { const vp = new DescriptorType(); vp.init(viewpoint); @@ -244,7 +246,9 @@ function DashManifestModel() { } function getRolesForAdaptation(adaptation) { - if (!adaptation || !adaptation.hasOwnProperty(DashConstants.ROLE) || !adaptation[DashConstants.ROLE].length) return []; + if (!adaptation || !adaptation.hasOwnProperty(DashConstants.ROLE) || !adaptation[DashConstants.ROLE].length) { + return []; + } return adaptation[DashConstants.ROLE].map(role => { const r = new DescriptorType(); r.init(role); @@ -253,7 +257,9 @@ function DashManifestModel() { } function getAccessibilityForAdaptation(adaptation) { - if (!adaptation || !adaptation.hasOwnProperty(DashConstants.ACCESSIBILITY) || !adaptation[DashConstants.ACCESSIBILITY].length) return []; + if (!adaptation || !adaptation.hasOwnProperty(DashConstants.ACCESSIBILITY) || !adaptation[DashConstants.ACCESSIBILITY].length) { + return []; + } return adaptation[DashConstants.ACCESSIBILITY].map(accessibility => { const a = new DescriptorType(); a.init(accessibility); @@ -262,7 +268,9 @@ function DashManifestModel() { } function getAudioChannelConfigurationForAdaptation(adaptation) { - if (!adaptation || !adaptation.hasOwnProperty(DashConstants.AUDIO_CHANNEL_CONFIGURATION) || !adaptation[DashConstants.AUDIO_CHANNEL_CONFIGURATION].length) return []; + if (!adaptation || !adaptation.hasOwnProperty(DashConstants.AUDIO_CHANNEL_CONFIGURATION) || !adaptation[DashConstants.AUDIO_CHANNEL_CONFIGURATION].length) { + return []; + } return adaptation[DashConstants.AUDIO_CHANNEL_CONFIGURATION].map(audioChanCfg => { const acc = new DescriptorType(); acc.init(audioChanCfg); @@ -271,7 +279,9 @@ function DashManifestModel() { } function getAudioChannelConfigurationForRepresentation(representation) { - if (!representation || !representation.hasOwnProperty(DashConstants.AUDIO_CHANNEL_CONFIGURATION) || !representation[DashConstants.AUDIO_CHANNEL_CONFIGURATION].length) return []; + if (!representation || !representation.hasOwnProperty(DashConstants.AUDIO_CHANNEL_CONFIGURATION) || !representation[DashConstants.AUDIO_CHANNEL_CONFIGURATION].length) { + return []; + } return representation[DashConstants.AUDIO_CHANNEL_CONFIGURATION].map(audioChanCfg => { const acc = new DescriptorType(); acc.init(audioChanCfg); @@ -568,8 +578,10 @@ function DashManifestModel() { } function getEssentialPropertiesForAdaptation(adaptation) { - if (!adaptation || !adaptation.hasOwnProperty(DashConstants.ESSENTIAL_PROPERTY) || !adaptation.EssentialProperty.length) return []; - return adaptation.EssentialProperty.map( essentialProperty => { + if (!adaptation || !adaptation.hasOwnProperty(DashConstants.ESSENTIAL_PROPERTY) || !adaptation.EssentialProperty.length) { + return []; + } + return adaptation.EssentialProperty.map(essentialProperty => { const s = new DescriptorType(); s.init(essentialProperty); return s @@ -577,7 +589,9 @@ function DashManifestModel() { } function getEssentialPropertiesForRepresentation(realRepresentation) { - if (!realRepresentation || !realRepresentation.EssentialProperty || !realRepresentation.EssentialProperty.length) return []; + if (!realRepresentation || !realRepresentation.EssentialProperty || !realRepresentation.EssentialProperty.length) { + return []; + } return realRepresentation.EssentialProperty.map((essentialProperty) => { const s = new DescriptorType(); @@ -1049,7 +1063,9 @@ function DashManifestModel() { const eventStreams = []; let i; - if (!inbandStreams) return eventStreams; + if (!inbandStreams) { + return eventStreams; + } for (i = 0; i < inbandStreams.length; i++) { const eventStream = new EventStream(); @@ -1260,7 +1276,7 @@ function DashManifestModel() { return entry; } - function _createClientDataReportingInstance(element){ + function _createClientDataReportingInstance(element) { const entry = new ClientDataReporting(); if (element.hasOwnProperty(DashConstants.CMCD_PARAMETERS) && element[DashConstants.CMCD_PARAMETERS].schemeIdUri === Constants.CTA_5004_2023_SCHEME) { @@ -1268,12 +1284,12 @@ function DashManifestModel() { entry.cmcdParameters.init(element[DashConstants.CMCD_PARAMETERS]); } - if (element.hasOwnProperty(DashConstants.SERVICE_LOCATIONS) && element[DashConstants.SERVICE_LOCATIONS] !== ''){ + if (element.hasOwnProperty(DashConstants.SERVICE_LOCATIONS) && element[DashConstants.SERVICE_LOCATIONS] !== '') { entry.serviceLocations = element[DashConstants.SERVICE_LOCATIONS]; entry.serviceLocationsArray = entry.serviceLocations.toString().split(' '); } - if (element.hasOwnProperty(DashConstants.ADAPTATION_SETS) && element[DashConstants.ADAPTATION_SETS] !== ''){ + if (element.hasOwnProperty(DashConstants.ADAPTATION_SETS) && element[DashConstants.ADAPTATION_SETS] !== '') { entry.adaptationSets = element[DashConstants.ADAPTATION_SETS]; entry.adaptationSetsArray = entry.adaptationSets.toString().split(' '); } @@ -1391,7 +1407,9 @@ function DashManifestModel() { } function getSupplementalPropertiesForAdaptation(adaptation) { - if (!adaptation || !adaptation.hasOwnProperty(DashConstants.SUPPLEMENTAL_PROPERTY) || !adaptation.SupplementalProperty.length) return []; + if (!adaptation || !adaptation.hasOwnProperty(DashConstants.SUPPLEMENTAL_PROPERTY) || !adaptation.SupplementalProperty.length) { + return []; + } return adaptation.SupplementalProperty.map(supp => { const s = new DescriptorType(); s.init(supp); @@ -1400,7 +1418,9 @@ function DashManifestModel() { } function getSupplementalPropertiesForRepresentation(representation) { - if (!representation || !representation.hasOwnProperty(DashConstants.SUPPLEMENTAL_PROPERTY) || !representation.SupplementalProperty.length) return []; + if (!representation || !representation.hasOwnProperty(DashConstants.SUPPLEMENTAL_PROPERTY) || !representation.SupplementalProperty.length) { + return []; + } return representation.SupplementalProperty.map(supp => { const s = new DescriptorType(); s.init(supp); @@ -1409,7 +1429,9 @@ function DashManifestModel() { } function setConfig(config) { - if (!config) return; + if (!config) { + return; + } if (config.errHandler) { errHandler = config.errHandler; diff --git a/src/mss/MssFragmentInfoController.js b/src/mss/MssFragmentInfoController.js index 6ebe1039cd..a1121ecc6d 100644 --- a/src/mss/MssFragmentInfoController.js +++ b/src/mss/MssFragmentInfoController.js @@ -66,7 +66,9 @@ function MssFragmentInfoController(config) { } function start() { - if (started) return; + if (started) { + return; + } logger.debug('Start'); @@ -77,7 +79,9 @@ function MssFragmentInfoController(config) { } function stop() { - if (!started) return; + if (!started) { + return; + } logger.debug('Stop'); @@ -92,7 +96,9 @@ function MssFragmentInfoController(config) { } function loadNextFragmentInfo() { - if (!started) return; + if (!started) { + return; + } // Get last segment from SegmentTimeline const representation = getCurrentRepresentation(); @@ -153,8 +159,10 @@ function MssFragmentInfoController(config) { fragmentModel.executeRequest(request); } - function fragmentInfoLoaded (e) { - if (!started) return; + function fragmentInfoLoaded(e) { + if (!started) { + return; + } const request = e.request; if (!e.response) { @@ -208,4 +216,4 @@ function MssFragmentInfoController(config) { } MssFragmentInfoController.__dashjs_factory_name = 'MssFragmentInfoController'; -export default FactoryMaker.getClassFactory(MssFragmentInfoController); +export default FactoryMaker.getClassFactory(MssFragmentInfoController); diff --git a/src/mss/MssFragmentMoofProcessor.js b/src/mss/MssFragmentMoofProcessor.js index 03781d750e..a5c74c0cc5 100644 --- a/src/mss/MssFragmentMoofProcessor.js +++ b/src/mss/MssFragmentMoofProcessor.js @@ -189,7 +189,9 @@ function MssFragmentMoofProcessor(config) { } function updateDVR(type, range, manifestInfo) { - if (type !== 'video' && type !== 'audio') return; + if (type !== 'video' && type !== 'audio') { + return; + } const dvrInfos = dashMetrics.getCurrentDVRInfo(type); if (!dvrInfos || (range.end > dvrInfos.range.end)) { logger.debug('Update DVR range: [' + range.start + ' - ' + range.end + ']'); diff --git a/src/mss/MssHandler.js b/src/mss/MssHandler.js index ed6c028b66..d1e8584f73 100644 --- a/src/mss/MssHandler.js +++ b/src/mss/MssHandler.js @@ -122,7 +122,9 @@ function MssHandler(config) { function onInitFragmentNeeded(e) { let streamProcessor = getStreamProcessor(e.mediaType); - if (!streamProcessor) return; + if (!streamProcessor) { + return; + } // Create init segment request let representationController = streamProcessor.getRepresentationController(); @@ -156,10 +158,14 @@ function MssHandler(config) { } function onSegmentMediaLoaded(e) { - if (e.error) return; + if (e.error) { + return; + } let streamProcessor = getStreamProcessor(e.request.mediaType); - if (!streamProcessor) return; + if (!streamProcessor) { + return; + } // Process moof to transcode it from MSS to DASH (or to update segment timeline for SegmentInfo fragments) mssFragmentProcessor.processFragment(e, streamProcessor); @@ -200,10 +206,10 @@ function MssHandler(config) { } function registerEvents() { - eventBus.on(events.INIT_FRAGMENT_NEEDED, onInitFragmentNeeded, instance, { priority: dashjs.FactoryMaker.getSingletonFactoryByName(eventBus.getClassName()).EVENT_PRIORITY_HIGH }); - eventBus.on(events.PLAYBACK_PAUSED, onPlaybackPaused, instance, { priority: dashjs.FactoryMaker.getSingletonFactoryByName(eventBus.getClassName()).EVENT_PRIORITY_HIGH }); - eventBus.on(events.PLAYBACK_SEEKING, onPlaybackSeeking, instance, { priority: dashjs.FactoryMaker.getSingletonFactoryByName(eventBus.getClassName()).EVENT_PRIORITY_HIGH }); - eventBus.on(events.FRAGMENT_LOADING_COMPLETED, onSegmentMediaLoaded, instance, { priority: dashjs.FactoryMaker.getSingletonFactoryByName(eventBus.getClassName()).EVENT_PRIORITY_HIGH }); + eventBus.on(events.INIT_FRAGMENT_NEEDED, onInitFragmentNeeded, instance, { priority: dashjs.FactoryMaker.getSingletonFactoryByName(eventBus.getClassName()).EVENT_PRIORITY_HIGH }); + eventBus.on(events.PLAYBACK_PAUSED, onPlaybackPaused, instance, { priority: dashjs.FactoryMaker.getSingletonFactoryByName(eventBus.getClassName()).EVENT_PRIORITY_HIGH }); + eventBus.on(events.PLAYBACK_SEEKING, onPlaybackSeeking, instance, { priority: dashjs.FactoryMaker.getSingletonFactoryByName(eventBus.getClassName()).EVENT_PRIORITY_HIGH }); + eventBus.on(events.FRAGMENT_LOADING_COMPLETED, onSegmentMediaLoaded, instance, { priority: dashjs.FactoryMaker.getSingletonFactoryByName(eventBus.getClassName()).EVENT_PRIORITY_HIGH }); eventBus.on(events.TTML_TO_PARSE, onTTMLPreProcess, instance); } @@ -241,7 +247,7 @@ function MssHandler(config) { } MssHandler.__dashjs_factory_name = 'MssHandler'; -const factory = dashjs.FactoryMaker.getClassFactory(MssHandler); +const factory = dashjs.FactoryMaker.getClassFactory(MssHandler); factory.errors = MssErrors; -dashjs.FactoryMaker.updateClassFactory(MssHandler.__dashjs_factory_name, factory); -export default factory; +dashjs.FactoryMaker.updateClassFactory(MssHandler.__dashjs_factory_name, factory); +export default factory; diff --git a/src/mss/parser/MssParser.js b/src/mss/parser/MssParser.js index 66f62905ad..b63922f1f0 100644 --- a/src/mss/parser/MssParser.js +++ b/src/mss/parser/MssParser.js @@ -89,7 +89,9 @@ function MssParser(config) { function getAttributeAsBoolean(node, attrName) { const value = node.getAttribute(attrName); - if (!value) return false; + if (!value) { + return false; + } return value.toLowerCase() === 'true'; } @@ -199,8 +201,12 @@ function MssParser(config) { width = parseInt(qualityLevel.getAttribute('MaxWidth'), 10); height = parseInt(qualityLevel.getAttribute('MaxHeight'), 10); - if (!isNaN(width)) representation.width = width; - if (!isNaN(height)) representation.height = height; + if (!isNaN(width)) { + representation.width = width; + } + if (!isNaN(height)) { + representation.height = height; + } fourCCValue = qualityLevel.getAttribute('FourCC'); @@ -536,8 +542,9 @@ function MssParser(config) { schemeIdUri: 'urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed', value: 'com.widevine.alpha' }; - if (!KID) + if (!KID) { return widevineCP; + } // Create Widevine CENC header (Protocol Buffer) with KID value const wvCencHeader = new Uint8Array(2 + KID.length); wvCencHeader[0] = 0x12; @@ -874,4 +881,4 @@ function MssParser(config) { } MssParser.__dashjs_factory_name = 'MssParser'; -export default FactoryMaker.getClassFactory(MssParser); +export default FactoryMaker.getClassFactory(MssParser); diff --git a/src/streaming/ManifestLoader.js b/src/streaming/ManifestLoader.js index 7c68358b9a..94b69b6876 100644 --- a/src/streaming/ManifestLoader.js +++ b/src/streaming/ManifestLoader.js @@ -134,7 +134,9 @@ function ManifestLoader(config) { request: request, success: function (data, textStatus, responseURL) { // Manage situations in which success is called after calling reset - if (!xlinkController) return; + if (!xlinkController) { + return; + } let actualUrl, baseUri, diff --git a/src/streaming/ManifestUpdater.js b/src/streaming/ManifestUpdater.js index 133f828704..15cbc8d7c0 100644 --- a/src/streaming/ManifestUpdater.js +++ b/src/streaming/ManifestUpdater.js @@ -65,7 +65,9 @@ function ManifestUpdater() { } function setConfig(config) { - if (!config) return; + if (!config) { + return; + } if (config.manifestModel) { manifestModel = config.manifestModel; diff --git a/src/streaming/MediaPlayer.js b/src/streaming/MediaPlayer.js index a96d6c0961..3f29b679ec 100644 --- a/src/streaming/MediaPlayer.js +++ b/src/streaming/MediaPlayer.js @@ -2650,12 +2650,24 @@ function MediaPlayer() { return null; } - if (value.lang) output.lang = value.lang; - if (value.index) output.index = value.index; - if (value.viewpoint) output.viewpoint = __sanitizeDescriptorType('viewpoint', value.viewpoint, defaults.viewpoint); - if (value.audioChannelConfiguration) output.audioChannelConfiguration = __sanitizeDescriptorType('audioChannelConfiguration', value.audioChannelConfiguration, defaults.audioChannelConfiguration); - if (value.role) output.role = __sanitizeDescriptorType('role', value.role, defaults.role); - if (value.accessibility) output.accessibility = __sanitizeDescriptorType('accessibility', value.accessibility, defaults.accessibility); + if (value.lang) { + output.lang = value.lang; + } + if (value.index) { + output.index = value.index; + } + if (value.viewpoint) { + output.viewpoint = __sanitizeDescriptorType('viewpoint', value.viewpoint, defaults.viewpoint); + } + if (value.audioChannelConfiguration) { + output.audioChannelConfiguration = __sanitizeDescriptorType('audioChannelConfiguration', value.audioChannelConfiguration, defaults.audioChannelConfiguration); + } + if (value.role) { + output.role = __sanitizeDescriptorType('role', value.role, defaults.role); + } + if (value.accessibility) { + output.accessibility = __sanitizeDescriptorType('accessibility', value.accessibility, defaults.accessibility); + } return output; } diff --git a/src/streaming/MediaPlayerFactory.js b/src/streaming/MediaPlayerFactory.js index 439adda40f..697cb35b09 100644 --- a/src/streaming/MediaPlayerFactory.js +++ b/src/streaming/MediaPlayerFactory.js @@ -20,9 +20,13 @@ function MediaPlayerFactory() { * @returns {MediaPlayer|null} */ function create(video, source, context) { - if (!video || !(/^VIDEO$/i).test(video.nodeName)) return null; + if (!video || !(/^VIDEO$/i).test(video.nodeName)) { + return null; + } - if (video._dashjs_player) return video._dashjs_player; + if (video._dashjs_player) { + return video._dashjs_player; + } let player; let videoID = (video.id || video.name || 'video element'); diff --git a/src/streaming/Stream.js b/src/streaming/Stream.js index 979f6f3a1a..aa0232e721 100644 --- a/src/streaming/Stream.js +++ b/src/streaming/Stream.js @@ -753,7 +753,9 @@ function Stream(config) { let manifest = manifestModel.getValue(); let processor = getProcessorForMediaInfo(mediaInfo); - if (!processor) return; + if (!processor) { + return; + } let currentTime = playbackController.getTime(); logger.info('Stream - Process track changed at current time ' + currentTime); @@ -918,7 +920,9 @@ function Stream(config) { let trackChangedEvent = trackChangedEvents.pop(); let mediaInfo = trackChangedEvent.newMediaInfo; let processor = getProcessorForMediaInfo(trackChangedEvent.oldMediaInfo); - if (!processor) return; + if (!processor) { + return; + } promises.push(processor.prepareTrackSwitch()); promises.push(processor.selectMediaInfo(mediaInfo)); } diff --git a/src/streaming/StreamProcessor.js b/src/streaming/StreamProcessor.js index 48c102a990..9bba192288 100644 --- a/src/streaming/StreamProcessor.js +++ b/src/streaming/StreamProcessor.js @@ -382,14 +382,18 @@ function StreamProcessor(config) { */ function _onInitFragmentNeeded(e, rescheduleIfNoRequest = true) { // Event propagation may have been stopped (see MssHandler) - if (!e.sender) return; + if (!e.sender) { + return; + } if (playbackController.getIsManifestUpdateInProgress()) { _noValidRequest(); return; } - if (currentMediaInfo.isText && !textController.isTextEnabled()) return; + if (currentMediaInfo.isText && !textController.isTextEnabled()) { + return; + } if (bufferController && e.representationId) { if (!bufferController.appendInitSegmentFromCache(e.representationId)) { diff --git a/src/streaming/controllers/AbrController.js b/src/streaming/controllers/AbrController.js index c15084caaa..0b9ae06af8 100644 --- a/src/streaming/controllers/AbrController.js +++ b/src/streaming/controllers/AbrController.js @@ -181,7 +181,9 @@ function AbrController() { } function setConfig(config) { - if (!config) return; + if (!config) { + return; + } if (config.streamController) { streamController = config.streamController; diff --git a/src/streaming/controllers/BufferController.js b/src/streaming/controllers/BufferController.js index e149b98e34..d924910f6b 100644 --- a/src/streaming/controllers/BufferController.js +++ b/src/streaming/controllers/BufferController.js @@ -372,7 +372,9 @@ function BufferController(config) { } // Check if session has not been stopped in the meantime (while last segment was being appended) - if (!sourceBufferSink) return; + if (!sourceBufferSink) { + return; + } _updateBufferLevel(); @@ -421,7 +423,9 @@ function BufferController(config) { * @private */ function _adjustSeekTarget() { - if (isNaN(seekTarget) || isPrebuffering) return; + if (isNaN(seekTarget) || isPrebuffering) { + return; + } // Check buffered data only for audio and video if (type !== Constants.AUDIO && type !== Constants.VIDEO) { seekTarget = NaN; @@ -440,7 +444,9 @@ function BufferController(config) { // Get buffered range corresponding to the seek target const segmentDuration = representationController.getCurrentRepresentation().segmentDuration; const range = getRangeAt(seekTarget, segmentDuration); - if (!range) return; + if (!range) { + return; + } if (settings.get().streaming.buffer.enableSeekDecorrelationFix && Math.abs(currentTime - seekTarget) > segmentDuration) { // If current video model time is decorrelated from seek target (and appended buffer) then seek video element @@ -843,7 +849,9 @@ function BufferController(config) { function checkIfSufficientBuffer() { // No need to check buffer if type is not audio or video (for example if several errors occur during text parsing, so that the buffer cannot be filled, no error must occur on video playback) - if (type !== Constants.AUDIO && type !== Constants.VIDEO) return; + if (type !== Constants.AUDIO && type !== Constants.VIDEO) { + return; + } // When the player is working in low latency mode, the buffer is often below STALL_THRESHOLD. // So, when in low latency mode, change dash.js behavior so it notifies a stall just when @@ -1120,7 +1128,9 @@ function BufferController(config) { let ln, i; - if (!ranges) return totalBufferedTime; + if (!ranges) { + return totalBufferedTime; + } for (i = 0, ln = ranges.length; i < ln; i++) { totalBufferedTime += ranges.end(i) - ranges.start(i); diff --git a/src/streaming/controllers/ClientDataReportingController.js b/src/streaming/controllers/ClientDataReportingController.js index d9ec240d63..4fa9132efe 100644 --- a/src/streaming/controllers/ClientDataReportingController.js +++ b/src/streaming/controllers/ClientDataReportingController.js @@ -37,8 +37,10 @@ function ClientDataReportingController() { serviceDescriptionController; function setConfig(config) { - if (!config) return; - + if (!config) { + return; + } + if (config.serviceDescriptionController) { serviceDescriptionController = config.serviceDescriptionController; } diff --git a/src/streaming/controllers/EventController.js b/src/streaming/controllers/EventController.js index c22638ea49..837bcabf2e 100644 --- a/src/streaming/controllers/EventController.js +++ b/src/streaming/controllers/EventController.js @@ -192,8 +192,9 @@ function EventController() { try { for (const key in events) { if (events.hasOwnProperty(key)) { - if (Object.keys(events[key]).length === 0) + if (Object.keys(events[key]).length === 0) { delete events[key]; + } } } } catch (e) { diff --git a/src/streaming/controllers/FragmentController.js b/src/streaming/controllers/FragmentController.js index b5911a235d..430a661a7f 100644 --- a/src/streaming/controllers/FragmentController.js +++ b/src/streaming/controllers/FragmentController.js @@ -129,7 +129,9 @@ function FragmentController(config) { function onFragmentLoadingCompleted(e) { // Event propagation may have been stopped (see MssHandler) - if (!e.sender) return; + if (!e.sender) { + return; + } const request = e.request; const bytes = e.response; diff --git a/src/streaming/controllers/MediaController.js b/src/streaming/controllers/MediaController.js index b508c49d6a..dcb53698d2 100644 --- a/src/streaming/controllers/MediaController.js +++ b/src/streaming/controllers/MediaController.js @@ -60,7 +60,9 @@ function MediaController() { } function setConfig(config) { - if (!config) return; + if (!config) { + return; + } if (config.domStorage) { domStorage = config.domStorage; @@ -129,7 +131,9 @@ function MediaController() { setInitialSettings(type, settings); } - if (!possibleTracks || (possibleTracks.length === 0)) return; + if (!possibleTracks || (possibleTracks.length === 0)) { + return; + } if (settings) { filteredTracks = Array.from(possibleTracks); @@ -170,10 +174,14 @@ function MediaController() { * @memberof MediaController# */ function addTrack(track) { - if (!track) return; + if (!track) { + return; + } const mediaType = track.type; - if (!_isMultiTrackSupportedByType(mediaType)) return; + if (!_isMultiTrackSupportedByType(mediaType)) { + return; + } let streamId = track.streamInfo.id; if (!tracks[streamId]) { @@ -198,9 +206,13 @@ function MediaController() { * @memberof MediaController# */ function getTracksFor(type, streamId) { - if (!type) return []; + if (!type) { + return []; + } - if (!tracks[streamId] || !tracks[streamId][type]) return []; + if (!tracks[streamId] || !tracks[streamId][type]) { + return []; + } return tracks[streamId][type].list; } @@ -212,7 +224,9 @@ function MediaController() { * @memberof MediaController# */ function getCurrentTrackFor(type, streamId) { - if (!type || !tracks[streamId] || !tracks[streamId][type]) return null; + if (!type || !tracks[streamId] || !tracks[streamId][type]) { + return null; + } return tracks[streamId][type].current; } @@ -237,14 +251,18 @@ function MediaController() { * @memberof MediaController# */ function setTrack(track, noSettingsSave = false) { - if (!track || !track.streamInfo) return; + if (!track || !track.streamInfo) { + return; + } const type = track.type; const streamInfo = track.streamInfo; const id = streamInfo.id; const current = getCurrentTrackFor(type, id); - if (!tracks[id] || !tracks[id][type]) return; + if (!tracks[id] || !tracks[id][type]) { + return; + } tracks[id][type].current = track; @@ -260,7 +278,9 @@ function MediaController() { let settings = extractSettings(track); - if (!settings || !tracks[id][type].storeLastSettings) return; + if (!settings || !tracks[id][type].storeLastSettings) { + return; + } if (settings.roles) { settings.role = settings.roles[0]; @@ -286,7 +306,9 @@ function MediaController() { * @memberof MediaController# */ function setInitialSettings(type, value) { - if (!type || !value) return; + if (!type || !value) { + return; + } initialSettings[type] = value; } @@ -297,7 +319,9 @@ function MediaController() { * @memberof MediaController# */ function getInitialSettings(type) { - if (!type) return null; + if (!type) { + return null; + } return initialSettings[type]; } @@ -578,7 +602,9 @@ function MediaController() { } function selectInitialTrack(type, mediaInfos) { - if (type === Constants.TEXT) return mediaInfos[0]; + if (type === Constants.TEXT) { + return mediaInfos[0]; + } let tmpArr; const customInitialTrackSelectionFunction = customParametersModel.getCustomInitialTrackSelectionFunction(); diff --git a/src/streaming/controllers/MediaSourceController.js b/src/streaming/controllers/MediaSourceController.js index 44b2e9a369..fbf6a5fa62 100644 --- a/src/streaming/controllers/MediaSourceController.js +++ b/src/streaming/controllers/MediaSourceController.js @@ -95,9 +95,15 @@ function MediaSourceController() { } function setDuration(value) { - if (!mediaSource || mediaSource.readyState !== 'open') return; - if (value === null && isNaN(value)) return; - if (mediaSource.duration === value) return; + if (!mediaSource || mediaSource.readyState !== 'open') { + return; + } + if (value === null && isNaN(value)) { + return; + } + if (mediaSource.duration === value) { + return; + } if (value === Infinity && !settings.get().streaming.buffer.mediaSourceDurationInfinity) { value = Math.pow(2, 32); diff --git a/src/streaming/controllers/PlaybackController.js b/src/streaming/controllers/PlaybackController.js index 462455fd0c..25889a97bb 100644 --- a/src/streaming/controllers/PlaybackController.js +++ b/src/streaming/controllers/PlaybackController.js @@ -206,10 +206,14 @@ function PlaybackController() { * @param {boolean} adjustLiveDelay */ function seek(time, stickToBuffered = false, internal = false, adjustLiveDelay = false) { - if (!streamInfo || !videoModel || !videoModel.getElement()) return; + if (!streamInfo || !videoModel || !videoModel.getElement()) { + return; + } let currentTime = !isNaN(seekTarget) ? seekTarget : videoModel.getTime(); - if (time === currentTime) return; + if (time === currentTime) { + return; + } internalSeek = (internal === true); @@ -468,7 +472,9 @@ function PlaybackController() { } function setConfig(config) { - if (!config) return; + if (!config) { + return; + } if (config.streamController) { streamController = config.streamController; @@ -498,7 +504,9 @@ function PlaybackController() { * @param {object} mediaType */ function updateCurrentTime(mediaType = null) { - if (isPaused() || !isDynamic || videoModel.getReadyState() === 0 || isSeeking() || manifestUpdateInProgress) return; + if (isPaused() || !isDynamic || videoModel.getReadyState() === 0 || isSeeking() || manifestUpdateInProgress) { + return; + } // Note: In some cases we filter certain media types completely (for instance due to an unsupported video codec). This happens after the first entry to the DVR metric has been added. // Now the DVR window for the filtered media type is not updated anymore. Consequently, always use a mediaType that is available to get a valid DVR window. @@ -557,7 +565,9 @@ function PlaybackController() { * Start interval handler for wallclock time update */ function startUpdatingWallclockTime() { - if (wallclockTimeIntervalId !== null) return; + if (wallclockTimeIntervalId !== null) { + return; + } wallclockTimeIntervalId = setInterval(() => { _onWallclockTime(); @@ -576,7 +586,9 @@ function PlaybackController() { const voRepresentation = e.currentRepresentation; const info = voRepresentation ? voRepresentation.mediaInfo.streamInfo : null; - if (info === null || streamInfo.id !== info.id) return; + if (info === null || streamInfo.id !== info.id) { + return; + } streamInfo = info; } @@ -689,7 +701,9 @@ function PlaybackController() { pause(); stopUpdatingWallclockTime(); const streamInfo = streamController ? streamController.getActiveStreamInfo() : null; - if (!streamInfo) return; + if (!streamInfo) { + return; + } eventBus.trigger(Events.PLAYBACK_ENDED, { 'isLast': streamInfo.isLast }); } diff --git a/src/streaming/controllers/StreamController.js b/src/streaming/controllers/StreamController.js index 5fe21a95c2..03a73493d6 100644 --- a/src/streaming/controllers/StreamController.js +++ b/src/streaming/controllers/StreamController.js @@ -460,7 +460,9 @@ function StreamController() { function _onMediaSourceOpen() { // Manage situations in which a call to reset happens while MediaSource is being opened - if (!mediaSource || mediaSource.readyState !== 'open') return; + if (!mediaSource || mediaSource.readyState !== 'open') { + return; + } logger.debug('MediaSource is open!'); window.URL.revokeObjectURL(sourceUrl); @@ -1318,7 +1320,9 @@ function StreamController() { } function _onPlaybackError(e) { - if (!e.error) return; + if (!e.error) { + return; + } let msg; @@ -1411,7 +1415,9 @@ function StreamController() { } function setConfig(config) { - if (!config) return; + if (!config) { + return; + } if (config.capabilities) { capabilities = config.capabilities; diff --git a/src/streaming/controllers/TimeSyncController.js b/src/streaming/controllers/TimeSyncController.js index 2543b071e9..0f4129f83b 100644 --- a/src/streaming/controllers/TimeSyncController.js +++ b/src/streaming/controllers/TimeSyncController.js @@ -76,7 +76,9 @@ function TimeSyncController() { } function setConfig(config) { - if (!config) return; + if (!config) { + return; + } if (config.dashMetrics) { dashMetrics = config.dashMetrics; diff --git a/src/streaming/models/CmcdModel.js b/src/streaming/models/CmcdModel.js index 23ddaadab8..32dc69648b 100644 --- a/src/streaming/models/CmcdModel.js +++ b/src/streaming/models/CmcdModel.js @@ -86,7 +86,9 @@ function CmcdModel() { } function setConfig(config) { - if (!config) return; + if (!config) { + return; + } if (config.abrController) { abrController = config.abrController; @@ -130,12 +132,20 @@ function CmcdModel() { } function _updateStreamProcessors() { - if (!playbackController) return; + if (!playbackController) { + return; + } const streamController = playbackController.getStreamController(); - if (!streamController) return; - if (typeof streamController.getActiveStream !== 'function') return; + if (!streamController) { + return; + } + if (typeof streamController.getActiveStream !== 'function') { + return; + } const activeStream = streamController.getActiveStream(); - if (!activeStream) return; + if (!activeStream) { + return; + } streamProcessors = activeStream.getProcessors(); } @@ -245,7 +255,7 @@ function CmcdModel() { return true; } - function _checkAvailableKeys(cmcdParametersFromManifest){ + function _checkAvailableKeys(cmcdParametersFromManifest) { const defaultAvailableKeys = Constants.CMCD_AVAILABLE_KEYS; const enabledCMCDKeys = cmcdParametersFromManifest.version ? cmcdParametersFromManifest.keys : settings.get().streaming.cmcd.enabledKeys; const invalidKeys = enabledCMCDKeys.filter(k => !defaultAvailableKeys.includes(k)); @@ -327,8 +337,9 @@ function CmcdModel() { function _updateLastMediaTypeRequest(type, mediatype) { // Video > Audio > None if (mediatype === Constants.VIDEO || mediatype === Constants.AUDIO) { - if (!_lastMediaTypeRequest || _lastMediaTypeRequest == Constants.AUDIO) + if (!_lastMediaTypeRequest || _lastMediaTypeRequest == Constants.AUDIO) { _lastMediaTypeRequest = mediatype; + } } } @@ -370,8 +381,12 @@ function CmcdModel() { const nextRequest = _probeNextRequest(mediaType); let ot; - if (mediaType === Constants.VIDEO) ot = CmcdObjectType.VIDEO; - if (mediaType === Constants.AUDIO) ot = CmcdObjectType.AUDIO; + if (mediaType === Constants.VIDEO) { + ot = CmcdObjectType.VIDEO; + } + if (mediaType === Constants.AUDIO) { + ot = CmcdObjectType.AUDIO; + } if (mediaType === Constants.TEXT) { if (request.representation.mediaInfo.mimeType === 'application/mp4') { ot = CmcdObjectType.TIMED_TEXT; @@ -625,7 +640,9 @@ function CmcdModel() { } function _probeNextRequest(mediaType) { - if (!streamProcessors || streamProcessors.length === 0) return; + if (!streamProcessors || streamProcessors.length === 0) { + return; + } for (let streamProcessor of streamProcessors) { if (streamProcessor.getType() === mediaType) { return streamProcessor.probeNextRequest(); @@ -637,7 +654,9 @@ function CmcdModel() { try { // Get the values we need let playbackRate = playbackController.getPlaybackRate(); - if (!playbackRate) playbackRate = 1; + if (!playbackRate) { + playbackRate = 1; + } let { bandwidth, mediaType, representation, duration } = request; const mediaInfo = representation.mediaInfo @@ -645,7 +664,9 @@ function CmcdModel() { return NaN; } let currentBufferLevel = _getBufferLevelByType(mediaType); - if (currentBufferLevel === 0) currentBufferLevel = 500; + if (currentBufferLevel === 0) { + currentBufferLevel = 500; + } // Calculate RTP let segmentSize = (bandwidth * duration) / 1000; // Calculate file size in kilobits diff --git a/src/streaming/models/CustomParametersModel.js b/src/streaming/models/CustomParametersModel.js index 13ad18c18d..6115ab818c 100644 --- a/src/streaming/models/CustomParametersModel.js +++ b/src/streaming/models/CustomParametersModel.js @@ -194,7 +194,9 @@ function CustomParametersModel() { return true; } }); - if (index < 0) return; + if (index < 0) { + return; + } filters.splice(index, 1); } @@ -299,7 +301,7 @@ function CustomParametersModel() { /** * Unregisters a request interceptor. * @param {function} interceptor - the request interceptor callback - */ + */ function removeRequestInterceptor(interceptor) { _unregisterFilter(requestInterceptors, interceptor); } @@ -307,7 +309,7 @@ function CustomParametersModel() { /** * Unregisters a response interceptor. * @param {function} interceptor - the request interceptor callback - */ + */ function removeResponseInterceptor(interceptor) { _unregisterFilter(responseInterceptors, interceptor); } diff --git a/src/streaming/models/FragmentModel.js b/src/streaming/models/FragmentModel.js index efdc1b728b..ab18f9cc45 100644 --- a/src/streaming/models/FragmentModel.js +++ b/src/streaming/models/FragmentModel.js @@ -242,8 +242,12 @@ function FragmentModel(config) { return arr.filter(request => { for (const prop in filter) { - if (prop === 'state') continue; - if (filter.hasOwnProperty(prop) && request[prop] != filter[prop]) return false; + if (prop === 'state') { + continue; + } + if (filter.hasOwnProperty(prop) && request[prop] != filter[prop]) { + return false; + } } return true; @@ -271,7 +275,9 @@ function FragmentModel(config) { } function onLoadingCompleted(e) { - if (e.sender !== fragmentLoader) return; + if (e.sender !== fragmentLoader) { + return; + } loadingRequests.splice(loadingRequests.indexOf(e.request), 1); @@ -293,7 +299,9 @@ function FragmentModel(config) { } function onLoadingInProgress(e) { - if (e.sender !== fragmentLoader) return; + if (e.sender !== fragmentLoader) { + return; + } eventBus.trigger(events.FRAGMENT_LOADING_PROGRESS, { @@ -307,7 +315,9 @@ function FragmentModel(config) { } function onLoadingAborted(e) { - if (e.sender !== fragmentLoader) return; + if (e.sender !== fragmentLoader) { + return; + } eventBus.trigger(events.FRAGMENT_LOADING_ABANDONED, { request: e.request }, diff --git a/src/streaming/models/MediaPlayerModel.js b/src/streaming/models/MediaPlayerModel.js index 9d6f828a43..f8d71de1c0 100644 --- a/src/streaming/models/MediaPlayerModel.js +++ b/src/streaming/models/MediaPlayerModel.js @@ -78,7 +78,9 @@ function MediaPlayerModel() { * @returns {number} corrected min playback rate */ function _checkMinPlaybackRate(rate, log) { - if (isNaN(rate)) return 0; + if (isNaN(rate)) { + return 0; + } if (rate > 0) { if (log) { logger.warn(`Supplied minimum playback rate is a positive value when it should be negative or 0. The supplied rate will not be applied and set to 0: 100% playback speed.`) @@ -101,7 +103,9 @@ function MediaPlayerModel() { * @returns {number} corrected max playback rate */ function _checkMaxPlaybackRate(rate, log) { - if (isNaN(rate)) return 0; + if (isNaN(rate)) { + return 0; + } if (rate < 0) { if (log) { logger.warn(`Supplied maximum playback rate is a negative value when it should be negative or 0. The supplied rate will not be applied and set to 0: 100% playback speed.`) diff --git a/src/streaming/models/URIFragmentModel.js b/src/streaming/models/URIFragmentModel.js index d6676f46e3..12885e3c8f 100644 --- a/src/streaming/models/URIFragmentModel.js +++ b/src/streaming/models/URIFragmentModel.js @@ -49,7 +49,9 @@ function URIFragmentModel() { function initialize(uri) { URIFragmentDataVO = new URIFragmentData(); - if (!uri) return null; + if (!uri) { + return null; + } const hashIndex = uri.indexOf('#'); if (hashIndex !== -1) { @@ -58,7 +60,7 @@ function URIFragmentModel() { const fragment = fragments[i]; const equalIndex = fragment.indexOf('='); if (equalIndex !== -1) { - const key = fragment.substring(0,equalIndex); + const key = fragment.substring(0, equalIndex); if (URIFragmentDataVO.hasOwnProperty(key)) { URIFragmentDataVO[key] = fragment.substr(equalIndex + 1); } diff --git a/src/streaming/models/VideoModel.js b/src/streaming/models/VideoModel.js index 772b8c47b3..0fbc080c95 100644 --- a/src/streaming/models/VideoModel.js +++ b/src/streaming/models/VideoModel.js @@ -85,7 +85,9 @@ function VideoModel() { } function setPlaybackRate(value, ignoreReadyState = false) { - if (!element) return; + if (!element) { + return; + } if (!ignoreReadyState && element.readyState <= 2 && value > 0) { // If media element hasn't loaded enough data to play yet, wait until it has element.addEventListener('canplay', onPlaybackCanPlay); diff --git a/src/streaming/net/HTTPLoader.js b/src/streaming/net/HTTPLoader.js index ff7685b5c3..daaf54f883 100644 --- a/src/streaming/net/HTTPLoader.js +++ b/src/streaming/net/HTTPLoader.js @@ -445,7 +445,9 @@ function HTTPLoader(cfg) { function _applyRequestInterceptors(httpRequest) { const interceptors = customParametersModel.getRequestInterceptors(); - if (!interceptors) return Promise.resolve(httpRequest); + if (!interceptors) { + return Promise.resolve(httpRequest); + } return interceptors.reduce((prev, next) => { return prev.then((request) => { @@ -456,7 +458,9 @@ function HTTPLoader(cfg) { function _applyResponseInterceptors(response) { const interceptors = customParametersModel.getResponseInterceptors(); - if (!interceptors) return Promise.resolve(response); + if (!interceptors) { + return Promise.resolve(response); + } return interceptors.reduce((prev, next) => { return prev.then(resp => { diff --git a/src/streaming/protection/CommonEncryption.js b/src/streaming/protection/CommonEncryption.js index 6606d08b1d..3668c6d5d8 100644 --- a/src/streaming/protection/CommonEncryption.js +++ b/src/streaming/protection/CommonEncryption.js @@ -52,8 +52,9 @@ class CommonEncryption { for (let i = 0; i < cpArray.length; ++i) { let cp = cpArray[i]; if (cp.schemeIdUri && cp.schemeIdUri.toLowerCase() === DashConstants.MP4_PROTECTION_SCHEME && cp.value && - (cp.value.toLowerCase() === 'cenc' || cp.value.toLowerCase() === 'cbcs')) + (cp.value.toLowerCase() === 'cenc' || cp.value.toLowerCase() === 'cbcs')) { retVal = cp; + } } return retVal; } @@ -129,8 +130,9 @@ class CommonEncryption { */ static parsePSSHList(data) { - if (data === null || data === undefined) + if (data === null || data === undefined) { return []; + } let dv = new DataView(data.buffer || data); // data.buffer first for Uint8Array support let done = false; @@ -146,8 +148,9 @@ class CommonEncryption { systemID; let boxStart = byteCursor; - if (byteCursor >= dv.buffer.byteLength) + if (byteCursor >= dv.buffer.byteLength) { break; + } /* Box size */ size = dv.getUint32(byteCursor); diff --git a/src/streaming/protection/controllers/ProtectionController.js b/src/streaming/protection/controllers/ProtectionController.js index 89f38fc7a7..8c2213e9b3 100644 --- a/src/streaming/protection/controllers/ProtectionController.js +++ b/src/streaming/protection/controllers/ProtectionController.js @@ -1028,7 +1028,9 @@ function ProtectionController(config) { * @private */ function _applyFilters(filters, param) { - if (!filters) return Promise.resolve(); + if (!filters) { + return Promise.resolve(); + } return filters.reduce((prev, next) => { return prev.then(() => { return next(param); @@ -1136,4 +1138,4 @@ function ProtectionController(config) { } ProtectionController.__dashjs_factory_name = 'ProtectionController'; -export default FactoryMaker.getClassFactory(ProtectionController); +export default FactoryMaker.getClassFactory(ProtectionController); diff --git a/src/streaming/protection/controllers/ProtectionKeyController.js b/src/streaming/protection/controllers/ProtectionKeyController.js index 0423a33bec..5c9309faf0 100644 --- a/src/streaming/protection/controllers/ProtectionKeyController.js +++ b/src/streaming/protection/controllers/ProtectionKeyController.js @@ -59,7 +59,9 @@ function ProtectionKeyController() { clearkeyW3CKeySystem; function setConfig(config) { - if (!config) return; + if (!config) { + return; + } if (config.debug) { debug = config.debug; @@ -401,4 +403,4 @@ function ProtectionKeyController() { } ProtectionKeyController.__dashjs_factory_name = 'ProtectionKeyController'; -export default FactoryMaker.getSingletonFactory(ProtectionKeyController); +export default FactoryMaker.getSingletonFactory(ProtectionKeyController); diff --git a/src/streaming/protection/drm/KeySystemPlayReady.js b/src/streaming/protection/drm/KeySystemPlayReady.js index 8b6111fc73..621ff8aa8e 100644 --- a/src/streaming/protection/drm/KeySystemPlayReady.js +++ b/src/streaming/protection/drm/KeySystemPlayReady.js @@ -53,7 +53,7 @@ function KeySystemPlayReady(config) { const settings = config.settings; function checkConfig() { - if (!BASE64 || !BASE64.hasOwnProperty('decodeArray') || !BASE64.hasOwnProperty('decodeArray') ) { + if (!BASE64 || !BASE64.hasOwnProperty('decodeArray') || !BASE64.hasOwnProperty('decodeArray')) { throw new Error('Missing config parameter(s)'); } } @@ -204,11 +204,9 @@ function KeySystemPlayReady(config) { // Handle native MS PlayReady ContentProtection elements if ('pro' in cpData && cpData.pro) { uint8arraydecodedPROHeader = BASE64.decodeArray(cpData.pro.__text); - } - else if ('prheader' in cpData && cpData.prheader) { + } else if ('prheader' in cpData && cpData.prheader) { uint8arraydecodedPROHeader = BASE64.decodeArray(cpData.prheader.__text); - } - else { + } else { return null; } @@ -263,7 +261,9 @@ function KeySystemPlayReady(config) { i; checkConfig(); - if (!_cdmData) return null; + if (!_cdmData) { + return null; + } // Convert custom data into multibyte string customData = []; @@ -306,4 +306,4 @@ function KeySystemPlayReady(config) { } KeySystemPlayReady.__dashjs_factory_name = 'KeySystemPlayReady'; -export default FactoryMaker.getSingletonFactory(KeySystemPlayReady); +export default FactoryMaker.getSingletonFactory(KeySystemPlayReady); diff --git a/src/streaming/protection/models/ProtectionModel_21Jan2015.js b/src/streaming/protection/models/ProtectionModel_21Jan2015.js index 6313b634de..03fe71ddd4 100644 --- a/src/streaming/protection/models/ProtectionModel_21Jan2015.js +++ b/src/streaming/protection/models/ProtectionModel_21Jan2015.js @@ -260,8 +260,9 @@ function ProtectionModel_21Jan2015(config) { } function setMediaElement(mediaElement) { - if (videoElement === mediaElement) + if (videoElement === mediaElement) { return; + } // Replacing the previous element if (videoElement) { @@ -579,4 +580,4 @@ function ProtectionModel_21Jan2015(config) { } ProtectionModel_21Jan2015.__dashjs_factory_name = 'ProtectionModel_21Jan2015'; -export default FactoryMaker.getClassFactory(ProtectionModel_21Jan2015); +export default FactoryMaker.getClassFactory(ProtectionModel_21Jan2015); diff --git a/src/streaming/protection/models/ProtectionModel_3Feb2014.js b/src/streaming/protection/models/ProtectionModel_3Feb2014.js index dea11cd358..f037cefe06 100644 --- a/src/streaming/protection/models/ProtectionModel_3Feb2014.js +++ b/src/streaming/protection/models/ProtectionModel_3Feb2014.js @@ -183,8 +183,9 @@ function ProtectionModel_3Feb2014(config) { } function setMediaElement(mediaElement) { - if (videoElement === mediaElement) + if (videoElement === mediaElement) { return; + } // Replacing the previous element if (videoElement) { @@ -401,4 +402,4 @@ function ProtectionModel_3Feb2014(config) { } ProtectionModel_3Feb2014.__dashjs_factory_name = 'ProtectionModel_3Feb2014'; -export default FactoryMaker.getClassFactory(ProtectionModel_3Feb2014); +export default FactoryMaker.getClassFactory(ProtectionModel_3Feb2014); diff --git a/src/streaming/protection/vo/ClearKeyKeySet.js b/src/streaming/protection/vo/ClearKeyKeySet.js index a424d4a423..12aab60bfb 100644 --- a/src/streaming/protection/vo/ClearKeyKeySet.js +++ b/src/streaming/protection/vo/ClearKeyKeySet.js @@ -43,8 +43,9 @@ class ClearKeyKeySet { * @ignore */ constructor(keyPairs, type) { - if (type && type !== 'persistent' && type !== 'temporary') + if (type && type !== 'persistent' && type !== 'temporary') { throw new Error('Invalid ClearKey key set type! Must be one of \'persistent\' or \'temporary\''); + } this.keyPairs = keyPairs; this.type = type; } @@ -57,7 +58,7 @@ class ClearKeyKeySet { toJWK() { let i; let numKeys = this.keyPairs.length; - let jwk = {keys: []}; + let jwk = { keys: [] }; for (i = 0; i < numKeys; i++) { let key = { @@ -77,8 +78,9 @@ class ClearKeyKeySet { // Convert JSON string to ArrayBuffer let buf = new ArrayBuffer(len); let bView = new Uint8Array(buf); - for (i = 0; i < len; i++) + for (i = 0; i < len; i++) { bView[i] = jwkString.charCodeAt(i); + } return buf; } } diff --git a/src/streaming/rules/abr/lolp/LearningAbrController.js b/src/streaming/rules/abr/lolp/LearningAbrController.js index d5d42dd2c7..67b1d98408 100644 --- a/src/streaming/rules/abr/lolp/LearningAbrController.js +++ b/src/streaming/rules/abr/lolp/LearningAbrController.js @@ -470,7 +470,9 @@ function LearningAbrController() { for (let i = 0; i < centers.length; i++) { let distance = 0; for (let j = 0; j < centers.length; j++) { - if (i === j) continue; + if (i === j) { + continue; + } distance += _getDistance(centers[i], centers[j], distanceWeights); } if (maxDistance === null || distance > maxDistance) { diff --git a/src/streaming/rules/abr/lolp/LoLpQoEEvaluator.js b/src/streaming/rules/abr/lolp/LoLpQoEEvaluator.js index 6e8bd1c078..08b0da7723 100644 --- a/src/streaming/rules/abr/lolp/LoLpQoEEvaluator.js +++ b/src/streaming/rules/abr/lolp/LoLpQoEEvaluator.js @@ -105,8 +105,12 @@ 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 - else qoeInfo.weights.playbackSpeedPenalty = minBitrateKbps; + if (!minBitrateKbps) { + qoeInfo.weights.playbackSpeedPenalty = 200; + } // set some safe value, else consider throwing error + else { + qoeInfo.weights.playbackSpeedPenalty = minBitrateKbps; + } return qoeInfo; } diff --git a/src/streaming/text/NotFragmentedTextBufferController.js b/src/streaming/text/NotFragmentedTextBufferController.js index 30fdfe92bf..9aa360ae80 100644 --- a/src/streaming/text/NotFragmentedTextBufferController.js +++ b/src/streaming/text/NotFragmentedTextBufferController.js @@ -157,7 +157,9 @@ function NotFragmentedTextBufferController(config) { } function _onInitFragmentLoaded(e) { - if (!e.chunk.bytes || isBufferingCompleted) return; + if (!e.chunk.bytes || isBufferingCompleted) { + return; + } initCache.save(e.chunk); diff --git a/src/streaming/text/TextTracks.js b/src/streaming/text/TextTracks.js index 28200c44fc..7befd10ce9 100644 --- a/src/streaming/text/TextTracks.js +++ b/src/streaming/text/TextTracks.js @@ -872,7 +872,9 @@ function TextTracks(config) { } function cueInTrack(track, cue) { - if (!track.cues) return false; + if (!track.cues) { + return false; + } for (let i = 0; i < track.cues.length; i++) { if ((track.cues[i].startTime === cue.startTime) && (track.cues[i].endTime === cue.endTime)) { diff --git a/src/streaming/thumbnail/ThumbnailTracks.js b/src/streaming/thumbnail/ThumbnailTracks.js index 1848d4b8ed..ca41d51fef 100644 --- a/src/streaming/thumbnail/ThumbnailTracks.js +++ b/src/streaming/thumbnail/ThumbnailTracks.js @@ -208,8 +208,9 @@ function ThumbnailTracks(config) { end: ss.mediaStartTime + ss.duration, url: imageUrl }); - if (callback) + if (callback) { callback(imageUrl); + } } }); return true; diff --git a/src/streaming/utils/BoxParser.js b/src/streaming/utils/BoxParser.js index 5312ca7c87..73138aa091 100644 --- a/src/streaming/utils/BoxParser.js +++ b/src/streaming/utils/BoxParser.js @@ -52,7 +52,9 @@ function BoxParser(/*config*/) { * @memberof BoxParser# */ function parse(data) { - if (!data) return null; + if (!data) { + return null; + } if (data.fileStart === undefined) { data.fileStart = 0; @@ -116,7 +118,7 @@ function BoxParser(/*config*/) { function getSamplesInfo(ab) { if (!ab || ab.byteLength === 0) { - return {sampleList: [], lastSequenceNumber: NaN, totalDuration: NaN, numSequences: NaN}; + return { sampleList: [], lastSequenceNumber: NaN, totalDuration: NaN, numSequences: NaN }; } let isoFile = parse(ab); // zero or more moofs @@ -201,7 +203,12 @@ function BoxParser(/*config*/) { totalDuration = sampleDts - tfdtBox.baseMediaDecodeTime; } } - return {sampleList: sampleList, lastSequenceNumber: lastSequenceNumber, totalDuration: totalDuration, numSequences: numSequences}; + return { + sampleList: sampleList, + lastSequenceNumber: lastSequenceNumber, + totalDuration: totalDuration, + numSequences: numSequences + }; } function getMediaTimescaleFromMoov(ab) { @@ -310,5 +317,6 @@ function BoxParser(/*config*/) { return instance; } + BoxParser.__dashjs_factory_name = 'BoxParser'; export default FactoryMaker.getSingletonFactory(BoxParser); diff --git a/src/streaming/utils/CapabilitiesFilter.js b/src/streaming/utils/CapabilitiesFilter.js index 93be9d9fd8..182bf68416 100644 --- a/src/streaming/utils/CapabilitiesFilter.js +++ b/src/streaming/utils/CapabilitiesFilter.js @@ -364,16 +364,18 @@ function CapabilitiesFilter() { Promise.all(promises) .then((supported) => { as.Representation = as.Representation.filter((rep, i) => { - let isReprSupported = supported[i].every( (s)=>{return s}); + let isReprSupported = supported[i].every((s) => { + return s + }); if (!isReprSupported) { - logger.debug('[Stream] Representation '+rep.id+' has been removed because of unsupported CustomFilter'); + logger.debug('[Stream] Representation ' + rep.id + ' has been removed because of unsupported CustomFilter'); } return isReprSupported; }); resolve(); }) .catch((err) => { - logger.warn('[Stream] at least one promise rejected in CustomFilter with error: ',err); + logger.warn('[Stream] at least one promise rejected in CustomFilter with error: ', err); resolve(); }); }); diff --git a/src/streaming/utils/CustomTimeRanges.js b/src/streaming/utils/CustomTimeRanges.js index dd1c3b340f..11f4ed3862 100644 --- a/src/streaming/utils/CustomTimeRanges.js +++ b/src/streaming/utils/CustomTimeRanges.js @@ -38,6 +38,7 @@ function CustomTimeRanges(/*config*/) { function add(start, end) { let i; + // eslint-disable-next-line curly for (i = 0; (i < this.customTimeRangeArray.length) && (start > this.customTimeRangeArray[i].start); i++) ; this.customTimeRangeArray.splice(i, 0, { start: start, end: end }); diff --git a/src/streaming/utils/DOMStorage.js b/src/streaming/utils/DOMStorage.js index 78ca6831df..0f563fe144 100644 --- a/src/streaming/utils/DOMStorage.js +++ b/src/streaming/utils/DOMStorage.js @@ -64,7 +64,9 @@ function DOMStorage(config) { //type can be local, session function isSupported(type) { - if (supported !== undefined) return supported; + if (supported !== undefined) { + return supported; + } supported = false; diff --git a/src/streaming/utils/IsoFile.js b/src/streaming/utils/IsoFile.js index 78b135f225..09f611d6d4 100644 --- a/src/streaming/utils/IsoFile.js +++ b/src/streaming/utils/IsoFile.js @@ -38,21 +38,23 @@ function IsoFile() { parsedIsoFile; /** - * @param {string} type - * @returns {IsoBox|null} - * @memberof IsoFile# - */ + * @param {string} type + * @returns {IsoBox|null} + * @memberof IsoFile# + */ function getBox(type) { - if (!type || !parsedIsoFile || !parsedIsoFile.boxes || (parsedIsoFile.boxes.length === 0) || typeof parsedIsoFile.fetch !== 'function') return null; + if (!type || !parsedIsoFile || !parsedIsoFile.boxes || (parsedIsoFile.boxes.length === 0) || typeof parsedIsoFile.fetch !== 'function') { + return null; + } return convertToDashIsoBox(parsedIsoFile.fetch(type)); } /** - * @param {string} type - * @returns {Array|null} array of {@link IsoBox} - * @memberof IsoFile# - */ + * @param {string} type + * @returns {Array|null} array of {@link IsoBox} + * @memberof IsoFile# + */ function getBoxes(type) { let boxes = []; @@ -75,19 +77,21 @@ function IsoFile() { } /** - * @param {string} value - * @memberof IsoFile# - */ + * @param {string} value + * @memberof IsoFile# + */ function setData(value) { parsedIsoFile = value; } /** - * @returns {IsoBox|null} - * @memberof IsoFile# - */ + * @returns {IsoBox|null} + * @memberof IsoFile# + */ function getLastBox() { - if (!parsedIsoFile || !parsedIsoFile.boxes || !parsedIsoFile.boxes.length) return null; + if (!parsedIsoFile || !parsedIsoFile.boxes || !parsedIsoFile.boxes.length) { + return null; + } let type = parsedIsoFile.boxes[parsedIsoFile.boxes.length - 1].type; let boxes = getBoxes(type); @@ -96,7 +100,9 @@ function IsoFile() { } function convertToDashIsoBox(boxData) { - if (!boxData) return null; + if (!boxData) { + return null; + } let box = new IsoBox(boxData); @@ -116,5 +122,6 @@ function IsoFile() { return instance; } + IsoFile.__dashjs_factory_name = 'IsoFile'; export default FactoryMaker.getClassFactory(IsoFile); diff --git a/src/streaming/utils/VTTParser.js b/src/streaming/utils/VTTParser.js index 2c03182677..cc90c64684 100644 --- a/src/streaming/utils/VTTParser.js +++ b/src/streaming/utils/VTTParser.js @@ -60,11 +60,11 @@ function VTTParser() { return captionArray; } - data = data.split( regExNewLine ); + data = data.split(regExNewLine); len = data.length; lastStartTime = -1; - for (let i = 0 ; i < len; i++) { + for (let i = 0; i < len; i++) { let item = data[i]; if (item.length > 0 && item !== WEBVTT) { @@ -86,12 +86,10 @@ function VTTParser() { data: text, styles: styles }); - } - else { + } else { logger.error('Skipping cue due to empty/malformed cue text'); } - } - else { + } else { logger.error('Skipping cue due to incorrect cue timing'); } } @@ -105,10 +103,10 @@ function VTTParser() { const timeArray = time.split(':'); const len = timeArray.length - 1; - time = parseInt( timeArray[len - 1], 10 ) * 60 + parseFloat( timeArray[len]); + time = parseInt(timeArray[len - 1], 10) * 60 + parseFloat(timeArray[len]); - if ( len === 2 ) { - time += parseInt( timeArray[0], 10 ) * 3600; + if (len === 2) { + time += parseInt(timeArray[0], 10) * 3600; } return time; @@ -120,7 +118,7 @@ function VTTParser() { arr.shift(); //remove first array index it is empty... vttCuePoints[1] = arr[0]; arr.shift(); - return {cuePoints: vttCuePoints, styles: getCaptionStyles(arr)}; + return { cuePoints: vttCuePoints, styles: getCaptionStyles(arr) }; } function getCaptionStyles(arr) { @@ -136,13 +134,13 @@ function VTTParser() { if (element.match(/align/) || element.match(/A/)) { styleObject.align = val; } - if (element.match(/line/) || element.match(/L/) ) { + if (element.match(/line/) || element.match(/L/)) { styleObject.line = val === 'auto' ? val : parseInt(val, 10); if (isPercentage) { styleObject.snapToLines = false; } } - if (element.match(/position/) || element.match(/P/) ) { + if (element.match(/position/) || element.match(/P/)) { styleObject.position = val; } if (element.match(/size/) || element.match(/S/)) { @@ -177,8 +175,7 @@ function VTTParser() { if (j !== lineCount - 1) { subline += '\n'; } - } - else { + } else { // caption text should not have '-->' in it subline = ''; break; @@ -186,8 +183,9 @@ function VTTParser() { } } else { lineData = data[idx]; - if (!lineData.match(regExToken)) + if (!lineData.match(regExToken)) { subline = lineData; + } } return subline; } @@ -200,5 +198,6 @@ function VTTParser() { setup(); return instance; } + VTTParser.__dashjs_factory_name = 'VTTParser'; export default FactoryMaker.getSingletonFactory(VTTParser); diff --git a/test/unit/mocks/AdapterMock.js b/test/unit/mocks/AdapterMock.js index b658ab3cdb..eadb27d336 100644 --- a/test/unit/mocks/AdapterMock.js +++ b/test/unit/mocks/AdapterMock.js @@ -162,7 +162,9 @@ function AdapterMock() { }; this.getEssentialPropertiesForRepresentation = function (realRepresentation) { - if (!realRepresentation || !realRepresentation.EssentialProperty || !realRepresentation.EssentialProperty.length) return null; + if (!realRepresentation || !realRepresentation.EssentialProperty || !realRepresentation.EssentialProperty.length) { + return null; + } return realRepresentation.EssentialProperty.map((prop) => { return { diff --git a/test/unit/mocks/MediaControllerMock.js b/test/unit/mocks/MediaControllerMock.js index 846116d4be..ca460bdd3d 100644 --- a/test/unit/mocks/MediaControllerMock.js +++ b/test/unit/mocks/MediaControllerMock.js @@ -45,7 +45,9 @@ class MediaControllerMock { * @memberof MediaController# */ setTrack(track) { - if (!track) return; + if (!track) { + return; + } this.track = track; } @@ -55,7 +57,9 @@ class MediaControllerMock { * @memberof MediaController# */ setInitialSettings(type, value) { - if (!type || !value) return; + if (!type || !value) { + return; + } this.initialSettings[type] = value; } @@ -66,7 +70,9 @@ class MediaControllerMock { * @memberof MediaController# */ getInitialSettings(type) { - if (!type) return null; + if (!type) { + return null; + } return this.initialSettings[type]; } diff --git a/test/unit/test/streaming/streaming.controllers.ClientDataReportingController.js b/test/unit/test/streaming/streaming.controllers.ClientDataReportingController.js index ee7145f5b2..3cce29c124 100644 --- a/test/unit/test/streaming/streaming.controllers.ClientDataReportingController.js +++ b/test/unit/test/streaming/streaming.controllers.ClientDataReportingController.js @@ -1,8 +1,8 @@ import ServiceDescriptionControllerMock from '../../mocks/ServiceDescriptionControllerMock.js'; -import { HTTPRequest } from '../../../../src/streaming/vo/metrics/HTTPRequest.js'; +import {HTTPRequest} from '../../../../src/streaming/vo/metrics/HTTPRequest.js'; import ClientDataReportingController from '../../../../src/streaming/controllers/ClientDataReportingController.js'; -import { expect } from 'chai'; +import {expect} from 'chai'; const context = {}; @@ -20,7 +20,7 @@ describe('ClientDataReportingController', function () { describe('if not configured', function () { it('isServiceLocationIncluded returns true when the filter is not present in manifest', function () { - const serviceLocation='test-location'; + const serviceLocation = 'test-location'; const result = clientDataReportingController.isServiceLocationIncluded(HTTPRequest.MPD_TYPE, serviceLocation); @@ -28,7 +28,7 @@ describe('ClientDataReportingController', function () { }); it('isAdaptationsIncluded returns true when the filter is not present in manifest', function () { - const adaptationId='1'; + const adaptationId = '1'; const result = clientDataReportingController.isAdaptationsIncluded(adaptationId); @@ -36,7 +36,7 @@ describe('ClientDataReportingController', function () { }); it('isServiceLocationIncluded returns true when the filter is not present in manifest and requestType is steering', function () { - const serviceLocation='test-location'; + const serviceLocation = 'test-location'; const result = clientDataReportingController.isServiceLocationIncluded(HTTPRequest.CONTENT_STEERING_TYPE, serviceLocation); @@ -47,7 +47,7 @@ describe('ClientDataReportingController', function () { describe('if configured', function () { it('isServiceLocationIncluded returns true when service location is included in the filter', function () { - const serviceLocation='test-b'; + const serviceLocation = 'test-b'; const serviceDescriptionSettings = { clientDataReporting: { @@ -62,7 +62,7 @@ describe('ClientDataReportingController', function () { }); it('isAdaptationsIncluded returns true when adaptation set is included in the filter', function () { - const adaptationId='test-a'; + const adaptationId = 'test-a'; const serviceDescriptionSettings = { clientDataReporting: { @@ -77,7 +77,7 @@ describe('ClientDataReportingController', function () { }); it('isServiceLocationIncluded returns true when service location is included in the filter and requestType is steering', function () { - const serviceLocation='test-b'; + const serviceLocation = 'test-b'; const serviceDescriptionSettings = { clientDataReporting: { @@ -93,7 +93,7 @@ describe('ClientDataReportingController', function () { it('isServiceLocationIncluded returns false when service location is not included in the filter', function () { - const serviceLocation='test-c'; + const serviceLocation = 'test-c'; const serviceDescriptionSettings = { clientDataReporting: { @@ -108,7 +108,7 @@ describe('ClientDataReportingController', function () { }); it('isAdaptationsIncluded returns false when adaptation set is not included in the filter', function () { - const adaptationId='test-c'; + const adaptationId = 'test-c'; const serviceDescriptionSettings = { clientDataReporting: { @@ -123,7 +123,7 @@ describe('ClientDataReportingController', function () { }); it('isServiceLocationIncluded returns true when service location is not included in the filter but requestType is steering', function () { - const serviceLocation='test-c'; + const serviceLocation = 'test-c'; const serviceDescriptionSettings = { clientDataReporting: {