Skip to content

Commit

Permalink
fix: Load image streams for offline multiperiod
Browse files Browse the repository at this point in the history
When loading offline content, we should load the image streams as
well.

Issue shaka-project#3383

Change-Id: I8cdd3d1ade188b7b2278a0eac5510a968229c6fc
  • Loading branch information
joeyparrish committed Jul 12, 2021
1 parent 42674be commit 4f4f6b1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/util/periods.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ shaka.util.PeriodCombiner = class {
(streams) => streams.filter((s) => s.type == ContentType.VIDEO));
const textStreamDbsPerPeriod = streamDbsPerPeriod.map(
(streams) => streams.filter((s) => s.type == ContentType.TEXT));
const imageStreamDbsPerPeriod = streamDbsPerPeriod.map(
(streams) => streams.filter((s) => s.type == ContentType.IMAGE));

// It's okay to have a period with no text, but our algorithm fails on any
// period without matching streams. So we add dummy text streams to each
Expand Down Expand Up @@ -429,6 +431,13 @@ shaka.util.PeriodCombiner = class {
shaka.util.PeriodCombiner.cloneStreamDB_,
shaka.util.PeriodCombiner.concatenateStreamDBs_);

const combinedImageStreamDbs = await shaka.util.PeriodCombiner.combine_(
/* outputStreams= */ [],
imageStreamDbsPerPeriod,
/* firstNewPeriodIndex= */ 0,
shaka.util.PeriodCombiner.cloneStreamDB_,
shaka.util.PeriodCombiner.concatenateStreamDBs_);

// Recreate variantIds from scratch in the output.
// HLS content is always single-period, so the early return at the top of
// this method would catch all HLS content. DASH content stored with v3.0
Expand Down Expand Up @@ -457,7 +466,8 @@ shaka.util.PeriodCombiner = class {

return combinedVideoStreamDbs
.concat(combinedAudioStreamDbs)
.concat(combinedTextStreamDbs);
.concat(combinedTextStreamDbs)
.concat(combinedImageStreamDbs);
}

/**
Expand Down

0 comments on commit 4f4f6b1

Please sign in to comment.