Merge muxer and encoder output format error codes.
After implementing fallback, it won't always be possible to differentiate between muxer and encoder as the cause of an output format not being supported. PiperOrigin-RevId: 422780443
This commit is contained in:
parent
c9151c23a2
commit
e5fde04a19
@ -294,7 +294,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
mediaCodecName,
|
mediaCodecName,
|
||||||
isDecoder
|
isDecoder
|
||||||
? TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED
|
? TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED
|
||||||
: TransformationException.ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED);
|
: TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
return TransformationException.createForUnexpected(cause);
|
return TransformationException.createForUnexpected(cause);
|
||||||
}
|
}
|
||||||
|
@ -71,10 +71,9 @@ public final class TransformationException extends Exception {
|
|||||||
ERROR_CODE_DECODING_FORMAT_UNSUPPORTED,
|
ERROR_CODE_DECODING_FORMAT_UNSUPPORTED,
|
||||||
ERROR_CODE_ENCODER_INIT_FAILED,
|
ERROR_CODE_ENCODER_INIT_FAILED,
|
||||||
ERROR_CODE_ENCODING_FAILED,
|
ERROR_CODE_ENCODING_FAILED,
|
||||||
ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED,
|
ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED,
|
||||||
ERROR_CODE_GL_INIT_FAILED,
|
ERROR_CODE_GL_INIT_FAILED,
|
||||||
ERROR_CODE_GL_PROCESSING_FAILED,
|
ERROR_CODE_GL_PROCESSING_FAILED,
|
||||||
ERROR_CODE_MUXER_SAMPLE_MIME_TYPE_UNSUPPORTED,
|
|
||||||
ERROR_CODE_MUXING_FAILED,
|
ERROR_CODE_MUXING_FAILED,
|
||||||
})
|
})
|
||||||
public @interface ErrorCode {}
|
public @interface ErrorCode {}
|
||||||
@ -148,8 +147,13 @@ public final class TransformationException extends Exception {
|
|||||||
public static final int ERROR_CODE_ENCODER_INIT_FAILED = 4001;
|
public static final int ERROR_CODE_ENCODER_INIT_FAILED = 4001;
|
||||||
/** Caused by a failure while trying to encode media samples. */
|
/** Caused by a failure while trying to encode media samples. */
|
||||||
public static final int ERROR_CODE_ENCODING_FAILED = 4002;
|
public static final int ERROR_CODE_ENCODING_FAILED = 4002;
|
||||||
/** Caused by requesting to encode content in a format that is not supported by the device. */
|
/**
|
||||||
public static final int ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED = 4003;
|
* Caused by the output format for a track not being supported.
|
||||||
|
*
|
||||||
|
* <p>Supported output formats are limited by the muxer's capabilities and the {@link
|
||||||
|
* Codec.DecoderFactory encoders} available.
|
||||||
|
*/
|
||||||
|
public static final int ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED = 4003;
|
||||||
|
|
||||||
// Video editing errors (5xxx).
|
// Video editing errors (5xxx).
|
||||||
|
|
||||||
@ -159,16 +163,8 @@ public final class TransformationException extends Exception {
|
|||||||
public static final int ERROR_CODE_GL_PROCESSING_FAILED = 5002;
|
public static final int ERROR_CODE_GL_PROCESSING_FAILED = 5002;
|
||||||
|
|
||||||
// Muxing errors (6xxx).
|
// Muxing errors (6xxx).
|
||||||
|
|
||||||
/**
|
|
||||||
* Caused by an output sample MIME type inferred from the input not being supported by the muxer.
|
|
||||||
*
|
|
||||||
* <p>Use {@link TransformationRequest.Builder#setAudioMimeType(String)} or {@link
|
|
||||||
* TransformationRequest.Builder#setVideoMimeType(String)} to transcode to a supported MIME type.
|
|
||||||
*/
|
|
||||||
public static final int ERROR_CODE_MUXER_SAMPLE_MIME_TYPE_UNSUPPORTED = 6001;
|
|
||||||
/** Caused by a failure while muxing media samples. */
|
/** Caused by a failure while muxing media samples. */
|
||||||
public static final int ERROR_CODE_MUXING_FAILED = 6002;
|
public static final int ERROR_CODE_MUXING_FAILED = 6001;
|
||||||
|
|
||||||
private static final ImmutableBiMap<String, @ErrorCode Integer> NAME_TO_ERROR_CODE =
|
private static final ImmutableBiMap<String, @ErrorCode Integer> NAME_TO_ERROR_CODE =
|
||||||
new ImmutableBiMap.Builder<String, @ErrorCode Integer>()
|
new ImmutableBiMap.Builder<String, @ErrorCode Integer>()
|
||||||
@ -187,12 +183,9 @@ public final class TransformationException extends Exception {
|
|||||||
.put("ERROR_CODE_DECODING_FORMAT_UNSUPPORTED", ERROR_CODE_DECODING_FORMAT_UNSUPPORTED)
|
.put("ERROR_CODE_DECODING_FORMAT_UNSUPPORTED", ERROR_CODE_DECODING_FORMAT_UNSUPPORTED)
|
||||||
.put("ERROR_CODE_ENCODER_INIT_FAILED", ERROR_CODE_ENCODER_INIT_FAILED)
|
.put("ERROR_CODE_ENCODER_INIT_FAILED", ERROR_CODE_ENCODER_INIT_FAILED)
|
||||||
.put("ERROR_CODE_ENCODING_FAILED", ERROR_CODE_ENCODING_FAILED)
|
.put("ERROR_CODE_ENCODING_FAILED", ERROR_CODE_ENCODING_FAILED)
|
||||||
.put("ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED", ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED)
|
.put("ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED", ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED)
|
||||||
.put("ERROR_CODE_GL_INIT_FAILED", ERROR_CODE_GL_INIT_FAILED)
|
.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_GL_PROCESSING_FAILED", ERROR_CODE_GL_PROCESSING_FAILED)
|
||||||
.put(
|
|
||||||
"ERROR_CODE_MUXER_SAMPLE_MIME_TYPE_UNSUPPORTED",
|
|
||||||
ERROR_CODE_MUXER_SAMPLE_MIME_TYPE_UNSUPPORTED)
|
|
||||||
.put("ERROR_CODE_MUXING_FAILED", ERROR_CODE_MUXING_FAILED)
|
.put("ERROR_CODE_MUXING_FAILED", ERROR_CODE_MUXING_FAILED)
|
||||||
.buildOrThrow();
|
.buildOrThrow();
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ import androidx.media3.extractor.metadata.mp4.SlowMotionData;
|
|||||||
"The output sample MIME inferred from the input format is not supported by the muxer."
|
"The output sample MIME inferred from the input format is not supported by the muxer."
|
||||||
+ " Sample MIME type: "
|
+ " Sample MIME type: "
|
||||||
+ sampleMimeType),
|
+ sampleMimeType),
|
||||||
TransformationException.ERROR_CODE_MUXER_SAMPLE_MIME_TYPE_UNSUPPORTED);
|
TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
if (shouldPassthrough(inputFormat)) {
|
if (shouldPassthrough(inputFormat)) {
|
||||||
samplePipeline = new PassthroughSamplePipeline(inputFormat);
|
samplePipeline = new PassthroughSamplePipeline(inputFormat);
|
||||||
|
@ -84,7 +84,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
"The output sample MIME inferred from the input format is not supported by the muxer."
|
"The output sample MIME inferred from the input format is not supported by the muxer."
|
||||||
+ " Sample MIME type: "
|
+ " Sample MIME type: "
|
||||||
+ sampleMimeType),
|
+ sampleMimeType),
|
||||||
TransformationException.ERROR_CODE_MUXER_SAMPLE_MIME_TYPE_UNSUPPORTED);
|
TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
if (shouldPassthrough(inputFormat)) {
|
if (shouldPassthrough(inputFormat)) {
|
||||||
samplePipeline = new PassthroughSamplePipeline(inputFormat);
|
samplePipeline = new PassthroughSamplePipeline(inputFormat);
|
||||||
|
@ -359,7 +359,7 @@ public final class TransformerTest {
|
|||||||
|
|
||||||
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
||||||
assertThat(exception.errorCode)
|
assertThat(exception.errorCode)
|
||||||
.isEqualTo(TransformationException.ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED);
|
.isEqualTo(TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -403,7 +403,7 @@ public final class TransformerTest {
|
|||||||
|
|
||||||
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
||||||
assertThat(exception.errorCode)
|
assertThat(exception.errorCode)
|
||||||
.isEqualTo(TransformationException.ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED);
|
.isEqualTo(TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -434,7 +434,7 @@ public final class TransformerTest {
|
|||||||
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
||||||
assertThat(exception).hasCauseThat().hasMessageThat().contains("audio");
|
assertThat(exception).hasCauseThat().hasMessageThat().contains("audio");
|
||||||
assertThat(exception.errorCode)
|
assertThat(exception.errorCode)
|
||||||
.isEqualTo(TransformationException.ERROR_CODE_MUXER_SAMPLE_MIME_TYPE_UNSUPPORTED);
|
.isEqualTo(TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -453,7 +453,7 @@ public final class TransformerTest {
|
|||||||
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
||||||
assertThat(exception).hasCauseThat().hasMessageThat().contains("video");
|
assertThat(exception).hasCauseThat().hasMessageThat().contains("video");
|
||||||
assertThat(exception.errorCode)
|
assertThat(exception.errorCode)
|
||||||
.isEqualTo(TransformationException.ERROR_CODE_MUXER_SAMPLE_MIME_TYPE_UNSUPPORTED);
|
.isEqualTo(TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user