Skip to content

Commit

Permalink
feat(FEC-13574): Add support in stallDetectionThreshold min value is 2 (
Browse files Browse the repository at this point in the history
#255)

Co-authored-by: Moshe Maor <moshe.mar@kaltura.com>
  • Loading branch information
MosheMaorKaltura and Moshe Maor committed Dec 17, 2023
1 parent 0369319 commit af64aac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/dash-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ const ABR_RESTRICTION_UPDATE_INTERVAL = 1000;
const STALL_DETECTION_INTERVAL = 500;

/**
* the threshold for stall detection in seconds
* the minimal threshold for stall detection in seconds
* @type {number}
* @const
*/
const STALL_DETECTION_THRESHOLD = 3;
const MIN_STALL_DETECTION_THRESHOLD = 2;

/**
* the threshold needed to break the stall
Expand Down Expand Up @@ -250,6 +250,10 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
if (typeof streaming.forceBreakStall === 'boolean') {
adapterConfig.forceBreakStall = streaming.forceBreakStall;
}
if (typeof streaming.stallDetectionThreshold === 'number') {
adapterConfig.stallDetectionThreshold = Math.max(MIN_STALL_DETECTION_THRESHOLD, streaming.stallDetectionThreshold);
}

if (typeof streaming.lowLatencyMode === 'boolean') {
adapterConfig.lowLatencyMode = streaming.lowLatencyMode;
}
Expand Down Expand Up @@ -444,7 +448,7 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
this._stallInterval = setInterval(() => {
const stallSeconds = getCurrentTimeInSeconds() - lastUpdateTime;
//waiting for 3 sec until checking stalling
if (stallSeconds > STALL_DETECTION_THRESHOLD && !this._videoElement.paused) {
if (stallSeconds > this._config.stallDetectionThreshold && !this._videoElement.paused) {
if (lastCurrentTime === this._videoElement.currentTime) {
DashAdapter._logger.debug('stall found, break the stall');
this._videoElement.currentTime = parseFloat(this._videoElement.currentTime.toFixed(1)) + STALL_BREAK_THRESHOLD;
Expand Down
3 changes: 2 additions & 1 deletion src/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
},
"forceRedirectExternalStreams": false,
"trackEmsgEvents": true,
"switchDynamicToStatic": false
"switchDynamicToStatic": false,
"stallDetectionThreshold": 3
}

0 comments on commit af64aac

Please sign in to comment.