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

DrmSession Caching Proposal #2049

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stevemayhew
Copy link
Contributor

This series of commits implements extending the functionality of the DefaultDrmSessionManagersetSessionKeepaliveMs() to allow keeping open MediaDrm sessions beyond the live time of any one MediaSource

Our fork of ExoPlayer is using this implementation to support a large live channel lineup while reducing the tune load on the DRM License Server significantly (we see hit ratios over 50% on AmLogic hardware).

The related issue Is #2048

One improvement would be to add a "player release listener" API to ExoPlayer to allow automatically calling the releaseAllSessions() method on DefaultDrmSessionManager rather than requiring the application to do this manually.

The `DefaultDrmSessionManager` releases all keep-alive DrmSessions after the
`MediaSource` is released, as such the only way to preserve keep-alive sessions
from one `MediaItem` playback to the next is to use `Playlist`'s.

`Playlist' is not practical for a large live channel set for a couple of
reasons:

1. Keeping the `MediaSource` active consumes considerable memory
2. Polling of the MPD/HLS Playlist continues for all `MediaItems` that have ever played in the playlist.

This change is conceptually quite simple:

1. Preserve the active list of cached `DrmSession` when `DrmSessionManager.release()` called
2. Add a method that can be used on `Activity.onStop()` to release the cached `DrmSession`'s

This new behavior is guarded by a setting that defaults to the old behavior.

This commit also includes a fix to remove `preacquiredSessionReferences` when their associated session is fully
released (to avoid the logged error message for `referenceCount` < 0)
Adds basic DrmSession logging for
     1. `DrmSession` acquire is a cache hit
     2. If resource issues require flushing the `DrmSession` cache
     3. When sessions are expired from the cache
@stevemayhew
Copy link
Contributor Author

This is also a possible solution for issue #394

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.

2 participants