diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/ExoMediaDrm.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/ExoMediaDrm.java index ca776267aa..e11656509d 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/ExoMediaDrm.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/ExoMediaDrm.java @@ -33,9 +33,20 @@ import java.util.UUID; */ public interface ExoMediaDrm { - /** - * @see MediaDrm#EVENT_KEY_REQUIRED - */ + /** {@link ExoMediaDrm} instances provider. */ + interface Provider { + + /** + * Returns an {@link ExoMediaDrm} instance with acquired ownership for the DRM scheme identified + * by the given UUID. + * + *

Each call to this method must have a corresponding call to {@link ExoMediaDrm#release()} + * to ensure correct resource management. + */ + ExoMediaDrm acquireExoMediaDrm(UUID uuid); + } + + /** @see MediaDrm#EVENT_KEY_REQUIRED */ @SuppressWarnings("InlinedApi") int EVENT_KEY_REQUIRED = MediaDrm.EVENT_KEY_REQUIRED; /** @@ -235,6 +246,16 @@ public interface ExoMediaDrm { Map queryKeyStatus(byte[] sessionId); /** + * Acquires ownership over this instance, which must be released by calling {@link #release()}. + */ + void acquire(); + + /** + * Releases ownership of this instance. If a call to this method causes this instance to have no + * acquired ownerships, releases the underlying resources. + * + *

Callers of this method must not make any further use of this instance. + * * @see MediaDrm#release() */ void release(); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/FrameworkMediaDrm.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/FrameworkMediaDrm.java index 15a4b3da4a..983a7139f2 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/FrameworkMediaDrm.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/FrameworkMediaDrm.java @@ -185,6 +185,11 @@ public final class FrameworkMediaDrm implements ExoMediaDrm