Skip to content

Commit

Permalink
fix: Fix DRM workaround for Tizen and Xbox with hvc1/hev1 boxes (shak…
Browse files Browse the repository at this point in the history
…a-project#4743) (shaka-project#194)

* fix: Fix DRM workaround for Tizen and Xbox with hvc1/hev1 boxes (shaka-project#4743)

fixes shaka-project#4742

* Add unit test

* fix typing

---------

Co-authored-by: Ricardo Alves <[email protected]>
  • Loading branch information
tykus160 and ricardo-a-alves-alb authored Mar 29, 2023
1 parent 56f7f83 commit 342bb0d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/media/content_workarounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ shaka.media.ContentWorkarounds = class {
})
.fullBox('encv', onEncryptionMetadataBox)
.fullBox('enca', onEncryptionMetadataBox)
.fullBox('hev1', (box) => {
boxesToModify.push({
box,
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
});
})
.fullBox('hvc1', (box) => {
boxesToModify.push({
box,
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
});
})
.fullBox('avc1', (box) => {
boxesToModify.push({
box,
Expand Down
23 changes: 23 additions & 0 deletions test/media/content_workarounds_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,29 @@ describe('Content Workarounds', () => {
shaka.util.Mp4Parser = oldMp4Parser;
});

it('adds encv box for HEVC', () => {
const hevc = new Uint8Array([
0x00, 0x00, 0x00, 0x20, // size
0x73, 0x74, 0x73, 0x64, // stsd
0x01, // version
0x12, 0x34, 0x56, // flags
0x00, 0x00, 0x00, 0x01, // count
0x00, 0x00, 0x00, 0x10, // size
0x68, 0x65, 0x76, 0x31, // hev1
0x01, // version
0x12, 0x34, 0x56, // flags
0x00, 0x11, 0x22, 0x33, // payload
]);

const faked = shaka.media.ContentWorkarounds.fakeEncryption(hevc);
const spy = jasmine.createSpy('encvCallback');
new shaka.util.Mp4Parser()
.fullBox('stsd', shaka.util.Mp4Parser.sampleDescription)
.box('encv', /** @type {!Function} */ (spy))
.parse(faked);
expect(spy).toHaveBeenCalled();
});

it('Faked encryption on edge returns two init segments', () => {
const dummyInitSegmentBuffer = new ArrayBuffer(100);

Expand Down

0 comments on commit 342bb0d

Please sign in to comment.