From 3fcae68432ae1cd07b8293cba0cb490f5aefdb4b Mon Sep 17 00:00:00 2001 From: aquilescanta Date: Thu, 13 Jun 2019 12:57:09 +0100 Subject: [PATCH] Add flags to DrmSessionManager PiperOrigin-RevId: 253006112 --- .../exoplayer2/drm/DrmSessionManager.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/DrmSessionManager.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/DrmSessionManager.java index 168783cf1c..375faff797 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/DrmSessionManager.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/DrmSessionManager.java @@ -16,13 +16,37 @@ package com.google.android.exoplayer2.drm; import android.os.Looper; +import androidx.annotation.IntDef; import com.google.android.exoplayer2.drm.DrmInitData.SchemeData; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; /** * Manages a DRM session. */ public interface DrmSessionManager { + /** Flags that control the handling of DRM protected content. */ + @Documented + @Retention(RetentionPolicy.SOURCE) + @IntDef( + flag = true, + value = {FLAG_PLAY_CLEAR_SAMPLES_WITHOUT_KEYS}) + @interface Flags {} + + /** + * When this flag is set, clear samples of an encrypted region may be rendered when no keys are + * available. + * + *

Encrypted media may contain clear (un-encrypted) regions. For example a media file may start + * with a short clear region so as to allow playback to begin in parallel with key acquisition. + * When this flag is set, consumers of sample data are permitted to access the clear regions of + * encrypted media files when the associated {@link DrmSession} has not yet obtained the keys + * necessary for the encrypted regions of the media. + */ + int FLAG_PLAY_CLEAR_SAMPLES_WITHOUT_KEYS = 1; + /** * Returns whether the manager is capable of acquiring a session for the given * {@link DrmInitData}. @@ -45,4 +69,10 @@ public interface DrmSessionManager { * @return The DRM session. */ DrmSession acquireSession(Looper playbackLooper, DrmInitData drmInitData); + + /** Returns flags that control the handling of DRM protected content. */ + @Flags + default int getFlags() { + return 0; + } }