Skip to content

Commit

Permalink
Error on unsupported media
Browse files Browse the repository at this point in the history
Fixes #5011
  • Loading branch information
robwalch committed Jan 20, 2023
1 parent 6f6fa2e commit 4d0b42b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
21 changes: 19 additions & 2 deletions src/controller/base-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ export default class BaseStreamController
// if we're here we probably needed to backtrack or are waiting for more parts
return;
}
this.fragLoadError = 0;
const state = this.state;
if (this.fragContextChanged(frag)) {
if (
Expand Down Expand Up @@ -1364,6 +1363,9 @@ export default class BaseStreamController
);
// keep retrying until the limit will be reached
if (this.fragLoadError + 1 <= config.fragLoadingMaxRetry) {
if (data.details === ErrorDetails.FRAG_PARSING_ERROR) {
return;
}
if (!this.loadedmetadata) {
this.startFragRequested = false;
this.nextLoadPosition = this.startPosition;
Expand Down Expand Up @@ -1491,11 +1493,26 @@ export default class BaseStreamController
},
false
);
if (!parsed) {
if (parsed) {
this.fragLoadError = 0;
} else {
this.warn(
`Found no media in fragment ${frag.sn} of level ${level.id} resetting transmuxer to fallback to playlist timing`
);
this.fragLoadError++;
const penalizeLevel = this.fragLoadError > 3;
this.hls.trigger(Events.ERROR, {
type: ErrorTypes.MEDIA_ERROR,
details: ErrorDetails.FRAG_PARSING_ERROR,
fatal: false,
frag,
levelRetry: !penalizeLevel,
reason: `Found no media in msn ${frag.sn} of level "${level.url}"`,
});
this.resetTransmuxer();
if (penalizeLevel) {
return;
}
}
this.state = State.PARSED;
this.hls.trigger(Events.FRAG_PARSED, { frag, part });
Expand Down
6 changes: 4 additions & 2 deletions src/controller/level-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,10 @@ export default class LevelController extends BasePlaylistController {
data.frag?.type === PlaylistLevelType.MAIN
? data.frag.level
: this.currentLevelIndex;
// Do not retry level. Escalate to fatal if switching levels fails.
data.levelRetry = false;
if (data.levelRetry !== true) {
// Do not retry level. Escalate to fatal if switching levels fails.
data.levelRetry = false;
}
break;
case ErrorDetails.LEVEL_LOAD_ERROR:
case ErrorDetails.LEVEL_LOAD_TIMEOUT:
Expand Down
14 changes: 9 additions & 5 deletions src/demux/transmuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,15 @@ export default class Transmuxer {
}
}
if (!mux) {
// If probing previous configs fail, use mp4 passthrough
logger.warn(
'Failed to find demuxer by probing frag, treating as mp4 passthrough'
);
mux = { demux: MP4Demuxer, remux: PassThroughRemuxer };
this.demuxer = undefined;
this.remuxer = undefined;
this.observer.emit(Events.ERROR, Events.ERROR, {
type: ErrorTypes.MEDIA_ERROR,
details: ErrorDetails.FRAG_PARSING_ERROR,
fatal: true,
reason: 'Failed to find demuxer by probing frag',
});
return;
}
// so let's check that current remuxer and demuxer are still valid
const demuxer = this.demuxer;
Expand Down

0 comments on commit 4d0b42b

Please sign in to comment.