Skip to content

Commit

Permalink
fix(HLS): Avoid get basic info when the first segment is a gap (#6882)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Jun 21, 2024
1 parent 1c863c8 commit f217344
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2350,24 +2350,32 @@ shaka.hls.HlsParser = class {
this.config_.hls.disableCodecGuessing) ||
(this.needsClosedCaptionsDetection_ && type == ContentType.VIDEO &&
!this.config_.hls.disableClosedCaptionsDetection)) {
this.needsClosedCaptionsDetection_ = false;

const basicInfo = await this.getMediaPlaylistBasicInfo_(
playlist, getUris, mediaVariables);

goog.asserts.assert(
type === basicInfo.type, 'Media types should match!');

if (basicInfo.closedCaptions.size && (!closedCaptions ||
closedCaptions.size != basicInfo.closedCaptions.size)) {
closedCaptions = basicInfo.closedCaptions;
closedCaptionsUpdated = true;
let canRequestBasicInfo = playlist.segments.length > 0;
if (canRequestBasicInfo) {
const segment = playlist.segments[0];
if (shaka.hls.Utils.getFirstTagWithName(segment.tags, 'EXT-X-GAP')) {
canRequestBasicInfo = false;
}
}
if (canRequestBasicInfo) {
this.needsClosedCaptionsDetection_ = false;
const basicInfo = await this.getMediaPlaylistBasicInfo_(
playlist, getUris, mediaVariables);

goog.asserts.assert(
type === basicInfo.type, 'Media types should match!');

if (basicInfo.closedCaptions.size && (!closedCaptions ||
closedCaptions.size != basicInfo.closedCaptions.size)) {
closedCaptions = basicInfo.closedCaptions;
closedCaptionsUpdated = true;
}

if (!this.codecInfoInManifest_ &&
this.config_.hls.disableCodecGuessing) {
mimeType = basicInfo.mimeType;
codecs = basicInfo.codecs;
if (!this.codecInfoInManifest_ &&
this.config_.hls.disableCodecGuessing) {
mimeType = basicInfo.mimeType;
codecs = basicInfo.codecs;
}
}
}

Expand Down

0 comments on commit f217344

Please sign in to comment.