mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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.Nullable;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import com.google.android.exoplayer2.C;
|
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.DrmInitData.SchemeData;
|
||||||
import com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest;
|
import com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest;
|
||||||
import com.google.android.exoplayer2.drm.ExoMediaDrm.ProvisionRequest;
|
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) {
|
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);
|
Log.e(TAG, "DRM session error", e);
|
||||||
dispatchEvent(eventDispatcher -> eventDispatcher.drmSessionManagerError(e));
|
dispatchEvent(eventDispatcher -> eventDispatcher.drmSessionManagerError(e));
|
||||||
if (state != STATE_OPENED_WITH_KEYS) {
|
if (state != STATE_OPENED_WITH_KEYS) {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Format;
|
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.DrmInitData.SchemeData;
|
||||||
import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException;
|
import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException;
|
||||||
import com.google.android.exoplayer2.drm.ExoMediaDrm.OnEventListener;
|
import com.google.android.exoplayer2.drm.ExoMediaDrm.OnEventListener;
|
||||||
|
|
@ -540,7 +541,8 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
|
||||||
if (eventDispatcher != null) {
|
if (eventDispatcher != null) {
|
||||||
eventDispatcher.drmSessionManagerError(error);
|
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 android.media.MediaDrm;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import com.google.android.exoplayer2.PlaybackException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
|
|
@ -53,8 +54,12 @@ public interface DrmSession {
|
||||||
/** Wraps the throwable which is the cause of the error state. */
|
/** Wraps the throwable which is the cause of the error state. */
|
||||||
class DrmSessionException extends IOException {
|
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);
|
super(cause);
|
||||||
|
this.errorCode = errorCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.drm;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
|
import com.google.android.exoplayer2.PlaybackException;
|
||||||
|
|
||||||
/** Manages a DRM session. */
|
/** Manages a DRM session. */
|
||||||
public interface DrmSessionManager {
|
public interface DrmSessionManager {
|
||||||
|
|
@ -54,8 +55,8 @@ public interface DrmSessionManager {
|
||||||
} else {
|
} else {
|
||||||
return new ErrorStateDrmSession(
|
return new ErrorStateDrmSession(
|
||||||
new DrmSession.DrmSessionException(
|
new DrmSession.DrmSessionException(
|
||||||
new UnsupportedDrmException(
|
new UnsupportedDrmException(UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME),
|
||||||
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.C;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.FormatHolder;
|
import com.google.android.exoplayer2.FormatHolder;
|
||||||
|
import com.google.android.exoplayer2.PlaybackException;
|
||||||
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
|
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
|
||||||
import com.google.android.exoplayer2.drm.DrmInitData;
|
import com.google.android.exoplayer2.drm.DrmInitData;
|
||||||
import com.google.android.exoplayer2.drm.DrmSession;
|
import com.google.android.exoplayer2.drm.DrmSession;
|
||||||
|
|
@ -554,7 +555,10 @@ public final class SampleQueueTest {
|
||||||
assertReadNothing(/* formatRequired= */ false);
|
assertReadNothing(/* formatRequired= */ false);
|
||||||
sampleQueue.maybeThrowError();
|
sampleQueue.maybeThrowError();
|
||||||
when(mockDrmSession.getState()).thenReturn(DrmSession.STATE_ERROR);
|
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);
|
assertReadNothing(/* formatRequired= */ false);
|
||||||
try {
|
try {
|
||||||
sampleQueue.maybeThrowError();
|
sampleQueue.maybeThrowError();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue