Skip to content

Commit

Permalink
Move DefaultLoadErrorHandling creation to DefaultDrmSessionManager
Browse files Browse the repository at this point in the history
Issue:#6334
PiperOrigin-RevId: 266910499
  • Loading branch information
AquilesCanta authored and tonihei committed Sep 5, 2019
1 parent 260db03 commit 578398c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -143,8 +142,8 @@ public interface ReleaseCallback<T extends ExoMediaCrypto> {
* @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,
Expand All @@ -158,7 +157,7 @@ public DefaultDrmSession(
MediaDrmCallback callback,
Looper playbackLooper,
EventDispatcher<DefaultDrmSessionEventListener> eventDispatcher,
int initialDrmRequestRetryCount) {
LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
if (mode == DefaultDrmSessionManager.MODE_QUERY
|| mode == DefaultDrmSessionManager.MODE_RELEASE) {
Assertions.checkNotNull(offlineLicenseKeySetId);
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -91,7 +93,7 @@ private MissingSchemeDataException(UUID uuid) {
@Nullable private final HashMap<String, String> optionalKeyRequestParameters;
private final EventDispatcher<DefaultDrmSessionEventListener> eventDispatcher;
private final boolean multiSession;
private final int initialDrmRequestRetryCount;
private final LoadErrorHandlingPolicy loadErrorHandlingPolicy;

private final List<DefaultDrmSession<T>> sessions;
private final List<DefaultDrmSession<T>> provisioningSessions;
Expand Down Expand Up @@ -224,6 +226,22 @@ public DefaultDrmSessionManager(
@Nullable HashMap<String, String> optionalKeyRequestParameters,
boolean multiSession,
int initialDrmRequestRetryCount) {
this(
uuid,
mediaDrm,
callback,
optionalKeyRequestParameters,
multiSession,
new DefaultLoadErrorHandlingPolicy(initialDrmRequestRetryCount));
}

private DefaultDrmSessionManager(
UUID uuid,
ExoMediaDrm<T> mediaDrm,
MediaDrmCallback callback,
@Nullable HashMap<String, String> optionalKeyRequestParameters,
boolean multiSession,
LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
Assertions.checkNotNull(uuid);
Assertions.checkNotNull(mediaDrm);
Assertions.checkArgument(!C.COMMON_PSSH_UUID.equals(uuid), "Use C.CLEARKEY_UUID instead");
Expand All @@ -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<>();
Expand Down Expand Up @@ -429,7 +447,7 @@ public DrmSession<T> acquireSession(Looper playbackLooper, DrmInitData drmInitDa
callback,
playbackLooper,
eventDispatcher,
initialDrmRequestRetryCount);
loadErrorHandlingPolicy);
sessions.add(session);
}
session.acquireReference();
Expand Down

0 comments on commit 578398c

Please sign in to comment.