Skip to content

Commit

Permalink
Exclude text StreamProcessor when checking buffer level for initial p…
Browse files Browse the repository at this point in the history
…layback (#3857)
  • Loading branch information
dsilhavy authored Jan 21, 2022
1 parent b3e56e4 commit f21d328
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
19 changes: 13 additions & 6 deletions src/streaming/controllers/PlaybackController.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,14 +642,21 @@ function PlaybackController() {
return settings.get().streaming.liveCatchup.enabled || settings.get().streaming.lowLatencyEnabled;
}

function getBufferLevel() {
/**
* Returns the combined minimum buffer level of all StreamProcessors. If a filter list is provided the types specified in the filter list are excluded.
* @param {array} filterList StreamProcessor types to exclude
* @return {null}
*/
function getBufferLevel(filterList = null) {
let bufferLevel = null;
streamController.getActiveStreamProcessors().forEach(p => {
const bl = p.getBufferLevel();
if (bufferLevel === null) {
bufferLevel = bl;
} else {
bufferLevel = Math.min(bufferLevel, bl);
if (!filterList || filterList.length === 0 || filterList.indexOf(p.getType()) === -1) {
const bl = p.getBufferLevel();
if (bufferLevel === null) {
bufferLevel = bl;
} else {
bufferLevel = Math.min(bufferLevel, bl);
}
}
});

Expand Down
4 changes: 2 additions & 2 deletions src/streaming/controllers/StreamController.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,8 @@ function StreamController() {
// check if this is the initial playback and we reached the buffer target. If autoplay is true we start playback
if (initialPlayback && autoPlay) {
const initialBufferLevel = mediaPlayerModel.getInitialBufferLevel();

if (isNaN(initialBufferLevel) || initialBufferLevel <= playbackController.getBufferLevel() || (adapter.getIsDynamic() && initialBufferLevel > playbackController.getLiveDelay())) {
const excludedStreamProcessors = [Constants.TEXT];
if (isNaN(initialBufferLevel) || initialBufferLevel <= playbackController.getBufferLevel(excludedStreamProcessors) || (adapter.getIsDynamic() && initialBufferLevel > playbackController.getLiveDelay())) {
initialPlayback = false;
_createPlaylistMetrics(PlayList.INITIAL_PLAYOUT_START_REASON);
playbackController.play();
Expand Down

0 comments on commit f21d328

Please sign in to comment.