Skip to content

Commit

Permalink
Merge branch 'master' into fix-fragment-loop
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkim9 committed Dec 15, 2017
2 parents 697170a + 017338f commit c3e7dc1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions doc/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ design idea is pretty simple :
**Feature: Media Zigzagging**

If there is a backup stream, Media Zigzagging will go through all available levels in `primary` and `backup` streams. Behavior has a dual constraint, where fragment retry limits and level limits are accounted in the same time.
When the lowest level has been reached, zigzagging will be adjusted to start from the highest level until retry limits are not reached.

![Media Zigzagging Explanation](./media-zigzagging.png)

Expand Down
12 changes: 7 additions & 5 deletions src/controller/level-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export default class LevelController extends EventHandler {
let {config} = this.hls;
let {details: errorDetails} = errorEvent;
let level = this._levels[levelIndex];
let redundantLevels, delay;
let redundantLevels, delay, nextLevel;

level.loadError++;
level.fragmentError = fragmentError;
Expand Down Expand Up @@ -326,10 +326,12 @@ export default class LevelController extends EventHandler {
level.urlId = (level.urlId + 1) % redundantLevels;
level.details = undefined;
} else {
// Switch-down if more renditions are available
if (this.manualLevelIndex === -1 && levelIndex !== 0) {
logger.warn(`level controller, ${errorDetails}: switch-down to ${levelIndex - 1}`);
this.hls.nextAutoLevel = this.currentLevelIndex = levelIndex - 1;
// Search for available level
if (this.manualLevelIndex === -1) {
// When lowest level has been reached, let's start hunt from the top
nextLevel = (levelIndex === 0) ? this._levels.length - 1 : levelIndex - 1;
logger.warn(`level controller, ${errorDetails}: switch to ${nextLevel}`);
this.hls.nextAutoLevel = this.currentLevelIndex = nextLevel;
} else if (fragmentError === true) {
// Allow fragment retry as long as configuration allows.
// reset this._level so that another call to set level() will trigger again a frag load
Expand Down

0 comments on commit c3e7dc1

Please sign in to comment.