Skip to content

Commit

Permalink
fix(DASH): Fix creation of multiperiod trickmode streams (#7229)
Browse files Browse the repository at this point in the history
  • Loading branch information
tykus160 authored and avelad committed Aug 29, 2024
1 parent da68173 commit 97d6fd8
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions lib/util/periods.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,26 +890,33 @@ shaka.util.PeriodCombiner = class {
// Create a fresh output stream for trick-mode playback.
output.trickModeVideo = shaka.util.PeriodCombiner.cloneStream_(
input.trickModeVideo);
// TODO: fix the createSegmentIndex function for trickModeVideo.
// The trick-mode tracks in multi-period content should have trick-mode
// segment indexes whenever available, rather than only regular-mode
// segment indexes.
output.trickModeVideo.matchedStreams = [];
output.trickModeVideo.createSegmentIndex = () => {
// Satisfy the compiler about the type.
goog.asserts.assert(
output.segmentIndex instanceof shaka.media.MetaSegmentIndex,
'The stream should have a MetaSegmentIndex.');
output.trickModeVideo.segmentIndex = output.segmentIndex.clone();
if (output.trickModeVideo.segmentIndex) {
return Promise.resolve();
}
const segmentIndex = new shaka.media.MetaSegmentIndex();
goog.asserts.assert(output.trickModeVideo.matchedStreams,
'trickmode matched streams should exist');
for (const stream of output.trickModeVideo.matchedStreams) {
goog.asserts.assert(stream.segmentIndex,
'trickmode segment index should exist');
segmentIndex.appendSegmentIndex(stream.segmentIndex);
}
output.trickModeVideo.segmentIndex = segmentIndex;

return Promise.resolve();
};
}

// Concatenate the trick mode input onto the trick mode output.
output.trickModeVideo.matchedStreams.push(input.trickModeVideo);
shaka.util.PeriodCombiner.concatenateStreams_(
output.trickModeVideo, input.trickModeVideo);
} else if (output.trickModeVideo) {
// We have a trick mode output, but no input from this Period. Fill it in
// from the standard input Stream.
output.trickModeVideo.matchedStreams.push(input);
shaka.util.PeriodCombiner.concatenateStreams_(
output.trickModeVideo, input);
}
Expand Down

0 comments on commit 97d6fd8

Please sign in to comment.