Skip to content

Commit

Permalink
fix(FEC-10269): dash adapter overrides shaka DRM settings (#105)
Browse files Browse the repository at this point in the history
If shaka config already has some drm configuration (for example from the app configuration) override the config defaults with it
  • Loading branch information
RoyBregman committed Jul 2, 2020
1 parent a26b8a6 commit 466f688
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/dash-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
let config = {};
for (let drmProtocol of DashAdapter._availableDrmProtocol) {
drmProtocol.setDrmPlayback(config, this._sourceObj.drmData);
// If shaka config already has some drm configuration override the config defaults with it
if (this._config.shakaConfig.drm) {
Utils.Object.mergeDeep(config.drm, this._config.shakaConfig.drm);
}
Utils.Object.mergeDeep(this._config.shakaConfig, config);
}
}
Expand Down
32 changes: 31 additions & 1 deletion test/src/dash-adapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ describe('DashAdapter: targetBuffer', () => {
it('should check targetBuffer in VOD close to end of stream (time left to end of stream is less than targetBuffer)', done => {
try {
dashInstance = DashAdapter.createAdapter(video, vodSource, config);
video.addEventListener(EventType.PLAYING, () => {
dashInstance._eventManager.listenOnce(video, EventType.PLAYING, () => {
video.currentTime = video.duration - 1;
dashInstance._eventManager.listenOnce(video, EventType.SEEKED, () => {
dashInstance.targetBuffer.should.equal(video.duration - video.currentTime);
Expand Down Expand Up @@ -477,6 +477,36 @@ describe('DashAdapter: _getParsedTracks', () => {
});
});

describe('DashAdapter: check config overriding', () => {
let video, dashInstance, config;
const source = {
drmData: wwDrmData
};

beforeEach(() => {
video = document.createElement('video');
});

afterEach(done => {
dashInstance.destroy().then(() => {
dashInstance = null;
done();
});
});

after(() => {
TestUtils.removeVideoElementsFromTestPage();
});

it('should set drm security level to HW', done => {
config = {playback: {options: {html5: {dash: {drm: {advanced: {'com.widevine.alpha': {videoRobustness: 'HW_SECURE_ALL'}}}}}}}};
DashAdapter._availableDrmProtocol.push(Widevine);
dashInstance = DashAdapter.createAdapter(video, source, config);
dashInstance._config.shakaConfig.drm.advanced['com.widevine.alpha'].videoRobustness.should.equal('HW_SECURE_ALL');
done();
});
});

describe('DashAdapter: selectVideoTrack', () => {
let video, dashInstance, config;

Expand Down

0 comments on commit 466f688

Please sign in to comment.