Skip to content

Commit 9e2a17f

Browse files
aveladjoeyparrish
authored andcommitted
fix: Fix DRM workaround with fLaC and Opus boxes (#8070)
Backported to v4.9.x
1 parent 79e47af commit 9e2a17f

File tree

2 files changed

+33
-72
lines changed

2 files changed

+33
-72
lines changed

lib/media/content_workarounds.js

Lines changed: 31 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ shaka.media.ContentWorkarounds = class {
5858
/** @type {!Array.<{box: shaka.extern.ParsedBox, newType: number}>} */
5959
const boxesToModify = [];
6060

61+
const pushEncv = (box) => {
62+
boxesToModify.push({
63+
box,
64+
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
65+
});
66+
};
67+
68+
const pushEnca = (box) => {
69+
boxesToModify.push({
70+
box,
71+
newType: ContentWorkarounds.BOX_TYPE_ENCA_,
72+
});
73+
};
74+
6175
new shaka.util.Mp4Parser()
6276
.box('moov', onSimpleAncestorBox)
6377
.box('trak', onSimpleAncestorBox)
@@ -71,78 +85,23 @@ shaka.media.ContentWorkarounds = class {
7185
})
7286
.fullBox('encv', onEncryptionMetadataBox)
7387
.fullBox('enca', onEncryptionMetadataBox)
74-
.fullBox('dvav', (box) => {
75-
boxesToModify.push({
76-
box,
77-
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
78-
});
79-
})
80-
.fullBox('dva1', (box) => {
81-
boxesToModify.push({
82-
box,
83-
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
84-
});
85-
})
86-
.fullBox('dvh1', (box) => {
87-
boxesToModify.push({
88-
box,
89-
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
90-
});
91-
})
92-
.fullBox('dvhe', (box) => {
93-
boxesToModify.push({
94-
box,
95-
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
96-
});
97-
})
98-
.fullBox('hev1', (box) => {
99-
boxesToModify.push({
100-
box,
101-
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
102-
});
103-
})
104-
.fullBox('hvc1', (box) => {
105-
boxesToModify.push({
106-
box,
107-
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
108-
});
109-
})
110-
.fullBox('avc1', (box) => {
111-
boxesToModify.push({
112-
box,
113-
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
114-
});
115-
})
116-
.fullBox('avc3', (box) => {
117-
boxesToModify.push({
118-
box,
119-
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
120-
});
121-
})
122-
.fullBox('ac-3', (box) => {
123-
boxesToModify.push({
124-
box,
125-
newType: ContentWorkarounds.BOX_TYPE_ENCA_,
126-
});
127-
})
128-
.fullBox('ec-3', (box) => {
129-
boxesToModify.push({
130-
box,
131-
newType: ContentWorkarounds.BOX_TYPE_ENCA_,
132-
});
133-
})
134-
.fullBox('ac-4', (box) => {
135-
boxesToModify.push({
136-
box,
137-
newType: ContentWorkarounds.BOX_TYPE_ENCA_,
138-
});
139-
})
140-
.fullBox('mp4a', (box) => {
141-
boxesToModify.push({
142-
box,
143-
newType: ContentWorkarounds.BOX_TYPE_ENCA_,
144-
});
145-
}).parse(initSegment);
88+
.fullBox('dvav', pushEncv)
89+
.fullBox('dva1', pushEncv)
90+
.fullBox('dvh1', pushEncv)
91+
.fullBox('dvhe', pushEncv)
92+
.fullBox('dvc1', pushEncv)
93+
.fullBox('dvi1', pushEncv)
94+
.fullBox('hev1', pushEncv)
95+
.fullBox('hvc1', pushEncv)
96+
.fullBox('avc1', pushEncv)
97+
.fullBox('avc3', pushEncv)
98+
.fullBox('ac-3', pushEnca)
99+
.fullBox('ec-3', pushEnca)
100+
.fullBox('ac-4', pushEnca)
101+
.fullBox('Opus', pushEnca)
102+
.fullBox('fLaC', pushEnca)
103+
.fullBox('mp4a', pushEnca)
104+
.parse(initSegment);
146105

147106
if (isEncrypted) {
148107
shaka.log.debug('Init segment already indicates encryption.');

test/media/content_workarounds_unit.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ describe('ContentWorkarounds', () => {
2424
'ac-3',
2525
'ec-3',
2626
'ac-4',
27+
'Opus',
28+
'fLaC',
2729
'mp4a',
2830
],
2931
};

0 commit comments

Comments
 (0)