Skip to content

Commit

Permalink
fix: Missing AES-128 key of last HLS segment
Browse files Browse the repository at this point in the history
  • Loading branch information
sunb-inflab committed Sep 27, 2022
1 parent b3621c2 commit 5f676db
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Giorgio Gamberoni <[email protected]>
Giuseppe Samela <[email protected]>
Google Inc. <*@google.com>
Itay Kinnrot <[email protected]>
Jaeseok Lee <[email protected]>
Jason Palmer <[email protected]>
Jesper Haug Karsrud <[email protected]>
Johan Sundström <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Hichem Taoufik <[email protected]>
Itay Kinnrot <[email protected]>
Isaac Ramirez <[email protected]>
Jacob Trimble <[email protected]>
Jaeseok Lee <[email protected]>
Jason Palmer <[email protected]>
Jeffrey Swan <[email protected]>
Jesper Haug Karsrud <[email protected]>
Expand Down
5 changes: 4 additions & 1 deletion lib/media/segment_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,10 @@ shaka.media.SegmentIndex = class {
lastReference.partialReferences,
lastReference.tilesLayout,
lastReference.tileDuration,
lastReference.syncTime);
lastReference.syncTime,
undefined,
lastReference.hlsAes128Key,
);
}


Expand Down
28 changes: 26 additions & 2 deletions test/media/segment_index_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,23 @@ describe('SegmentIndex', /** @suppress {accessControls} */ () => {
];
expect(index.references).toEqual(newReferences);
});

it('keeps hlsAes128Key of all references', () => {
// The end time is meant to be exclusive, so segments ending at window
// start should be dropped.
const references = [
makeReference(uri(0), 0, 10, undefined,
{method: 'AES-128', firstMediaSequenceNumber: 0}),
makeReference(uri(1), 10, 20, undefined,
{method: 'AES-128', firstMediaSequenceNumber: 0}),
];

const index = new shaka.media.SegmentIndex(references);
expect(index.references).toEqual(references);

index.fit(/* windowStart= */ 0, /* windowEnd= */ 20);
expect(index.references).toEqual(references);
});
});

describe('merge', () => {
Expand Down Expand Up @@ -955,9 +972,11 @@ describe('SegmentIndex', /** @suppress {accessControls} */ () => {
* @param {number} startTime
* @param {number} endTime
* @param {!Array.<!shaka.media.SegmentReference>=} partialReferences
* @param {!shaka.extern.HlsAes128Key} hlsAes128Key
* @return {shaka.media.SegmentReference}
*/
function makeReference(uri, startTime, endTime, partialReferences = []) {
function makeReference(uri, startTime, endTime, partialReferences = [],
hlsAes128Key = {method: 'AES-128', firstMediaSequenceNumber: 0}) {
return new shaka.media.SegmentReference(
startTime,
endTime,
Expand All @@ -968,6 +987,11 @@ describe('SegmentIndex', /** @suppress {accessControls} */ () => {
/* timestampOffset= */ 0,
/* appendWindowStart= */ 0,
/* appendWindowEnd= */ Infinity,
/* partialReferences= */ partialReferences);
/* partialReferences= */ partialReferences,
undefined,
undefined,
undefined,
undefined,
hlsAes128Key);
}
});

0 comments on commit 5f676db

Please sign in to comment.