Skip to content

Commit

Permalink
fix(HLS): Allow sync live streams without PROGRAM-DATE-TIME (#7340)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Sep 24, 2024
1 parent a3b05fa commit 5655ade
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ shaka.hls.HlsParser = class {
*/
this.lowestSyncTime_ = Infinity;

/**
* Flag to indicate if any of the media playlists use
* EXT-X-PROGRAM-DATE-TIME.
*
* @private {boolean}
*/
this.usesProgramDateTime_ = false;

/**
* Whether the streams have previously been "finalized"; that is to say,
* whether we have loaded enough streams to know information about the asset
Expand Down Expand Up @@ -621,9 +629,10 @@ shaka.hls.HlsParser = class {
* Align the streams by sequence number by dropping early segments. Then
* offset the streams to begin at presentation time 0.
* @param {!Array.<!shaka.hls.HlsParser.StreamInfo>} streamInfos
* @param {boolean=} force
* @private
*/
syncStreamsWithSequenceNumber_(streamInfos) {
syncStreamsWithSequenceNumber_(streamInfos, force = false) {
// We assume that, when this is first called, we have enough info to
// determine how to use the program date times (e.g. we have both a video
// and an audio, and all other videos and audios match those).
Expand Down Expand Up @@ -678,7 +687,7 @@ shaka.hls.HlsParser = class {
this.minSequenceNumber_);

for (const streamInfo of streamInfos) {
if (!this.ignoreManifestProgramDateTimeFor_(streamInfo.type)) {
if (!this.ignoreManifestProgramDateTimeFor_(streamInfo.type) && !force) {
continue;
}
const segmentIndex = streamInfo.stream.segmentIndex;
Expand Down Expand Up @@ -2750,8 +2759,12 @@ shaka.hls.HlsParser = class {
}
}
this.notifySegmentsForStreams_(streamInfos.map((s) => s.stream));
if (this.config_.hls.ignoreManifestProgramDateTime) {
this.syncStreamsWithSequenceNumber_(streamInfos);
const liveWithNoProgramaDateTime =
this.isLive_() && !this.usesProgramDateTime_;
if (this.config_.hls.ignoreManifestProgramDateTime ||
liveWithNoProgramaDateTime) {
this.syncStreamsWithSequenceNumber_(
streamInfos, liveWithNoProgramaDateTime);
} else {
this.syncStreamsWithProgramDateTime_(streamInfos);
if (this.config_.hls.ignoreManifestProgramDateTimeForTypes.length > 0) {
Expand Down Expand Up @@ -3624,6 +3637,7 @@ shaka.hls.HlsParser = class {
syncTime = shaka.util.TXml.parseDate(dateTimeTag.value);
goog.asserts.assert(syncTime != null,
'EXT-X-PROGRAM-DATE-TIME format not valid');
this.usesProgramDateTime_ = true;
}
}

Expand Down

0 comments on commit 5655ade

Please sign in to comment.