Skip to content

Commit

Permalink
Merge pull request #1341 from gavr-pavel/master
Browse files Browse the repository at this point in the history
fix frag loading loop detection
  • Loading branch information
mangui committed Sep 14, 2017
2 parents faa4a93 + dc961c1 commit 7a37214
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,8 +698,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 @@ -1402,8 +1404,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 @@ -1540,8 +1544,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

0 comments on commit 7a37214

Please sign in to comment.