Skip to content

Commit

Permalink
feat: Add config to ignore duplicate init data (#5853)
Browse files Browse the repository at this point in the history
Closes #4572
  • Loading branch information
avelad committed Nov 3, 2023
1 parent b39f334 commit acf23f8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion demo/config.js
Expand Up @@ -128,7 +128,9 @@ shakaDemo.Config = class {
/* canBeUnset= */ true)
.addBoolInput_('Parse inband "pssh" from media segments',
'drm.parseInbandPsshEnabled')
.addTextInput_('Min HDCP version', 'drm.minHdcpVersion');
.addTextInput_('Min HDCP version', 'drm.minHdcpVersion')
.addBoolInput_('Ignore duplicate init data',
'drm.ignoreDuplicateInitData');
const advanced = shakaDemoMain.getConfiguration().drm.advanced || {};
const addDRMAdvancedField = (name, valueName, suggestions) => {
// All advanced fields of a given type are set at once.
Expand Down
10 changes: 8 additions & 2 deletions externs/shaka/player.js
Expand Up @@ -757,7 +757,8 @@ shaka.extern.PersistentSessionMetadata;
* preferredKeySystems: !Array.<string>,
* keySystemsMapping: !Object.<string, string>,
* parseInbandPsshEnabled: boolean,
* minHdcpVersion: string
* minHdcpVersion: string,
* ignoreDuplicateInitData: boolean
* }}
*
* @property {shaka.extern.RetryParameters} retryParameters
Expand Down Expand Up @@ -813,7 +814,12 @@ shaka.extern.PersistentSessionMetadata;
* <i>By default (''), do not check the HDCP version.</i><br>
* Indicates the minimum version of HDCP to start the playback of encrypted
* streams. <b>May be ignored if not supported by the device.</b>
*
* @property {boolean} ignoreDuplicateInitData
* <i>Defaults to false on Tizen 2, and true for all other browsers.</i><br>
* When true indicate that the player doesn't ignore duplicate init data.
* Note: Tizen 2015 and 2016 models will send multiple webkitneedkey events
* with the same init data. If the duplicates are supressed, playback
* will stall without errors.
* @exportDoc
*/
shaka.extern.DrmConfiguration;
Expand Down
5 changes: 1 addition & 4 deletions lib/media/drm_engine.js
Expand Up @@ -715,11 +715,8 @@ shaka.media.DrmEngine = class {

const metadatas = this.activeSessions_.values();
for (const metadata of metadatas) {
// Tizen 2015 and 2016 models will send multiple webkitneedkey events
// with the same init data. If the duplicates are supressed, playback
// will stall without errors.
if (shaka.util.BufferUtils.equal(initData, metadata.initData) &&
!shaka.util.Platform.isTizen2()) {
this.config_.ignoreDuplicateInitData) {
shaka.log.debug('Ignoring duplicate init data.');
return;
}
Expand Down
1 change: 1 addition & 0 deletions lib/util/player_configuration.js
Expand Up @@ -91,6 +91,7 @@ shaka.util.PlayerConfiguration = class {
// segments to detect key changes.
parseInbandPsshEnabled: shaka.util.Platform.isXboxOne(),
minHdcpVersion: '',
ignoreDuplicateInitData: !shaka.util.Platform.isTizen2(),
};

const manifest = {
Expand Down

0 comments on commit acf23f8

Please sign in to comment.