mirror of
https://github.com/samsonjs/media.git
synced 2026-03-28 09:55:48 +00:00
Add an errorCode field to DrmSessionException
In order to avoid doing the classification in ExoPlayerImplInternal. Note: This only makes the constructor change. The error code assignment will happen in an immediately following CL. PiperOrigin-RevId: 383397729
This commit is contained in:
parent
c0051c502a
commit
54b4f6635d
5 changed files with 20 additions and 6 deletions
|
|
@ -30,6 +30,7 @@ import androidx.annotation.GuardedBy;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.PlaybackException;
|
||||
import com.google.android.exoplayer2.drm.DrmInitData.SchemeData;
|
||||
import com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest;
|
||||
import com.google.android.exoplayer2.drm.ExoMediaDrm.ProvisionRequest;
|
||||
|
|
@ -511,7 +512,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
}
|
||||
|
||||
private void onError(final Exception e) {
|
||||
lastException = new DrmSessionException(e);
|
||||
// TODO(internal b/184262323): Add an argument here which takes the error code from the caller.
|
||||
lastException = new DrmSessionException(e, PlaybackException.ERROR_CODE_DRM_UNSPECIFIED);
|
||||
Log.e(TAG, "DRM session error", e);
|
||||
dispatchEvent(eventDispatcher -> eventDispatcher.drmSessionManagerError(e));
|
||||
if (state != STATE_OPENED_WITH_KEYS) {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.PlaybackException;
|
||||
import com.google.android.exoplayer2.drm.DrmInitData.SchemeData;
|
||||
import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException;
|
||||
import com.google.android.exoplayer2.drm.ExoMediaDrm.OnEventListener;
|
||||
|
|
@ -540,7 +541,8 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
|
|||
if (eventDispatcher != null) {
|
||||
eventDispatcher.drmSessionManagerError(error);
|
||||
}
|
||||
return new ErrorStateDrmSession(new DrmSessionException(error));
|
||||
return new ErrorStateDrmSession(
|
||||
new DrmSessionException(error, PlaybackException.ERROR_CODE_DRM_CONTENT_ERROR));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.drm;
|
|||
import android.media.MediaDrm;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.PlaybackException;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
|
|
@ -53,8 +54,12 @@ public interface DrmSession {
|
|||
/** Wraps the throwable which is the cause of the error state. */
|
||||
class DrmSessionException extends IOException {
|
||||
|
||||
public DrmSessionException(Throwable cause) {
|
||||
/** The {@link PlaybackException.ErrorCode} that corresponds to the failure. */
|
||||
@PlaybackException.ErrorCode public final int errorCode;
|
||||
|
||||
public DrmSessionException(Throwable cause, @PlaybackException.ErrorCode int errorCode) {
|
||||
super(cause);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.drm;
|
|||
import android.os.Looper;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.PlaybackException;
|
||||
|
||||
/** Manages a DRM session. */
|
||||
public interface DrmSessionManager {
|
||||
|
|
@ -54,8 +55,8 @@ public interface DrmSessionManager {
|
|||
} else {
|
||||
return new ErrorStateDrmSession(
|
||||
new DrmSession.DrmSessionException(
|
||||
new UnsupportedDrmException(
|
||||
UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME)));
|
||||
new UnsupportedDrmException(UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME),
|
||||
PlaybackException.ERROR_CODE_DRM_SCHEME_UNSUPPORTED));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.FormatHolder;
|
||||
import com.google.android.exoplayer2.PlaybackException;
|
||||
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
|
||||
import com.google.android.exoplayer2.drm.DrmInitData;
|
||||
import com.google.android.exoplayer2.drm.DrmSession;
|
||||
|
|
@ -554,7 +555,10 @@ public final class SampleQueueTest {
|
|||
assertReadNothing(/* formatRequired= */ false);
|
||||
sampleQueue.maybeThrowError();
|
||||
when(mockDrmSession.getState()).thenReturn(DrmSession.STATE_ERROR);
|
||||
when(mockDrmSession.getError()).thenReturn(new DrmSession.DrmSessionException(new Exception()));
|
||||
when(mockDrmSession.getError())
|
||||
.thenReturn(
|
||||
new DrmSession.DrmSessionException(
|
||||
new Exception(), PlaybackException.ERROR_CODE_DRM_UNSPECIFIED));
|
||||
assertReadNothing(/* formatRequired= */ false);
|
||||
try {
|
||||
sampleQueue.maybeThrowError();
|
||||
|
|
|
|||
Loading…
Reference in a new issue