Skip to content

Commit 9461bc2

Browse files
feat(HLS): Add an option to ignore DRM info (#7986)
Fixes #7985. --------- Co-authored-by: Álvaro Velad Galván <[email protected]>
1 parent 35066b0 commit 9461bc2

File tree

8 files changed

+70
-16
lines changed

8 files changed

+70
-16
lines changed

demo/config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,14 @@ shakaDemo.Config = class {
227227
.addBoolInput_('Ignore supplemental codecs',
228228
'manifest.ignoreSupplementalCodecs')
229229
.addNumberInput_('Override the Update time of the manifest',
230-
'manifest.updatePeriod');
230+
'manifest.updatePeriod')
231+
.addBoolInput_('Ignore DRM Info', 'manifest.ignoreDrmInfo');
231232
}
232233

233234
/** @private */
234235
addDashManifestSection_() {
235236
const docLink = this.resolveExternLink_('.ManifestConfiguration');
236237
this.addSection_('DASH Manifest', docLink)
237-
.addBoolInput_('Ignore DASH DRM Info', 'manifest.dash.ignoreDrmInfo')
238238
.addBoolInput_('Auto-Correct DASH Drift',
239239
'manifest.dash.autoCorrectDrift')
240240
.addBoolInput_('Disable Xlink processing',

externs/shaka/player.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,6 @@ shaka.extern.xml.Node;
10801080
/**
10811081
* @typedef {{
10821082
* clockSyncUri: string,
1083-
* ignoreDrmInfo: boolean,
10841083
* disableXlinkProcessing: boolean,
10851084
* xlinkFailGracefully: boolean,
10861085
* ignoreMinBufferTime: boolean,
@@ -1104,12 +1103,6 @@ shaka.extern.xml.Node;
11041103
* URI will be used to determine the current time.
11051104
* <br>
11061105
* Defaults to <code>''</code>.
1107-
* @property {boolean} ignoreDrmInfo
1108-
* If true will cause DASH parser to ignore DRM information specified
1109-
* by the manifest and treat it as if it signaled no particular key
1110-
* system and contained no init data.
1111-
* <br>
1112-
* Defaults to <code>false</code>.
11131106
* @property {boolean} disableXlinkProcessing
11141107
* If true, xlink-related processing will be disabled.
11151108
* <br>
@@ -1355,7 +1348,8 @@ shaka.extern.MssManifestConfiguration;
13551348
* raiseFatalErrorOnManifestUpdateRequestFailure: boolean,
13561349
* continueLoadingWhenPaused: boolean,
13571350
* ignoreSupplementalCodecs: boolean,
1358-
* updatePeriod: number
1351+
* updatePeriod: number,
1352+
* ignoreDrmInfo: boolean
13591353
* }}
13601354
*
13611355
* @property {shaka.extern.RetryParameters} retryParameters
@@ -1436,6 +1430,12 @@ shaka.extern.MssManifestConfiguration;
14361430
* trigger a new download of the manifest.
14371431
* <br>
14381432
* Defaults to <code>-1</code>.
1433+
* @property {boolean} ignoreDrmInfo
1434+
* If true will cause DASH/HLS parser to ignore DRM information specified
1435+
* by the manifest and treat it as if it signaled no particular key
1436+
* system and contained no init data.
1437+
* <br>
1438+
* Defaults to <code>false</code>.
14391439
* @exportDoc
14401440
*/
14411441
shaka.extern.ManifestConfiguration;

lib/dash/dash_parser.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,7 @@ shaka.dash.DashParser = class {
19641964
TXml.findChildren(elem, 'ContentProtection');
19651965
const contentProtection = ContentProtection.parseFromAdaptationSet(
19661966
contentProtectionElements,
1967-
this.config_.dash.ignoreDrmInfo,
1967+
this.config_.ignoreDrmInfo,
19681968
this.config_.dash.keySystemsByURI);
19691969

19701970
const language = shaka.util.LanguageUtils.normalize(
@@ -2295,7 +2295,7 @@ shaka.dash.DashParser = class {
22952295
TXml.findChildren(node, 'ContentProtection');
22962296
const keyId = shaka.dash.ContentProtection.parseFromRepresentation(
22972297
contentProtectionElements, contentProtection,
2298-
this.config_.dash.ignoreDrmInfo,
2298+
this.config_.ignoreDrmInfo,
22992299
this.config_.dash.keySystemsByURI);
23002300
const keyIds = new Set(keyId ? [keyId] : []);
23012301

lib/hls/hls_parser.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ shaka.hls.HlsParser = class {
15841584
// EXT-X-SESSION-KEY processing
15851585
const drmInfos = [];
15861586
const keyIds = new Set();
1587-
if (sessionKeyTags.length > 0) {
1587+
if (!this.config_.ignoreDrmInfo && sessionKeyTags.length > 0) {
15881588
for (const drmTag of sessionKeyTags) {
15891589
const method = drmTag.getRequiredAttrValue('METHOD');
15901590
// According to the HLS spec, KEYFORMAT is optional and implicitly
@@ -3189,7 +3189,7 @@ shaka.hls.HlsParser = class {
31893189
async parseDrmInfo_(playlist, mimeType, getUris, variables) {
31903190
/** @type {!Map<!shaka.hls.Tag, ?shaka.media.InitSegmentReference>} */
31913191
const drmTagsMap = new Map();
3192-
if (playlist.segments) {
3192+
if (!this.config_.ignoreDrmInfo && playlist.segments) {
31933193
for (const segment of playlist.segments) {
31943194
const segmentKeyTags = shaka.hls.Utils.filterTagsByName(segment.tags,
31953195
'EXT-X-KEY');

lib/player.js

+11
Original file line numberDiff line numberDiff line change
@@ -4115,6 +4115,17 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
41154115
delete config['manifest']['hls']['updatePeriod'];
41164116
}
41174117

4118+
// Deprecate 'manifest.dash.ignoreDrmInfo' configuration.
4119+
if (config['manifest'] && config['manifest']['dash'] &&
4120+
'ignoreDrmInfo' in config['manifest']['dash']) {
4121+
shaka.Deprecate.deprecateFeature(5,
4122+
'manifest.dash.ignoreDrmInfo configuration',
4123+
'Please Use manifest.ignoreDrmInfo instead.');
4124+
config['manifest']['ignoreDrmInfo'] =
4125+
config['manifest']['dash']['ignoreDrmInfo'];
4126+
delete config['manifest']['dash']['ignoreDrmInfo'];
4127+
}
4128+
41184129
// Deprecate AdvancedDrmConfiguration's videoRobustness and audioRobustness
41194130
// as a string. It's now an array of strings.
41204131
if (config['drm'] && config['drm']['advanced']) {

lib/util/player_configuration.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ shaka.util.PlayerConfiguration = class {
128128
continueLoadingWhenPaused: true,
129129
ignoreSupplementalCodecs: false,
130130
updatePeriod: -1,
131+
ignoreDrmInfo: false,
131132
dash: {
132133
clockSyncUri: '',
133-
ignoreDrmInfo: false,
134134
disableXlinkProcessing: true,
135135
xlinkFailGracefully: false,
136136
ignoreMinBufferTime: false,

test/dash/dash_parser_content_protection_unit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('DashParser ContentProtection', () => {
2929
const dashParser = new shaka.dash.DashParser();
3030

3131
const config = shaka.util.PlayerConfiguration.createDefault().manifest;
32-
config.dash.ignoreDrmInfo = ignoreDrmInfo || false;
32+
config.ignoreDrmInfo = ignoreDrmInfo || false;
3333
dashParser.configure(config);
3434

3535
const playerInterface = {

test/hls/hls_parser_unit.js

+43
Original file line numberDiff line numberDiff line change
@@ -3714,6 +3714,49 @@ describe('HlsParser', () => {
37143714
}
37153715
});
37163716

3717+
it('does not construct DrmInfo with ignoreDrmInfo = true', async () => {
3718+
const master = [
3719+
'#EXTM3U\n',
3720+
'#EXT-X-STREAM-INF:BANDWIDTH=200,CODECS="avc1.4d401f",',
3721+
'RESOLUTION=960x540,FRAME-RATE=60\n',
3722+
'video\n',
3723+
].join('');
3724+
3725+
const initDataBase64 =
3726+
'dGhpcyBpbml0IGRhdGEgY29udGFpbnMgaGlkZGVuIHNlY3JldHMhISE=';
3727+
3728+
const keyId = 'abc123';
3729+
3730+
const media = [
3731+
'#EXTM3U\n',
3732+
'#EXT-X-TARGETDURATION:6\n',
3733+
'#EXT-X-PLAYLIST-TYPE:VOD\n',
3734+
'#EXT-X-KEY:METHOD=SAMPLE-AES-CTR,',
3735+
'KEYID=0X' + keyId + ',',
3736+
'KEYFORMAT="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",',
3737+
'URI="data:text/plain;base64,',
3738+
initDataBase64, '",\n',
3739+
'#EXT-X-MAP:URI="init.mp4"\n',
3740+
'#EXTINF:5,\n',
3741+
'#EXT-X-BYTERANGE:121090@616\n',
3742+
'main.mp4',
3743+
].join('');
3744+
3745+
const manifest = shaka.test.ManifestGenerator.generate((manifest) => {
3746+
manifest.anyTimeline();
3747+
manifest.addPartialVariant((variant) => {
3748+
variant.addPartialStream(ContentType.VIDEO, (stream) => {
3749+
});
3750+
});
3751+
manifest.sequenceMode = sequenceMode;
3752+
manifest.type = shaka.media.ManifestParser.HLS;
3753+
});
3754+
3755+
config.ignoreDrmInfo = true;
3756+
await testHlsParser(master, media, manifest);
3757+
expect(newDrmInfoSpy).not.toHaveBeenCalled();
3758+
});
3759+
37173760
it('constructs DrmInfo for Widevine', async () => {
37183761
const master = [
37193762
'#EXTM3U\n',

0 commit comments

Comments
 (0)