Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(HLS): Allow sync live streams without PROGRAM-DATE-TIME #7340

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2752,8 +2761,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 @@ -3626,6 +3639,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
Loading