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
This commit is contained in:
hschlueter 2022-07-27 23:21:31 +00:00 committed by tonihei
parent 580e44fc47
commit 0f96d8615d
2 changed files with 7 additions and 11 deletions

View File

@ -70,8 +70,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 {}
@ -157,10 +156,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. */
@ -185,8 +182,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();
@ -204,7 +200,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);
}

View File

@ -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(