From 44de468f6392c2d203a8aebc779ecc876c9cffa6 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 27 Jul 2022 23:21:31 +0000 Subject: [PATCH] Generalize frame processing error codes. TransformationException error codes were previously tied to OpenGL but other FrameProcessor implementations are possible. So this CL renames the error codes. Also, remove GL_INIT_FAILED error code, as FrameProcessor implemenations may initialize resources on a background thread after the factory method returns, so it's not obvious how to distinguish between initialization failures and processing failures. PiperOrigin-RevId: 463704902 (cherry picked from commit bac323d346c1d3118a0b904caf9926ecb96b912d) --- .../transformer/TransformationException.java | 14 +++++--------- .../VideoTranscodingSamplePipeline.java | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformationException.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformationException.java index 4c019f7c29..21246c5012 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformationException.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformationException.java @@ -68,8 +68,7 @@ public final class TransformationException extends Exception { ERROR_CODE_ENCODING_FAILED, ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED, ERROR_CODE_HDR_EDITING_UNSUPPORTED, - ERROR_CODE_GL_INIT_FAILED, - ERROR_CODE_GL_PROCESSING_FAILED, + ERROR_CODE_FRAME_PROCESSING_FAILED, ERROR_CODE_MUXING_FAILED, }) public @interface ErrorCode {} @@ -155,10 +154,8 @@ public final class TransformationException extends Exception { // Video editing errors (5xxx). - /** Caused by a GL initialization failure. */ - public static final int ERROR_CODE_GL_INIT_FAILED = 5001; - /** Caused by a failure while using or releasing a GL program. */ - public static final int ERROR_CODE_GL_PROCESSING_FAILED = 5002; + /** Caused by a frame processing failure. */ + public static final int ERROR_CODE_FRAME_PROCESSING_FAILED = 5001; // Muxing errors (6xxx). /** Caused by a failure while muxing media samples. */ @@ -183,8 +180,7 @@ public final class TransformationException extends Exception { .put("ERROR_CODE_ENCODING_FAILED", ERROR_CODE_ENCODING_FAILED) .put("ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED", ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED) .put("ERROR_CODE_HDR_EDITING_UNSUPPORTED", ERROR_CODE_HDR_EDITING_UNSUPPORTED) - .put("ERROR_CODE_GL_INIT_FAILED", ERROR_CODE_GL_INIT_FAILED) - .put("ERROR_CODE_GL_PROCESSING_FAILED", ERROR_CODE_GL_PROCESSING_FAILED) + .put("ERROR_CODE_FRAME_PROCESSING_FAILED", ERROR_CODE_FRAME_PROCESSING_FAILED) .put("ERROR_CODE_MUXING_FAILED", ERROR_CODE_MUXING_FAILED) .buildOrThrow(); @@ -202,7 +198,7 @@ public final class TransformationException extends Exception { * Equivalent to {@link TransformationException#getErrorCodeName(int) * TransformationException.getErrorCodeName(this.errorCode)}. */ - public final String getErrorCodeName() { + public String getErrorCodeName() { return getErrorCodeName(errorCode); } diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoTranscodingSamplePipeline.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoTranscodingSamplePipeline.java index d169c9a023..3ce9508b1e 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoTranscodingSamplePipeline.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoTranscodingSamplePipeline.java @@ -120,7 +120,7 @@ import org.checkerframework.dataflow.qual.Pure; public void onFrameProcessingError(FrameProcessingException exception) { asyncErrorListener.onTransformationException( TransformationException.createForFrameProcessingException( - exception, TransformationException.ERROR_CODE_GL_PROCESSING_FAILED)); + exception, TransformationException.ERROR_CODE_FRAME_PROCESSING_FAILED)); } @Override @@ -140,7 +140,7 @@ import org.checkerframework.dataflow.qual.Pure; /* useHdr= */ encoderWrapper.isHdrEditingEnabled()); } catch (FrameProcessingException e) { throw TransformationException.createForFrameProcessingException( - e, TransformationException.ERROR_CODE_GL_INIT_FAILED); + e, TransformationException.ERROR_CODE_FRAME_PROCESSING_FAILED); } frameProcessor.setInputFrameInfo( new FrameInfo(