Skip to content

Commit

Permalink
Allow the odd empty segment to be skipped like a gap segment (#5676)
Browse files Browse the repository at this point in the history
* Allow the odd empty segment to be skipped like a gap segment
Resolves #5674

* Handle buffered gap segments in fragment tracker so they can be treated as partial appends
  • Loading branch information
robwalch committed Jul 18, 2023
1 parent 1dd623c commit 7cde71f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/controller/base-stream-controller.ts
Expand Up @@ -1708,8 +1708,15 @@ export default class BaseStreamController
level.fragmentError = 0;
} else if (this.transmuxer?.error === null) {
const error = new Error(
`Found no media in fragment ${frag.sn} of level ${level.id} resetting transmuxer to fallback to playlist timing`
`Found no media in fragment ${frag.sn} of level ${frag.level} resetting transmuxer to fallback to playlist timing`
);
if (level.fragmentError === 0) {
// Mark and track the odd empty segment as a gap to avoid reloading
level.fragmentError++;
frag.gap = true;
this.fragmentTracker.removeFragment(frag);
this.fragmentTracker.fragBuffered(frag, true);
}
this.warn(error.message);
this.hls.trigger(Events.ERROR, {
type: ErrorTypes.MEDIA_ERROR,
Expand Down
11 changes: 10 additions & 1 deletion src/controller/error-controller.ts
Expand Up @@ -128,8 +128,17 @@ export default class ErrorController implements NetworkComponentAPI {
case ErrorDetails.KEY_LOAD_TIMEOUT:
data.errorAction = this.getFragRetryOrSwitchAction(data);
return;
case ErrorDetails.FRAG_GAP:
case ErrorDetails.FRAG_PARSING_ERROR:
// ignore empty segment errors marked as gap
if (data.frag?.gap) {
data.errorAction = {
action: NetworkErrorAction.DoNothing,
flags: ErrorActionFlags.None,
};
return;
}
// falls through
case ErrorDetails.FRAG_GAP:
case ErrorDetails.FRAG_DECRYPT_ERROR: {
// Switch level if possible, otherwise allow retry count to reach max error retries
data.errorAction = this.getFragRetryOrSwitchAction(data);
Expand Down
2 changes: 1 addition & 1 deletion src/controller/fragment-tracker.ts
Expand Up @@ -185,7 +185,7 @@ export class FragmentTracker implements ComponentAPI {

const fragKey = getFragmentKey(frag);
const fragmentEntity = this.fragments[fragKey];
if (!fragmentEntity) {
if (!fragmentEntity || (fragmentEntity.buffered && frag.gap)) {
return;
}
const isFragHint = !frag.relurl;
Expand Down

0 comments on commit 7cde71f

Please sign in to comment.