Skip to content

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

@icbaker
Copy link
Collaborator

icbaker commented Feb 26, 2025

Closing this - see #2048 (comment) for the app-side solution we settled on without any changes to the library.

@icbaker icbaker closed this Feb 26, 2025
@androidx androidx locked and limited conversation to collaborators Apr 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants