Add DummyDrmSessionManager

Avoids nullable DrmSessionManagers and simplifies sample reading.
To be used as default value for MediaSources.

PiperOrigin-RevId: 253624465
This commit is contained in:
aquilescanta 2019-06-17 19:36:36 +01:00 committed by Oliver Woodman
parent 3204cf8ffa
commit af5eb5e552

View File

@ -27,6 +27,24 @@ import java.lang.annotation.RetentionPolicy;
*/
public interface DrmSessionManager<T extends ExoMediaCrypto> {
/** {@link DrmSessionManager} that supports no DRM schemes. */
DrmSessionManager<ExoMediaCrypto> DUMMY =
new DrmSessionManager<ExoMediaCrypto>() {
@Override
public boolean canAcquireSession(DrmInitData drmInitData) {
return false;
}
@Override
public DrmSession<ExoMediaCrypto> acquireSession(
Looper playbackLooper, DrmInitData drmInitData) {
return new ErrorStateDrmSession<>(
new DrmSession.DrmSessionException(
new UnsupportedDrmException(UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME)));
}
};
/** Flags that control the handling of DRM protected content. */
@Documented
@Retention(RetentionPolicy.SOURCE)