Skip to content

Commit

Permalink
fix(HLS): Fix seek on LL streams when using segments mode (#5283)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Jun 12, 2023
1 parent ad2eef6 commit d4f3f5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
13 changes: 5 additions & 8 deletions lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,8 @@ shaka.media.MediaSourceEngine = class {
* @param {number} appendWindowEnd The timestamp to set the append window end
* to. For future appends, frames/samples with timestamps greater than this
* value will be dropped.
* @param {boolean} sequenceMode If true, the timestampOffset will not be
* applied in this step.
* @param {boolean} ignoreTimestampOffset If true, the timestampOffset will
* not be applied in this step.
* @param {shaka.extern.Stream} stream The current stream.
* @param {!Map.<shaka.util.ManifestParserUtils.ContentType,
* shaka.extern.Stream>} streamsByType
Expand All @@ -1042,10 +1042,10 @@ shaka.media.MediaSourceEngine = class {
*/
async setStreamProperties(
contentType, timestampOffset, appendWindowStart, appendWindowEnd,
sequenceMode, stream, streamsByType) {
ignoreTimestampOffset, stream, streamsByType) {
const ContentType = shaka.util.ManifestParserUtils.ContentType;
if (contentType == ContentType.TEXT) {
if (!sequenceMode) {
if (!ignoreTimestampOffset) {
this.textEngine_.setTimestampOffset(timestampOffset);
}
this.textEngine_.setAppendWindow(appendWindowStart, appendWindowEnd);
Expand All @@ -1066,10 +1066,7 @@ shaka.media.MediaSourceEngine = class {
hasChangedCodecs ? Promise.resolve() : this.enqueueOperation_(
contentType,
() => this.abort_(contentType)),
// Don't set the timestampOffset here when in sequenceMode, since we
// use timestampOffset for a different purpose in that mode (e.g. to
// indicate where the current segment is).
sequenceMode ? Promise.resolve() : this.enqueueOperation_(
ignoreTimestampOffset ? Promise.resolve() : this.enqueueOperation_(
contentType,
() => this.setTimestampOffset_(contentType, timestampOffset)),
this.enqueueOperation_(
Expand Down
7 changes: 5 additions & 2 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1728,9 +1728,12 @@ shaka.media.StreamingEngine = class {
mediaState.lastMimeType = mimeType;
mediaState.lastTimestampOffset = timestampOffset;

const ignoreTimestampOffset = this.manifest_.sequenceMode ||
this.manifest_.type == shaka.media.ManifestParser.HLS;

await this.playerInterface_.mediaSourceEngine.setStreamProperties(
mediaState.type, timestampOffset, appendWindowStart,
appendWindowEnd, this.manifest_.sequenceMode,
appendWindowEnd, ignoreTimestampOffset,
mediaState.stream, streamsByType);
} catch (error) {
mediaState.lastAppendWindowStart = null;
Expand Down Expand Up @@ -1801,7 +1804,7 @@ shaka.media.StreamingEngine = class {
operations.push(this.playerInterface_.mediaSourceEngine.resync(
mediaState.type, reference.startTime));
}
} else {
} else if (this.manifest_.ignoreManifestTimestampsInSegmentsMode) {
// In segments mode, we need to resync to set the timestampOffset
// to the start of the current discontinuity sequence. This is
// because individual discontinuity sequences may have internal
Expand Down

0 comments on commit d4f3f5c

Please sign in to comment.