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

Exclude text StreamProcessor when checking buffer level for initial playback #3857

Merged
merged 1 commit into from
Jan 21, 2022
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
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