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

fix: Multivariant HLS manifests don't work with DRM #7775

Conversation

gmcgarry
Copy link
Contributor

@gmcgarry gmcgarry commented Dec 18, 2024

For Reference, DASH manifest is: https://content.media24.link/hls/flicker84/playready/manifest.mpd

Problematic HLS manifests:

PlayReady: https://content.media24.link/hls/flicker84/playready/master.m3u8
FairPlay: https://content.media24.link/hls/flicker84/fairplay/master.m3u8

This specifically happened with a test for supplemental codecs, because the implementation of HLS SUPPLEMENTAL-CODECS duplicates the variant for all the supplemental codecs. But the same behaviour could be done by explicitly providing multiple variants in the manifest.

The problematic code is in lib/hls/hls_parser.js, method parseManifest_():

    if (variants.length == 1) {
      const createSegmentIndexPromises = [];
      const variant = variants[0];
      for (const stream of [variant.video, variant.audio]) {
        if (stream && !stream.segmentIndex) {
          createSegmentIndexPromises.push(stream.createSegmentIndex());
        }
      }
      if (createSegmentIndexPromises.length > 0) {
        await Promise.all(createSegmentIndexPromises);
      }
    }

This code will only invoke stream.createSegmentIndex() when one variant is available. If it isn't invoked, then the download of the media manifest is deferred, the EXT-X-KEY in the media manifest is not parsed and the code in shaka.media.PreloadManager.initializeDrmInner() never detects any DrmInfos.

Not sure why this code is only invoked if one variant is available. Maybe an optimisation in the common case, which is now a required code path.

…T-X-KEY attribute to get the variant drmInfos early.
@shaka-bot
Copy link
Collaborator

Incremental code coverage: 100.00%

@avelad
Copy link
Member

avelad commented Dec 20, 2024

I'm not convinced by this solution... I'll think of a better solution.

@avelad
Copy link
Member

avelad commented Dec 20, 2024

@gmcgarry I have seen that your content is generated with Shaka Packager, use the --create_session_keys option for it to work correctly. Can you tell me if that works for you without any changes? Thanks!

avelad added a commit that referenced this pull request Dec 23, 2024
@avelad avelad added the status: waiting on response Waiting on a response from the reporter(s) of the issue label Dec 23, 2024
@shaka-bot
Copy link
Collaborator

Closing due to inactivity. If the author would like to continue this PR, they can reopen it (preferred) or start a new one (if needed).

@shaka-bot shaka-bot closed this Dec 30, 2024
@shaka-bot shaka-bot removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants