Skip to content

Commit

Permalink
stream-controller: dont backtrack if dropped frames on first frag
Browse files Browse the repository at this point in the history
related to video-dev#1377
  • Loading branch information
mangui committed Oct 5, 2017
1 parent 9255b96 commit 8f0ba57
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1136,16 +1136,21 @@ class StreamController extends EventHandler {
frag.dropped = data.dropped;
if (frag.dropped) {
if (!frag.backtracked) {
logger.warn('missing video frame(s), backtracking fragment');
// Return back to the IDLE state without appending to buffer
// Causes findFragments to backtrack a segment and find the keyframe
// Audio fragments arriving before video sets the nextLoadPosition, causing _findFragments to skip the backtracked fragment
frag.backtracked = true;
this.nextLoadPosition = data.startPTS;
this.state = State.IDLE;
this.fragPrevious = frag;
this.tick();
return;
const levelDetails = level.details;
if (levelDetails && frag.sn === levelDetails.startSN) {
logger.warn('missing video frame(s) on first frag, appending with gap');
} else {
logger.warn('missing video frame(s), backtracking fragment');
// Return back to the IDLE state without appending to buffer
// Causes findFragments to backtrack a segment and find the keyframe
// Audio fragments arriving before video sets the nextLoadPosition, causing _findFragments to skip the backtracked fragment
frag.backtracked = true;
this.nextLoadPosition = data.startPTS;
this.state = State.IDLE;
this.fragPrevious = frag;
this.tick();
return;
}
} else {
logger.warn('Already backtracked on this fragment, appending with the gap');
}
Expand Down

0 comments on commit 8f0ba57

Please sign in to comment.