diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSession.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSession.java index 23c5f0a7556..763405aa657 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSession.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSession.java @@ -29,7 +29,6 @@ import com.google.android.exoplayer2.drm.DrmInitData.SchemeData; import com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest; import com.google.android.exoplayer2.drm.ExoMediaDrm.ProvisionRequest; -import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy; import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.EventDispatcher; @@ -143,8 +142,8 @@ public interface ReleaseCallback { * @param callback The media DRM callback. * @param playbackLooper The playback looper. * @param eventDispatcher The dispatcher for DRM session manager events. - * @param initialDrmRequestRetryCount The number of times to retry for initial provisioning and - * key request before reporting error. + * @param loadErrorHandlingPolicy The {@link LoadErrorHandlingPolicy} for key and provisioning + * requests. */ public DefaultDrmSession( UUID uuid, @@ -158,7 +157,7 @@ public DefaultDrmSession( MediaDrmCallback callback, Looper playbackLooper, EventDispatcher eventDispatcher, - int initialDrmRequestRetryCount) { + LoadErrorHandlingPolicy loadErrorHandlingPolicy) { if (mode == DefaultDrmSessionManager.MODE_QUERY || mode == DefaultDrmSessionManager.MODE_RELEASE) { Assertions.checkNotNull(offlineLicenseKeySetId); @@ -177,9 +176,7 @@ public DefaultDrmSession( this.optionalKeyRequestParameters = optionalKeyRequestParameters; this.callback = callback; this.eventDispatcher = eventDispatcher; - loadErrorHandlingPolicy = - new DefaultLoadErrorHandlingPolicy( - /* minimumLoadableRetryCount= */ initialDrmRequestRetryCount); + this.loadErrorHandlingPolicy = loadErrorHandlingPolicy; state = STATE_OPENING; responseHandler = new ResponseHandler(playbackLooper); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java index 042a30e440c..0757ad12e08 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java @@ -28,6 +28,8 @@ import com.google.android.exoplayer2.drm.DrmInitData.SchemeData; import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException; import com.google.android.exoplayer2.drm.ExoMediaDrm.OnEventListener; +import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy; +import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.EventDispatcher; import com.google.android.exoplayer2.util.Log; @@ -91,7 +93,7 @@ private MissingSchemeDataException(UUID uuid) { @Nullable private final HashMap optionalKeyRequestParameters; private final EventDispatcher eventDispatcher; private final boolean multiSession; - private final int initialDrmRequestRetryCount; + private final LoadErrorHandlingPolicy loadErrorHandlingPolicy; private final List> sessions; private final List> provisioningSessions; @@ -224,6 +226,22 @@ public DefaultDrmSessionManager( @Nullable HashMap optionalKeyRequestParameters, boolean multiSession, int initialDrmRequestRetryCount) { + this( + uuid, + mediaDrm, + callback, + optionalKeyRequestParameters, + multiSession, + new DefaultLoadErrorHandlingPolicy(initialDrmRequestRetryCount)); + } + + private DefaultDrmSessionManager( + UUID uuid, + ExoMediaDrm mediaDrm, + MediaDrmCallback callback, + @Nullable HashMap optionalKeyRequestParameters, + boolean multiSession, + LoadErrorHandlingPolicy loadErrorHandlingPolicy) { Assertions.checkNotNull(uuid); Assertions.checkNotNull(mediaDrm); Assertions.checkArgument(!C.COMMON_PSSH_UUID.equals(uuid), "Use C.CLEARKEY_UUID instead"); @@ -233,7 +251,7 @@ public DefaultDrmSessionManager( this.optionalKeyRequestParameters = optionalKeyRequestParameters; this.eventDispatcher = new EventDispatcher<>(); this.multiSession = multiSession; - this.initialDrmRequestRetryCount = initialDrmRequestRetryCount; + this.loadErrorHandlingPolicy = loadErrorHandlingPolicy; mode = MODE_PLAYBACK; sessions = new ArrayList<>(); provisioningSessions = new ArrayList<>(); @@ -429,7 +447,7 @@ public DrmSession acquireSession(Looper playbackLooper, DrmInitData drmInitDa callback, playbackLooper, eventDispatcher, - initialDrmRequestRetryCount); + loadErrorHandlingPolicy); sessions.add(session); } session.acquireReference();