-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
There are several situations in which it would be desirable to re-prepare ExoPlayer with a different media source while keeping the DrmSession from the previous prepare.
For example, there may be several different media sources which have the same DRM info or it is required to retry a failed playback.
In such cases not keeping the DrmSession would mean an extra license request, which takes time and consumes resources
We had a solution for this which in essence does the following:
defaultDrmSessionManager.prepare()
session = defaultDrmSessionManager.acquireSession()
// acquire session so we can keep it
session.acquire(null)
session.release(null)
defaultDrmSessionManager.release()
defaultDrmSessionManager.prepare()
defaultDrmSessionManager.release()
defaultDrmSessionManager.prepare()
// release the session when we do not need it anymore
session.release(null)
defaultDrmSessionManager.release()This worked as we expected it to in ExoPlayer 2.9.4, however, we recently upgraded to ExoPlayer 2.12.2 and this mechanism does not work anymore.
Two reasons why it is no longer working are both in 2.12.2's implementation of DefaultDrmSessionManager.release():
a) when a DefaultDrmSessionManager is constructed with sessionKeepaliveMs == C.TIME_UNSET
calling DefaultDrmSessionManager.release() releases DrmSessions which it did not acquire.
b) DefaultDrmSessionManager.release() releases DrmSessions, however it does not forget them -- they are still kept in the
DefaultDrmSessionManager.sessions list.
The sequence of
defaultDrmSessionManager.prepare()
defaultDrmSessionManager.release()always releases the DrmSession objects which are stored in the sessions list, while it does not acquire them (in the same sequence) and this eventually causes a license request (or IllegalStateException).