Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable logic to decision to ignore duplicate init data #4572

Closed
Wayne-Morgan opened this issue Oct 12, 2022 · 2 comments · Fixed by #5853
Closed

Add configurable logic to decision to ignore duplicate init data #4572

Wayne-Morgan opened this issue Oct 12, 2022 · 2 comments · Fixed by #5853
Labels
priority: P3 Useful but not urgent status: archived Archived and locked; will not be updated type: enhancement New feature or request
Milestone

Comments

@Wayne-Morgan
Copy link
Contributor

Have you read the FAQ and checked for duplicate open issues?
Yes

Is your feature request related to a problem? Please describe.
DrmEngine.newInitData() decides whether to create a new session based on whether the initData has already been seen. We have some advanced DRM features which means sometimes we'd like to change this result to:

  • Force session creation regardless of whether we've already seen the initData
  • Prevent session creation regardless of whether we've seen the initData
  • follow the default behaviour

Describe the solution you'd like
We'd like to provide a function in the DRM configuration which will return one of the three options listed above (something like 'FORCE_CREATE', 'FORCE_IGNORE', or 'CHECK_FOR_DUPLICATE')
Parameters for the above function will include the initData for the keySystem, and the keyStatuses:

      let initDataAction = 'CHECK_FOR_DUPLICATE';
      if (this.config_.initDataIgnoreOverride) {
        // Need to find the initData for current keySystem
        const systemIds = shaka.media.DrmEngine.defaultSystemIds_;
        const keySystem = this.currentDrmInfo_.keySystem;
        const currentSystemId = systemIds.get(keySystem);
        const pssh = new shaka.util.Pssh(initData);
        if (pssh) {
          const index = pssh.systemIds.indexOf(currentSystemId);
          if (index >= 0) {
            const ksInitData = pssh.data[index];
            const keyStat = this.getKeyStatuses();
            initDataAction = this.config_.initDataIgnoreOverride(ksInitData, keyStat);
          }
        }
      }
      if (initDataAction === 'FORCE_IGNORE') {
        shaka.log.debug('Ignoring init data');
        return;
      }
      if (initDataAction === 'CHECK_FOR_DUPLICATE') {
        const metadatas = this.activeSessions_.values();
        for (const metadata of metadatas) {
          if (shaka.util.BufferUtils.equal(initData, metadata.initData)) {
            shaka.log.debug('Ignoring duplicate init data.');
            return;
          }
        }
      }
      // Either FORCE_CREATE or no duplicate found
      this.createSession(initDataType, initData,
          this.currentDrmInfo_.sessionType);

Describe alternatives you've considered
I can't think of an alternative, but would welcome any suggestions

Additional context

@Wayne-Morgan Wayne-Morgan added the type: enhancement New feature or request label Oct 12, 2022
@Wayne-Morgan
Copy link
Contributor Author

Reviewing the requirements once again, the 'FORCE_CREATE' is not necessary. We need the 'FORCE_IGNORE' and the 'CHECK_FOR_DUPLICATE'.

@github-actions github-actions bot added this to the Backlog milestone Oct 12, 2022
@avelad
Copy link
Member

avelad commented Oct 13, 2022

@Wayne-Morgan are you interested on send a PR for it? Thanks!

@avelad avelad added priority: P3 Useful but not urgent flag: seeking PR We are actively seeking PRs for this; we do not currently expect the core team will resolve this labels Oct 13, 2022
@avelad avelad removed the flag: seeking PR We are actively seeking PRs for this; we do not currently expect the core team will resolve this label Nov 3, 2023
@avelad avelad modified the milestones: Backlog, v4.6 Nov 3, 2023
Robloche pushed a commit to Robloche/shaka-player that referenced this issue Nov 30, 2023
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Jan 2, 2024
@shaka-project shaka-project locked as resolved and limited conversation to collaborators Jan 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: P3 Useful but not urgent status: archived Archived and locked; will not be updated type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants