Commit 42375424 by hschlueter Committed by Ian Baker

Disable fallback in tests that don't test fallback.

Fallback is only disabled for robolectric and instrumentation tests.
For MH tests, fallback is not disabled, as it may be needed due to
the broad range of devices available.

PiperOrigin-RevId: 426403167
parent 13626a18
......@@ -47,6 +47,8 @@ public class TransformerEndToEndTest {
.setTransformationRequest(
new TransformationRequest.Builder().setVideoMimeType(MimeTypes.VIDEO_H264).build())
.setMuxerFactory(muxerFactory)
.setEncoderFactory(
new DefaultEncoderFactory(EncoderSelector.DEFAULT, /* disableFallback= */ true))
.build();
// Result of the following command:
// ffprobe -count_frames -select_streams v:0 -show_entries stream=nb_read_frames bear-vp9.webm
......@@ -78,6 +80,8 @@ public class TransformerEndToEndTest {
.setTransformationMatrix(transformationMatrix)
.build())
.setMuxerFactory(muxerFactory)
.setEncoderFactory(
new DefaultEncoderFactory(EncoderSelector.DEFAULT, /* disableFallback= */ true))
.build();
// Result of the following command:
// ffprobe -count_frames -select_streams v:0 -show_entries stream=nb_read_frames sample.mp4
......
......@@ -73,9 +73,18 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
// TODO(b/210591626) Add encoder selection for audio.
checkArgument(!allowedMimeTypes.isEmpty());
if (!allowedMimeTypes.contains(format.sampleMimeType)) {
// TODO(b/210591626): Pick fallback MIME type using same strategy as for encoder
// capabilities limitations.
format = format.buildUpon().setSampleMimeType(allowedMimeTypes.get(0)).build();
if (!disableFallback) {
// TODO(b/210591626): Pick fallback MIME type using same strategy as for encoder
// capabilities limitations.
format = format.buildUpon().setSampleMimeType(allowedMimeTypes.get(0)).build();
} else {
throw createTransformationException(
new IllegalArgumentException("The requested output format is not supported."),
format,
/* isVideo= */ false,
/* isDecoder= */ false,
/* mediaCodecName= */ null);
}
}
MediaFormat mediaFormat =
MediaFormat.createAudioFormat(
......@@ -110,8 +119,7 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
format, videoEncoderSelector, allowedMimeTypes, disableFallback);
if (encoderAndClosestFormatSupport == null) {
throw createTransformationException(
new IllegalArgumentException(
"No encoder available that supports the requested output format."),
new IllegalArgumentException("The requested output format is not supported."),
format,
/* isVideo= */ true,
/* isDecoder= */ false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment