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

fix frag loading loop detection #1341

Merged
merged 1 commit into from
Sep 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,10 @@ class StreamController extends EventHandler {
// ensure that media is defined and that metadata are available (to retrieve currentTime)
if (media && media.readyState) {
let fetchdelay, fragPlayingCurrent, nextBufferedFrag;
// increase fragment load Index to avoid frag loop loading error after buffer flush
this.fragLoadIdx += 2 * this.config.fragLoadingLoopThreshold;
if (this.fragLoadIdx !== undefined) {
// increase fragment load Index to avoid frag loop loading error after buffer flush
this.fragLoadIdx += 2 * this.config.fragLoadingLoopThreshold;
}
fragPlayingCurrent = this.getBufferedFrag(media.currentTime);
if (fragPlayingCurrent && fragPlayingCurrent.startPTS > 1) {
// flush buffer preceding current fragment (flush until current fragment start offset)
Expand Down Expand Up @@ -1401,8 +1403,10 @@ class StreamController extends EventHandler {
// reduce max buffer length as it might be too high. we do this to avoid loop flushing ...
config.maxMaxBufferLength/=2;
logger.warn(`main:reduce max buffer length to ${config.maxMaxBufferLength}s`);
// increase fragment load Index to avoid frag loop loading error after buffer flush
this.fragLoadIdx += 2 * config.fragLoadingLoopThreshold;
if (this.fragLoadIdx !== undefined) {
// increase fragment load Index to avoid frag loop loading error after buffer flush
this.fragLoadIdx += 2 * config.fragLoadingLoopThreshold;
}
}
}

Expand Down Expand Up @@ -1539,8 +1543,10 @@ _checkBuffer() {
const media = this.mediaBuffer ? this.mediaBuffer : this.media;
this._bufferedFrags = this._bufferedFrags.filter(frag => {return BufferHelper.isBuffered(media,(frag.startPTS + frag.endPTS) / 2);});

// increase fragment load Index to avoid frag loop loading error after buffer flush
this.fragLoadIdx += 2 * this.config.fragLoadingLoopThreshold;
if (this.fragLoadIdx !== undefined) {
// increase fragment load Index to avoid frag loop loading error after buffer flush
this.fragLoadIdx += 2 * this.config.fragLoadingLoopThreshold;
}
// move to IDLE once flush complete. this should trigger new fragment loading
this.state = State.IDLE;
// reset reference to frag
Expand Down