diff --git a/library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java index 8de7c4cf3f..72d157c665 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java @@ -332,18 +332,6 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities { return index; } - /** - * Creates an {@link ExoPlaybackException} of type {@link ExoPlaybackException#TYPE_RENDERER} for - * this renderer. - * - *

Equivalent to {@link #createRendererException(Throwable, Format, int) - * createRendererException(cause, format, PlaybackException.ERROR_CODE_UNSPECIFIED)}. - */ - protected final ExoPlaybackException createRendererException( - Throwable cause, @Nullable Format format) { - return createRendererException(cause, format, PlaybackException.ERROR_CODE_UNSPECIFIED); - } - /** * Creates an {@link ExoPlaybackException} of type {@link ExoPlaybackException#TYPE_RENDERER} for * this renderer. diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java index a05190f7eb..51e5fa5720 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java @@ -559,7 +559,8 @@ public abstract class MediaCodecRenderer extends BaseRenderer { try { mediaCrypto = new MediaCrypto(sessionMediaCrypto.uuid, sessionMediaCrypto.sessionId); } catch (MediaCryptoException e) { - throw createRendererException(e, inputFormat); + throw createRendererException( + e, inputFormat, PlaybackException.ERROR_CODE_DRM_SYSTEM_ERROR); } mediaCryptoRequiresSecureDecoder = !sessionMediaCrypto.forceAllowInsecureDecoderComponents @@ -569,7 +570,12 @@ public abstract class MediaCodecRenderer extends BaseRenderer { if (FrameworkMediaCrypto.WORKAROUND_DEVICE_NEEDS_KEYS_TO_CONFIGURE_CODEC) { @DrmSession.State int drmSessionState = codecDrmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { - throw createRendererException(codecDrmSession.getError(), inputFormat); + // TODO(internal b/184262323): Assign a proper error code, once we attach that information + // to DrmSessionException. + throw createRendererException( + codecDrmSession.getError(), + inputFormat, + PlaybackException.ERROR_CODE_DRM_UNSPECIFIED); } else if (drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS) { // Wait for keys. return; @@ -1295,7 +1301,8 @@ public abstract class MediaCodecRenderer extends BaseRenderer { resetInputBuffer(); } } catch (CryptoException e) { - throw createRendererException(e, inputFormat); + throw createRendererException( + e, inputFormat, C.getErrorCodeCorrespondingToPlatformDrmErrorCode(e.getErrorCode())); } return false; } @@ -1365,7 +1372,8 @@ public abstract class MediaCodecRenderer extends BaseRenderer { inputIndex, /* offset= */ 0, buffer.data.limit(), presentationTimeUs, /* flags= */ 0); } } catch (CryptoException e) { - throw createRendererException(e, inputFormat); + throw createRendererException( + e, inputFormat, C.getErrorCodeCorrespondingToPlatformDrmErrorCode(e.getErrorCode())); } resetInputBuffer(); @@ -2151,7 +2159,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { try { mediaCrypto.setMediaDrmSession(getFrameworkMediaCrypto(sourceDrmSession).sessionId); } catch (MediaCryptoException e) { - throw createRendererException(e, inputFormat); + throw createRendererException(e, inputFormat, PlaybackException.ERROR_CODE_DRM_SYSTEM_ERROR); } setCodecDrmSession(sourceDrmSession); codecDrainState = DRAIN_STATE_NONE; @@ -2167,7 +2175,8 @@ public abstract class MediaCodecRenderer extends BaseRenderer { // selection. throw createRendererException( new IllegalArgumentException("Expecting FrameworkMediaCrypto but found: " + mediaCrypto), - inputFormat); + inputFormat, + PlaybackException.ERROR_CODE_DRM_SCHEME_UNSUPPORTED); } return (FrameworkMediaCrypto) mediaCrypto; } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java index bf8ce6aa6f..71d43ecaaa 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java @@ -7185,7 +7185,9 @@ public final class ExoPlayerTest { if (audioRendererEnableCount.incrementAndGet() == 2) { // Fail when enabling the renderer for the second time during the playlist update. throw createRendererException( - new IllegalStateException(), ExoPlayerTestRunner.AUDIO_FORMAT); + new IllegalStateException(), + ExoPlayerTestRunner.AUDIO_FORMAT, + PlaybackException.ERROR_CODE_UNSPECIFIED); } } }; @@ -8704,7 +8706,9 @@ public final class ExoPlayerTest { // Fail when enabling the renderer. This will happen during the period // transition while the reading and playing period are different. throw createRendererException( - new IllegalStateException(), ExoPlayerTestRunner.AUDIO_FORMAT); + new IllegalStateException(), + ExoPlayerTestRunner.AUDIO_FORMAT, + PlaybackException.ERROR_CODE_UNSPECIFIED); } } }; diff --git a/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java index 635b21f6f7..de92f5f13c 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java @@ -1550,7 +1550,9 @@ public final class AnalyticsCollectorTest { throws ExoPlaybackException { // Fail when enabling the renderer. This will happen during the period transition. throw createRendererException( - new IllegalStateException(), ExoPlayerTestRunner.AUDIO_FORMAT); + new IllegalStateException(), + ExoPlayerTestRunner.AUDIO_FORMAT, + PlaybackException.ERROR_CODE_UNSPECIFIED); } } }; @@ -1582,7 +1584,9 @@ public final class AnalyticsCollectorTest { // Fail when rendering the audio stream. This will happen during the period // transition. throw createRendererException( - new IllegalStateException(), ExoPlayerTestRunner.AUDIO_FORMAT); + new IllegalStateException(), + ExoPlayerTestRunner.AUDIO_FORMAT, + PlaybackException.ERROR_CODE_UNSPECIFIED); } } }; @@ -1617,7 +1621,9 @@ public final class AnalyticsCollectorTest { // period transition (as the first time is when enabling the stream initially). if (++streamChangeCount == 2) { throw createRendererException( - new IllegalStateException(), ExoPlayerTestRunner.AUDIO_FORMAT); + new IllegalStateException(), + ExoPlayerTestRunner.AUDIO_FORMAT, + PlaybackException.ERROR_CODE_UNSPECIFIED); } } }