mirror of
https://github.com/samsonjs/media.git
synced 2026-04-04 11:05:47 +00:00
Tweak DefaultDrmSession acquire & release event behaviour
The new behaviour: - If the session is successfully opened, an acquire event is dispatched to all attached dispatchers. - If acquire() is called but the session is already open, the acquire event is dispatched only to the dispatcher provided in to acquire() - If the session is successfully released, a release event is dispatched to all attached dispatchers (in theory at most one should ever be attached at this point). - If release() is called but the session isn't released (because referenceCount > 0) then a release event is dispatched only to the dispatcher provided to release(). PiperOrigin-RevId: 312062422
This commit is contained in:
parent
b667a0e7e2
commit
786edf8ecd
1 changed files with 11 additions and 6 deletions
|
|
@ -273,13 +273,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
if (openInternal(true)) {
|
||||
doLicense(true);
|
||||
}
|
||||
} else {
|
||||
} else if (eventDispatcher != null && isOpen()) {
|
||||
// If the session is already open then send the acquire event only to the provided dispatcher.
|
||||
// TODO: Add a parameter to onDrmSessionAcquired to indicate whether the session is being
|
||||
// re-used or not.
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.dispatch(
|
||||
DrmSessionEventListener::onDrmSessionAcquired, DrmSessionEventListener.class);
|
||||
}
|
||||
eventDispatcher.dispatch(
|
||||
DrmSessionEventListener::onDrmSessionAcquired, DrmSessionEventListener.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -302,9 +301,15 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
sessionId = null;
|
||||
}
|
||||
releaseCallback.onSessionReleased(this);
|
||||
dispatchEvent(DrmSessionEventListener::onDrmSessionReleased);
|
||||
}
|
||||
dispatchEvent(DrmSessionEventListener::onDrmSessionReleased);
|
||||
if (eventDispatcher != null) {
|
||||
if (isOpen()) {
|
||||
// If the session is still open then send the release event only to the provided dispatcher
|
||||
// before removing it.
|
||||
eventDispatcher.dispatch(
|
||||
DrmSessionEventListener::onDrmSessionReleased, DrmSessionEventListener.class);
|
||||
}
|
||||
eventDispatchers.remove(eventDispatcher);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue