ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

DRM - Fetch keys ahead of the playback position

Open ojw28 opened this issue 8 years ago • 11 comments

Spun out from #3780. The issue is as described in the title.

ojw28 avatar Apr 16 '18 17:04 ojw28

Randomly getting the error "Error decrypting data: requested key has not been loaded" using DefaultDrmSessionManager even after setting multiSession=true. Exoplayer version 2.9.1

E/ExoPlayerImplInternal: Playback error.
    com.google.android.exoplayer2.ExoPlaybackException: android.media.MediaCodec$CryptoException: Error decrypting data: requested key has not been loaded
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:1025)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:664)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:536)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:303)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:154)
        at android.os.HandlerThread.run(HandlerThread.java:61)

vinay-altbalaji avatar Nov 23 '18 06:11 vinay-altbalaji

@vinay-altbalaji That sounds like a content issue rather than anything related to this one. Marking off topic. Please file a new issue containing complete information as requested in the issue template if you wish for us to take a look. We cannot investigate your issues without test media and clear reproduction steps.

ojw28 avatar Nov 23 '18 19:11 ojw28

Useful background: https://exoplayer.dev/drm.html

This issue can occur where key rotation is present in the media, where the media consists of different quality streams with different keys, and when playing playlists containing DRM protected content.

The problem is that DRM keys are only requested at the point of playback. The solution will be to request them earlier (e.g. one option is to request them at the point of buffering).

ojw28 avatar Aug 28 '19 08:08 ojw28

@AquilesCanta - This seems affecting our playback experience too. Please let me know if you need any help with test streams. Thanks.

juechemparathy avatar Sep 03 '19 06:09 juechemparathy

@AquilesCanta Do you consider the key rotation stream which the pssh is only in segment? some encoder/packager won't put the pssh in mpd for live key rotation stream so you can't fetch license in the MediaSource. To be able to retrieve license earlier maybe trigger the license request after demuxing before rendering?

AchibanaUkyo avatar Sep 03 '19 08:09 AchibanaUkyo

We are working on other DRM improvements at the moment, please be patient. A commit will appear below once we push something to the dev-branch.

AquilesCanta avatar Sep 03 '19 10:09 AquilesCanta

To be able to retrieve license earlier maybe trigger the license request after demuxing before rendering

@AchibanaUkyo That's what we intend to do.

AquilesCanta avatar Sep 03 '19 10:09 AquilesCanta

Hello! Is there somewhere a work-in-progress branch? I'm implementing server side DAI for live DASH streams (multi period). When player is switching from advert period (non DRM) to content period (DRM Widevine) I can see a short buffering (around 1 sec).

Time is of the essence here and I'm wondering how I could fix that by myself. Could you give me possible solutions or point me into right direction?

rafakob avatar Oct 29 '19 14:10 rafakob

We are working on other DRM improvements at the moment, please be patient. A commit will appear below once we push something to the dev-branch.

Hello, Do you have a date estimate of when the update will be committed? Thank you.

seanvi24 avatar Oct 30 '19 20:10 seanvi24

We haven't implemented key pre-fetching, but 316f8a8 implements session keepalive inside the DefaultDrmSessionManager. By default sessions are kept for 5 minutes after the last 'release' - this can be customised with DefaultDrmSessionManager.Builder#setSessionKeepaliveMs(long).

This is enough to bridge a clear ad-break, so if the content before and after the ad is encrypted with the same keys then the session should now be re-used after the ad (e.g https://github.com/google/ExoPlayer/issues/4133#issuecomment-547446450). This doesn't help for content with key rotation - so I'll keep the issue open to track implementing proper key-prefetching.

This is available on the dev-v2 branch - please try it out and let us know if you spot any problems!

icbaker avatar Jul 03 '20 13:07 icbaker

This is now implemented on the dev-v2 branch - it will be included in the next major release.

I'd appreciate it if people could try it out and report any issues they observe.

icbaker avatar Mar 12 '21 10:03 icbaker