Skip to content

Commit

Permalink
fix: Support for Zenterio (#6717)
Browse files Browse the repository at this point in the history
Few bugfixes to support DT Zenterio platform:
- Zenterio seems to have a problem with the EME onKeyStatus event payload (the key statuses map), where the map key ID comes in as empty. This is not correct based on the EME spec:
https://w3c.github.io/encrypted-media/#dom-mediakeysession-keystatuses
- Add polyfills that are used to fix issues with older webkits, same as for older safari browsers
  • Loading branch information
tykus160 authored Jun 3, 2024
1 parent a7dc138 commit 97910dc
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
9 changes: 8 additions & 1 deletion lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -7115,14 +7115,21 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
shaka.util.FakeEvent.EventName.KeyStatusChanged);
this.dispatchEvent(event);

const keyIds = Object.keys(keyStatusMap);
let keyIds = Object.keys(keyStatusMap);
if (keyIds.length == 0) {
shaka.log.warning(
'Got a key status event without any key statuses, so we don\'t ' +
'know the real key statuses. If we don\'t have all the keys, ' +
'you\'ll need to set restrictions so we don\'t select those tracks.');
}

// Non-standard version of global key status. Modify it to match standard
// behavior.
if (keyIds.length == 1 && keyIds[0] == '') {
keyIds = ['00'];
keyStatusMap = {'00': keyStatusMap['']};
}

// If EME is using a synthetic key ID, the only key ID is '00' (a single 0
// byte). In this case, it is only used to report global success/failure.
// See note about old platforms in: https://bit.ly/2tpez5Z
Expand Down
12 changes: 12 additions & 0 deletions lib/polyfill/mediasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ shaka.polyfill.MediaSource = class {
// Bug filed: https://bugs.webkit.org/show_bug.cgi?id=165342
shaka.polyfill.MediaSource.stubAbort_();
}
} else if (shaka.util.Platform.isZenterio()) {
// Zenterio uses WPE based on Webkit 607.x.x which do not correctly
// implement abort() on SourceBuffer.
// Calling abort() before appending a segment causes that segment to be
// incomplete in the buffer.
// Bug filed: https://bugs.webkit.org/show_bug.cgi?id=165342
shaka.polyfill.MediaSource.stubAbort_();
// If you remove up to a keyframe, Webkit 607.x.x incorrectly will also
// remove that keyframe and the content up to the next.
// Offsetting the end of the removal range seems to help.
// Bug filed: https://bugs.webkit.org/show_bug.cgi?id=177884
shaka.polyfill.MediaSource.patchRemovalRange_();
} else if (shaka.util.Platform.isTizen2() ||
shaka.util.Platform.isTizen3() ||
shaka.util.Platform.isTizen4()) {
Expand Down
13 changes: 11 additions & 2 deletions lib/util/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ shaka.util.Platform = class {
!shaka.util.Platform.isOrange() &&
!shaka.util.Platform.isPS4() &&
!shaka.util.Platform.isAmazonFireTV() &&
!shaka.util.Platform.isWPE();
!shaka.util.Platform.isWPE() &&
!shaka.util.Platform.isZenterio();
}

/**
Expand Down Expand Up @@ -362,6 +363,14 @@ shaka.util.Platform = class {
return shaka.util.Platform.userAgentContains_('WPE');
}

/**
* Check if the current platform is Deutsche Telecom Zenterio STB.
* @return {boolean}
*/
static isZenterio() {
return shaka.util.Platform.userAgentContains_('DT_STB_BCM');
}

/**
* Returns a major version number for Safari, or Safari-based iOS browsers.
*
Expand Down Expand Up @@ -519,7 +528,7 @@ shaka.util.Platform = class {
Platform.isEOS() || Platform.isAPL() ||
Platform.isVirginMedia() || Platform.isOrange() ||
Platform.isWPE() || Platform.isChromecast() ||
Platform.isHisense()) {
Platform.isHisense() || Platform.isZenterio()) {
return true;
}
return false;
Expand Down
24 changes: 24 additions & 0 deletions test/player_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3398,6 +3398,30 @@ describe('Player', () => {
expect(tracks.length).toBe(2);
});

it('doesn\'t remove when using empty map key status event', async () => {
manifest = shaka.test.ManifestGenerator.generate((manifest) => {
manifest.addVariant(0, (variant) => {
variant.addVideo(1, (stream) => {
stream.keyIds = new Set(['abc']);
stream.size(10, 10);
});
});
manifest.addVariant(2, (variant) => {
variant.addVideo(3, (stream) => {
stream.size(20, 20);
});
});
});

await player.load(fakeManifestUri, 0, fakeMimeType);
expect(player.getVariantTracks().length).toBe(2);

// Empty key status event map ID.
onKeyStatus({'': 'usable'});

expect(player.getVariantTracks().length).toBe(2);
});

it('doesn\'t remove when using synthetic key status', async () => {
manifest = shaka.test.ManifestGenerator.generate((manifest) => {
manifest.addVariant(0, (variant) => {
Expand Down

0 comments on commit 97910dc

Please sign in to comment.