Skip to content

Commit

Permalink
feat: Check encryptionScheme against MCap (#6484)
Browse files Browse the repository at this point in the history
Closes #1419
  • Loading branch information
avelad committed May 8, 2024
1 parent 4eb63ed commit ec29f82
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 34 deletions.
58 changes: 32 additions & 26 deletions lib/util/stream_utils.js
Expand Up @@ -927,38 +927,44 @@ shaka.util.StreamUtils = class {
}

if (audio) {
// See: https://github.com/shaka-project/shaka-player/issues/4659
if (info.audioRobustness != '') {
if (!keySystemConfig.audio) {
// KeySystemTrackConfiguration
keySystemConfig.audio = {
robustness: info.audioRobustness,
};
} else {
keySystemConfig.audio.robustness =
keySystemConfig.audio.robustness || info.audioRobustness;
}
} else if (!keySystemConfig.audio) {
if (!keySystemConfig.audio) {
// KeySystemTrackConfiguration
keySystemConfig.audio = {};
keySystemConfig.audio = {
encryptionScheme: info.encryptionScheme,
robustness: info.audioRobustness,
};
} else {
keySystemConfig.audio.encryptionScheme =
keySystemConfig.audio.encryptionScheme ||
info.encryptionScheme;
keySystemConfig.audio.robustness =
keySystemConfig.audio.robustness ||
info.audioRobustness;
}
// See: https://github.com/shaka-project/shaka-player/issues/4659
if (keySystemConfig.audio.robustness == '') {
delete keySystemConfig.audio.robustness;
}
}

if (video) {
// See: https://github.com/shaka-project/shaka-player/issues/4659
if (info.videoRobustness != '') {
if (!keySystemConfig.video) {
// KeySystemTrackConfiguration
keySystemConfig.video = {
robustness: info.videoRobustness,
};
} else {
keySystemConfig.video.robustness =
keySystemConfig.video.robustness || info.videoRobustness;
}
} else if (!keySystemConfig.video) {
if (!keySystemConfig.video) {
// KeySystemTrackConfiguration
keySystemConfig.video = {};
keySystemConfig.video = {
encryptionScheme: info.encryptionScheme,
robustness: info.videoRobustness,
};
} else {
keySystemConfig.video.encryptionScheme =
keySystemConfig.video.encryptionScheme ||
info.encryptionScheme;
keySystemConfig.video.robustness =
keySystemConfig.video.robustness ||
info.videoRobustness;
}
// See: https://github.com/shaka-project/shaka-player/issues/4659
if (keySystemConfig.video.robustness == '') {
delete keySystemConfig.video.robustness;
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -100,7 +100,7 @@
"prepublishOnly": "python build/checkversion.py && python build/all.py --force"
},
"dependencies": {
"eme-encryption-scheme-polyfill": "^2.1.1"
"eme-encryption-scheme-polyfill": "^2.1.2"
},
"engines": {
"node": ">=14"
Expand Down
5 changes: 5 additions & 0 deletions test/media/drm_engine_unit.js
Expand Up @@ -589,9 +589,11 @@ describe('DrmEngine', () => {
sessionTypes: ['persistent-license'],
initDataType: 'cenc',
audio: containing({
encryptionScheme: '',
robustness: 'good',
}),
video: containing({
encryptionScheme: '',
robustness: 'really_really_ridiculously_good',
}),
}),
Expand Down Expand Up @@ -621,6 +623,7 @@ describe('DrmEngine', () => {
drmInfos[0].persistentStateRequired = true;
drmInfos[0].audioRobustness = 'good';
drmInfos[0].videoRobustness = 'really_really_ridiculously_good';
drmInfos[0].encryptionScheme = 'bad';
});

config.advanced['drm.abc'] = {
Expand All @@ -647,9 +650,11 @@ describe('DrmEngine', () => {
keySystemConfiguration: containing({
keySystem: 'drm.abc',
audio: containing({
encryptionScheme: 'bad',
robustness: 'good',
}),
video: containing({
encryptionScheme: 'bad',
robustness: 'really_really_ridiculously_good',
}),
distinctiveIdentifier: 'required',
Expand Down

0 comments on commit ec29f82

Please sign in to comment.