Skip to content

Commit

Permalink
video-dev#359 improve manifest refresh logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gjanblaszczyk committed Apr 8, 2016
1 parent 80dfaf1 commit 05e0a07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/controller/level-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class LevelController extends EventHandler {
if (data.details.live && !this.timer) {
// if live playlist we will have to reload it periodically
// set reload period to playlist target duration
this.timer = setInterval(this.ontick, 1000 * data.details.targetduration);
this.timer = setInterval(this.ontick, 1000 * (data.details.avrtargetduration ? data.details.avrtargetduration : data.details.targetduration));
}
if (!data.details.live && this.timer) {
// playlist is not live and timer is armed : stopping it
Expand Down
5 changes: 5 additions & 0 deletions src/loader/playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class PlaylistLoader extends EventHandler {
cc = 0,
programDateTime = null,
frag = null,
maxFragDuration = 0,
minFragDuration = Infinity,
result,
regexp,
byteRangeEndOffset,
Expand Down Expand Up @@ -175,6 +177,8 @@ class PlaylistLoader extends EventHandler {
frag = {url: url, duration: duration, start: totalduration, sn: sn, level: id, cc: cc, byteRangeStartOffset: byteRangeStartOffset, byteRangeEndOffset: byteRangeEndOffset, decryptdata : fragdecryptdata, programDateTime: programDateTime};
level.fragments.push(frag);
totalduration += duration;
minFragDuration = duration < minFragDuration ? duration : minFragDuration;
maxFragDuration = duration > maxFragDuration ? duration : maxFragDuration;
byteRangeStartOffset = null;
programDateTime = null;
}
Expand Down Expand Up @@ -211,6 +215,7 @@ class PlaylistLoader extends EventHandler {
totalduration-=frag.duration;
}
level.totalduration = totalduration;
level.avrtargetduration = (minFragDuration + maxFragDuration) / 2;
level.endSN = currentSN - 1;
return level;
}
Expand Down

0 comments on commit 05e0a07

Please sign in to comment.