Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a settings parameter for the EventController.js refresh delay #3577

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ declare namespace dashjs {
useAppendWindow?: boolean,
manifestUpdateRetryInterval?: number;
stallThreshold?: number;
filterUnsupportedEssentialProperties?: true
filterUnsupportedEssentialProperties?: boolean;
eventControllerRefreshDelay?: number;
utcSynchronization?: {
backgroundAttempts?: number,
timeBetweenSyncAttempts?: number,
Expand Down
4 changes: 4 additions & 0 deletions src/core/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import {HTTPRequest} from '../streaming/vo/metrics/HTTPRequest';
* manifestUpdateRetryInterval: 100,
* stallThreshold: 0.5,
* filterUnsupportedEssentialProperties: true,
* eventControllerRefreshDelay: 100,
* utcSynchronization: {
* backgroundAttempts: 2,
* timeBetweenSyncAttempts: 30,
Expand Down Expand Up @@ -364,6 +365,8 @@ import {HTTPRequest} from '../streaming/vo/metrics/HTTPRequest';
* Stall threshold used in BufferController.js to determine whether a track should still be changed and which buffer range to prune.
* @property {boolean} [filterUnsupportedEssentialProperties=true]
* Enable to filter all the AdaptationSets and Representations which contain an unsupported \<EssentialProperty\> element.
* @property {number} [eventControllerRefreshDelay=100]
* Defines the delay in milliseconds between two consecutive checks for events to be fired.
* @property {module:Settings~UtcSynchronizationSettings} utcSynchronization Settings related to UTC clock synchronization
* @property {module:Settings~LiveCatchupSettings} liveCatchup Settings related to live catchup.
* @property {module:Settings~CachingInfoSettings} [lastBitrateCachingInfo={enabled: true, ttl: 360000}]
Expand Down Expand Up @@ -627,6 +630,7 @@ function Settings() {
manifestUpdateRetryInterval: 100,
stallThreshold: 0.5,
filterUnsupportedEssentialProperties: true,
eventControllerRefreshDelay: 100,
utcSynchronization: {
backgroundAttempts: 2,
timeBetweenSyncAttempts: 30,
Expand Down
13 changes: 8 additions & 5 deletions src/streaming/controllers/EventController.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ function EventController() {
const MPD_CALLBACK_SCHEME = 'urn:mpeg:dash:event:callback:2015';
const MPD_CALLBACK_VALUE = 1;

const REFRESH_DELAY = 100;
const REMAINING_EVENTS_THRESHOLD = 300;

const EVENT_HANDLED_STATES = {
Expand All @@ -63,6 +62,7 @@ function EventController() {
lastEventTimerCall,
manifestUpdater,
playbackController,
settings,
eventHandlingInProgress,
isStarted;

Expand Down Expand Up @@ -118,9 +118,10 @@ function EventController() {
try {
checkConfig();
logger.debug('Start Event Controller');
if (!isStarted && !isNaN(REFRESH_DELAY)) {
const refreshDelay = settings.get().streaming.eventControllerRefreshDelay;
if (!isStarted && !isNaN(refreshDelay)) {
isStarted = true;
eventInterval = setInterval(_onEventTimer, REFRESH_DELAY);
eventInterval = setInterval(_onEventTimer, refreshDelay);
}
} catch (e) {
throw e;
Expand Down Expand Up @@ -504,14 +505,16 @@ function EventController() {
if (!config) {
return;
}

if (config.manifestUpdater) {
manifestUpdater = config.manifestUpdater;
}

if (config.playbackController) {
playbackController = config.playbackController;
}
if (config.settings) {
settings = config.settings;
}

} catch (e) {
throw e;
}
Expand Down
3 changes: 2 additions & 1 deletion src/streaming/controllers/StreamController.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ function StreamController() {
eventController = EventController(context).getInstance();
eventController.setConfig({
manifestUpdater: manifestUpdater,
playbackController: playbackController
playbackController: playbackController,
settings
});
eventController.start();

Expand Down
5 changes: 4 additions & 1 deletion test/unit/streaming.controllers.EventController.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import EventBus from '../../src/core/EventBus';
import MediaPlayerEvents from '../../src/streaming/MediaPlayerEvents';
import PlaybackControllerMock from './mocks/PlaybackControllerMock';
import ManifestUpdaterMock from './mocks/ManifestUpdaterMock';
import Settings from '../../src/core/Settings';

const expect = require('chai').expect;
const context = {};
Expand All @@ -13,6 +14,7 @@ describe('EventController', function () {

let manifestUpdaterMock = new ManifestUpdaterMock();
let playbackControllerMock = new PlaybackControllerMock();
const settings = Settings(context).getInstance();

const manifestExpiredEventStub = {
'duration': 0,
Expand Down Expand Up @@ -58,7 +60,8 @@ describe('EventController', function () {
eventController.reset();
eventController.setConfig({
manifestUpdater: manifestUpdaterMock,
playbackController: playbackControllerMock
playbackController: playbackControllerMock,
settings
});
});

Expand Down