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

Support Multi-Key Content with Key Rotation While Ensuring Seamless Track Switching #2271

Open
ggabdol opened this issue Mar 26, 2025 · 2 comments

Comments

@ggabdol
Copy link

ggabdol commented Mar 26, 2025

I apologize if this question has been asked before. I searched for similar issues but couldn’t find an exact answer or may not have fully understood previous discussions.

I am trying to support multi-key HLS linear content with key rotation while ensuring seamless track switching.
As per the, Digital rights management - Key rotation

To play streams with rotating keys, pass true to MediaItem.DrmConfiguration.Builder.setMultiSession when building the media item.

I enabled DRM MultiSession mode to support key rotation, with my license server configured according to Case 2: License server responds with requested key only. However, because ExoPlayer only requests a license for the key associated with the currently selected track, I observed that playback freezes or experiences rebuffering during track switching while fetching the key for the selected track.

To avoid this issue, I reconfigured my license server following Case 1: License server responds with all keys for the content. While this prevents freezing during track switching, key rotation no longer works since all keys are provided upfront.

I have a few ideas to customize ExoPlayer to handle both scenarios, but before implementing any workarounds, I wanted to check if there is an official simple solution for this use case.

Any guidance would be greatly appreciated. Thank you!

@stevemayhew
Copy link
Contributor

I would be interested to see your ideas... ExoPlayer would need to know all the tracks were not covered by a single license request. I think, in practice, this would be very difficult as all the init segments from all the tracks would need to be read in order to resolve the final DrmInitData and issue multiple license requests.

The docs make this pretty clear:

Where possible, we recommend configuring your license server to behave in this way. It's the most efficient and robust way to support playback of multikey content, because it doesn't require the client to make multiple license requests to access the different streams.

I'm curious why you say this:

While this prevents freezing during track switching, key rotation no longer works since all keys are provided upfront.

I'm confused how this matters? All the keys for each track are provided up front, but not for all time ranges?

See my question (which I answered myself) as to the difference between key and license rotation: #1048

@nkrview
Copy link

nkrview commented Mar 28, 2025

Hi @stevemayhew I am facing the similar issue, where DRM server is responding with all keys, but stream is not playing and Player is throwing crypto key not available, While the thrown key is available when I check on entitlement_message used to generate license token on DRM server. and the same stream is playable on https://vtb.axinom.com/dash.html.

Can you please advice. below is the log and exoplayer DRM code:

if (isDRMEnabled) {
val drmUuid = C.WIDEVINE_UUID //Util.getDrmUuid("widevine");
if (drmUuid != null) {

            val requestHeaders =
                mapOf(context.getString(R.string.drm_token_key_axinom) to licenseToken.toString())
            val drmConfiguration = DrmConfiguration.Builder(drmUuid)
                .setLicenseRequestHeaders(requestHeaders)
                .setLicenseUri(licenseUrl)
                .setMultiSession(true)
                .setForceDefaultLicenseUri(false)   // Ensure it fetches new keys
                .setPlayClearContentWithoutKey(true)  // Prevent crashes during rotation
                .build()
            mediaItemBuilder.setDrmConfiguration(drmConfiguration)
        }

    }

Logs FIle: firetv.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants