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 { ...@@ -47,6 +47,8 @@ public class TransformerEndToEndTest {
.setTransformationRequest( .setTransformationRequest(
new TransformationRequest.Builder().setVideoMimeType(MimeTypes.VIDEO_H264).build()) new TransformationRequest.Builder().setVideoMimeType(MimeTypes.VIDEO_H264).build())
.setMuxerFactory(muxerFactory) .setMuxerFactory(muxerFactory)
.setEncoderFactory(
new DefaultEncoderFactory(EncoderSelector.DEFAULT, /* disableFallback= */ true))
.build(); .build();
// Result of the following command: // Result of the following command:
// ffprobe -count_frames -select_streams v:0 -show_entries stream=nb_read_frames bear-vp9.webm // ffprobe -count_frames -select_streams v:0 -show_entries stream=nb_read_frames bear-vp9.webm
...@@ -78,6 +80,8 @@ public class TransformerEndToEndTest { ...@@ -78,6 +80,8 @@ public class TransformerEndToEndTest {
.setTransformationMatrix(transformationMatrix) .setTransformationMatrix(transformationMatrix)
.build()) .build())
.setMuxerFactory(muxerFactory) .setMuxerFactory(muxerFactory)
.setEncoderFactory(
new DefaultEncoderFactory(EncoderSelector.DEFAULT, /* disableFallback= */ true))
.build(); .build();
// Result of the following command: // Result of the following command:
// ffprobe -count_frames -select_streams v:0 -show_entries stream=nb_read_frames sample.mp4 // 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 { ...@@ -73,9 +73,18 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
// TODO(b/210591626) Add encoder selection for audio. // TODO(b/210591626) Add encoder selection for audio.
checkArgument(!allowedMimeTypes.isEmpty()); checkArgument(!allowedMimeTypes.isEmpty());
if (!allowedMimeTypes.contains(format.sampleMimeType)) { if (!allowedMimeTypes.contains(format.sampleMimeType)) {
// TODO(b/210591626): Pick fallback MIME type using same strategy as for encoder if (!disableFallback) {
// capabilities limitations. // TODO(b/210591626): Pick fallback MIME type using same strategy as for encoder
format = format.buildUpon().setSampleMimeType(allowedMimeTypes.get(0)).build(); // 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 mediaFormat =
MediaFormat.createAudioFormat( MediaFormat.createAudioFormat(
...@@ -110,8 +119,7 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory { ...@@ -110,8 +119,7 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
format, videoEncoderSelector, allowedMimeTypes, disableFallback); format, videoEncoderSelector, allowedMimeTypes, disableFallback);
if (encoderAndClosestFormatSupport == null) { if (encoderAndClosestFormatSupport == null) {
throw createTransformationException( throw createTransformationException(
new IllegalArgumentException( new IllegalArgumentException("The requested output format is not supported."),
"No encoder available that supports the requested output format."),
format, format,
/* isVideo= */ true, /* isVideo= */ true,
/* isDecoder= */ false, /* 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