Transformer: Rename error code from output to encoding format.

Rename ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED to
ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED.

This makes the error code more consistent with ERROR_CODE_DECODING_FAILED on the
decoding side. Also, the error code is in the "Encoding errors (4xxx)" section,
so muxer errors probably should be in the "Muxer errors (7xxx)" section instead.

Additionally, no muxer errors currently seem to use
ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED, so this should be a safe change.

PiperOrigin-RevId: 493322880
This commit is contained in:
huangdarwin 2022-12-06 17:08:36 +00:00 committed by Ian Baker
parent 0d12de8134
commit c37317222c
6 changed files with 12 additions and 12 deletions

View File

@ -47,7 +47,7 @@ import androidx.media3.decoder.DecoderInputBuffer;
/* isDecoder= */ false,
requestedEncoderFormat,
/* mediaCodecName= */ null,
TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
TransformationException.ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED);
}
@Override

View File

@ -407,7 +407,7 @@ public final class DefaultCodec implements Codec {
mediaCodecName,
isDecoder
? TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED
: TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
: TransformationException.ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED);
}
return TransformationException.createForUnexpected(cause);
}

View File

@ -669,7 +669,7 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
@RequiresNonNull("#1.sampleMimeType")
private static TransformationException createTransformationException(Format format) {
return createTransformationException(
format, TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
format, TransformationException.ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED);
}
@RequiresNonNull("#1.sampleMimeType")

View File

@ -68,7 +68,7 @@ public final class TransformationException extends Exception {
ERROR_CODE_DECODING_FORMAT_UNSUPPORTED,
ERROR_CODE_ENCODER_INIT_FAILED,
ERROR_CODE_ENCODING_FAILED,
ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED,
ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED,
ERROR_CODE_HDR_ENCODING_UNSUPPORTED,
ERROR_CODE_FRAME_PROCESSING_FAILED,
ERROR_CODE_AUDIO_PROCESSING_FAILED,
@ -148,12 +148,12 @@ public final class TransformationException extends Exception {
/** Caused by a failure while trying to encode media samples. */
public static final int ERROR_CODE_ENCODING_FAILED = 4002;
/**
* Caused by the output format for a track not being supported.
* Caused by trying to encode content whose format is not supported. *
*
* <p>Supported output formats are limited by the muxer's capabilities and the {@linkplain
* Codec.DecoderFactory encoders} available.
* <p>Supported output formats are limited by the {@linkplain Codec.DecoderFactory encoders}
* available.
*/
public static final int ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED = 4003;
public static final int ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED = 4003;
/** Caused by the encoder not supporting HDR formats. */
public static final int ERROR_CODE_HDR_ENCODING_UNSUPPORTED = 4004;
@ -190,7 +190,7 @@ public final class TransformationException extends Exception {
.put("ERROR_CODE_HDR_DECODING_UNSUPPORTED", ERROR_CODE_HDR_DECODING_UNSUPPORTED)
.put("ERROR_CODE_ENCODER_INIT_FAILED", ERROR_CODE_ENCODER_INIT_FAILED)
.put("ERROR_CODE_ENCODING_FAILED", ERROR_CODE_ENCODING_FAILED)
.put("ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED", ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED)
.put("ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED", ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED)
.put("ERROR_CODE_HDR_ENCODING_UNSUPPORTED", ERROR_CODE_HDR_ENCODING_UNSUPPORTED)
.put("ERROR_CODE_FRAME_PROCESSING_FAILED", ERROR_CODE_FRAME_PROCESSING_FAILED)
.put("ERROR_CODE_AUDIO_PROCESSING_FAILED", ERROR_CODE_AUDIO_PROCESSING_FAILED)

View File

@ -16,7 +16,7 @@
package androidx.media3.transformer;
import static androidx.media3.transformer.TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED;
import static androidx.media3.transformer.TransformationException.ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED;
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
@ -113,7 +113,7 @@ public class DefaultEncoderFactoryTest {
assertThrows(
TransformationException.class,
() -> encoderFactory.createForVideoEncoding(requestedVideoFormat));
assertThat(transformationException.errorCode).isEqualTo(ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
assertThat(transformationException.errorCode).isEqualTo(ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED);
}
@Test

View File

@ -450,7 +450,7 @@ public final class TransformerEndToEndTest {
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
assertThat(exception.errorCode)
.isEqualTo(TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
.isEqualTo(TransformationException.ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED);
}
@Test