Merged in m3u-frag (pull request #359)

mjpeg-player: keeping track of loaded fragments

Approved-by: Saxon Milton
This commit is contained in:
Trek Hopton 2020-01-29 03:01:46 +00:00
commit 8cbaa90cff
1 changed files with 14 additions and 10 deletions

View File

@ -38,20 +38,30 @@ class StreamController extends EventHandler {
this.audioCodecSwap = false;
this.stallReported = false;
this.gapController = null;
this.currentFrag = 0;
this.currentFragIdx = 0;
this.lastSN = 0;
this.fragments = [];
}
_fetchPayloadOrEos(levelDetails) {
this.fragments = levelDetails.fragments;
// Keep track of any new frags and load them.
for (let i = 0; i < levelDetails.fragments.length; i++) {
let frag = levelDetails.fragments[i];
if (frag.sn > this.lastSN) {
console.log("adding fragment: " + frag.sn);
this.fragments.push(frag);
this.lastSN = frag.sn;
}
}
this._loadFragment();
}
_loadFragment() {
let fragLen = this.fragments.length;
if (this.currentFrag >= fragLen) {
if (this.currentFragIdx >= fragLen) {
return;
}
this.hls.trigger(Event.FRAG_LOADING, { frag: this.fragments[this.currentFrag++] });
this.hls.trigger(Event.FRAG_LOADING, { frag: this.fragments[this.currentFragIdx++] });
}
onLevelLoaded(data) {
@ -63,11 +73,6 @@ class StreamController extends EventHandler {
console.log(`level ${newLevelId} loaded [${newDetails.startSN},${newDetails.endSN}],duration:${duration}`);
if (newDetails.live) {
console.log("handling of this case is not implemented");
} else {
newDetails.PTSKnown = false;
}
// override level info
this.levelLastLoaded = newLevelId;
this.hls.trigger(Event.LEVEL_UPDATED, { details: newDetails, level: newLevelId });
@ -96,7 +101,6 @@ class StreamController extends EventHandler {
}
this.nextLoadPosition = this.startPosition;
}
this._fetchPayloadOrEos(levelDetails);
}