Skip to content

Commit

Permalink
Merge branch 'fix/independent-subtitle-playhead' of https://github.co…
Browse files Browse the repository at this point in the history
…m/Eyevinn/channel-engine into fix/independent-subtitle-playhead
  • Loading branch information
Nfrederiksen committed Nov 21, 2023
2 parents 774b6dc + f2f5d33 commit 3d6f1cf
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions engine/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -2100,40 +2100,6 @@ class Session {
}
return false;
}

async _determineExtraMediaIncrement(_extraType, _currentPosVideo, _extraSeqFinalIndex, _vodMediaSeqExtra, _getExtraPlayheadPositionAsyncFn) {
debug(`[${this._sessionId}]: About to determine ${_extraType} increment. Video increment has already been executed.`);
let extraMediaIncrement = 0;
let positionV = _currentPosVideo ? _currentPosVideo / 1000 : 0;
let positionX;
let posDiff;
const threshold = 0.500;
while (extraMediaIncrement < _extraSeqFinalIndex) {
const currentPosExtraMedia = (await _getExtraPlayheadPositionAsyncFn(_vodMediaSeqExtra + extraMediaIncrement)) * 1000;
positionX = currentPosExtraMedia ? currentPosExtraMedia / 1000 : 0;
posDiff = (positionV - positionX).toFixed(3);
debug(`[${this._sessionId}]: positionV=${positionV};position${_extraType === "audio" ? "A" : "S"}=${positionX};posDiff=${posDiff}`);
if (isNaN(posDiff)) {
break;
}
if (positionX >= positionV) {
break;
}
const difference = Math.abs(posDiff);
if (difference > threshold && difference > Number.EPSILON) {
// Video position ahead of audio|sub position, further increment needed...
extraMediaIncrement++;
} else {
debug(`[${this._sessionId}]: Difference(${difference}) is acceptable; IncrementValue=${extraMediaIncrement}`);
break;
}
}
return {
increment: extraMediaIncrement,
position: positionX,
diff: posDiff
};
}
}

module.exports = Session;

0 comments on commit 3d6f1cf

Please sign in to comment.