Skip to content

Commit

Permalink
Fix content steering BaseURL blacklisting duration (#4502)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbert authored Jun 19, 2024
1 parent ca4c7aa commit 9b4aa90
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/streaming/controllers/BlacklistController.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ function BlackListController(config) {
eventBus.trigger(updateEventName, { entry: entry });
}

function remove(entry) {
const index = blacklist.indexOf(entry);
if (index !== -1) {
blacklist.splice(index, 1)
}
}

function onAddBlackList(e) {
add(e.entry);
}
Expand All @@ -76,6 +83,7 @@ function BlackListController(config) {

instance = {
add: add,
remove: remove,
contains: contains,
reset: reset
};
Expand Down
4 changes: 3 additions & 1 deletion src/streaming/utils/BaseURLSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ function BaseURLSelector() {

contentSteeringSelector = ContentSteeringSelector(context).create();
contentSteeringSelector.setConfig({
blacklistController: serviceLocationBlacklistController
blacklistController: serviceLocationBlacklistController,
addBlacklistEventName: Events.SERVICE_LOCATION_BASE_URL_BLACKLIST_ADD
})

selector = basicSelector;
Expand Down Expand Up @@ -131,6 +132,7 @@ function BaseURLSelector() {
}

function reset() {
contentSteeringSelector.reset();
serviceLocationBlacklistController.reset();
}

Expand Down
29 changes: 27 additions & 2 deletions src/streaming/utils/baseUrlResolution/ContentSteeringSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@

import FactoryMaker from '../../../core/FactoryMaker.js';
import ContentSteeringController from '../../../dash/controllers/ContentSteeringController.js';
import EventBus from '../../../core/EventBus.js';

function ContentSteeringSelector() {

const context = this.context;
const eventBus = EventBus(context).getInstance();
let instance,
contentSteeringController,
blacklistController;
blacklistController,
blacklistResetTimeout = [];

function setup() {
contentSteeringController = ContentSteeringController(context).getInstance();
Expand All @@ -50,6 +53,7 @@ function ContentSteeringSelector() {
if (config.contentSteeringController) {
contentSteeringController = config.contentSteeringController;
}
eventBus.on(config.addBlacklistEventName, _onAddBlackList, instance);
}

function selectBaseUrlIndex(data) {
Expand All @@ -73,6 +77,11 @@ function ContentSteeringSelector() {
return steeringIndex;
}

function reset() {
blacklistResetTimeout.forEach(timer => clearTimeout(timer))
blacklistResetTimeout = []
}

function _findexIndexOfServiceLocation(pathwayPriority = [], baseUrls = []) {
let i = 0;
let steeringIndex = NaN;
Expand All @@ -90,9 +99,25 @@ function ContentSteeringSelector() {
return steeringIndex;
}


function _onAddBlackList(e) {
const currentSteeringResponseData = contentSteeringController.getCurrentSteeringResponseData();
if (!currentSteeringResponseData) {
return
}
const entry = e.entry
const timer = setTimeout(() => {
blacklistController.remove(entry);
blacklistResetTimeout.splice(blacklistResetTimeout.indexOf(timer, 1))
}, currentSteeringResponseData.ttl * 1000);
blacklistResetTimeout.push(timer)
}


instance = {
selectBaseUrlIndex,
setConfig
setConfig,
reset
};

setup();
Expand Down

0 comments on commit 9b4aa90

Please sign in to comment.