Commit 61ceae67 by hschlueter Committed by Ian Baker

Move FrameProcessorChain OpenGL setup to factory method.

The encoder surface is no longer needed for the OpenGL setup and frame
processor initialization, as a placeholder surface is used instead. So
all of the setup can now be done in the factory method.

PiperOrigin-RevId: 438844450
parent 2611b495
...@@ -260,7 +260,7 @@ public final class FrameProcessorChainPixelTest { ...@@ -260,7 +260,7 @@ public final class FrameProcessorChainPixelTest {
outputSize.getHeight(), outputSize.getHeight(),
PixelFormat.RGBA_8888, PixelFormat.RGBA_8888,
/* maxImages= */ 1); /* maxImages= */ 1);
frameProcessorChain.configure( frameProcessorChain.setOutputSurface(
outputImageReader.getSurface(), outputImageReader.getSurface(),
outputSize.getWidth(), outputSize.getWidth(),
outputSize.getHeight(), outputSize.getHeight(),
......
...@@ -28,10 +28,9 @@ import org.junit.Test; ...@@ -28,10 +28,9 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
/** /**
* Robolectric tests for {@link FrameProcessorChain}. * Tests for creating and configuring a {@link FrameProcessorChain}.
* *
* <p>See {@code FrameProcessorChainPixelTest} in the androidTest directory for instrumentation * <p>See {@link FrameProcessorChainPixelTest} for data processing tests.
* tests.
*/ */
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public final class FrameProcessorChainTest { public final class FrameProcessorChainTest {
......
...@@ -116,7 +116,7 @@ import org.checkerframework.dataflow.qual.Pure; ...@@ -116,7 +116,7 @@ import org.checkerframework.dataflow.qual.Pure;
requestedEncoderFormat, requestedEncoderFormat,
encoderSupportedFormat)); encoderSupportedFormat));
frameProcessorChain.configure( frameProcessorChain.setOutputSurface(
/* outputSurface= */ encoder.getInputSurface(), /* outputSurface= */ encoder.getInputSurface(),
/* outputWidth= */ encoderSupportedFormat.width, /* outputWidth= */ encoderSupportedFormat.width,
/* outputHeight= */ encoderSupportedFormat.height, /* outputHeight= */ encoderSupportedFormat.height,
......
...@@ -114,13 +114,19 @@ public class DefaultEncoderFactoryTest { ...@@ -114,13 +114,19 @@ public class DefaultEncoderFactoryTest {
@Test @Test
public void createForVideoEncoding_withNoSupportedEncoder_throws() { public void createForVideoEncoding_withNoSupportedEncoder_throws() {
Format requestedVideoFormat = createVideoFormat(MimeTypes.VIDEO_H264, 1920, 1080, 30); Format requestedVideoFormat = createVideoFormat(MimeTypes.VIDEO_H264, 1920, 1080, 30);
assertThrows(
TransformationException.class, TransformationException exception =
() -> assertThrows(
new DefaultEncoderFactory() TransformationException.class,
.createForVideoEncoding( () ->
requestedVideoFormat, new DefaultEncoderFactory()
/* allowedMimeTypes= */ ImmutableList.of(MimeTypes.VIDEO_H265))); .createForVideoEncoding(
requestedVideoFormat,
/* allowedMimeTypes= */ ImmutableList.of(MimeTypes.VIDEO_H265)));
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
assertThat(exception.errorCode)
.isEqualTo(TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
} }
@Test @Test
......
...@@ -30,7 +30,6 @@ import static org.mockito.Mockito.times; ...@@ -30,7 +30,6 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import android.content.Context; import android.content.Context;
import android.media.MediaCodecInfo;
import android.media.MediaCrypto; import android.media.MediaCrypto;
import android.media.MediaFormat; import android.media.MediaFormat;
import android.os.Handler; import android.os.Handler;
...@@ -406,26 +405,6 @@ public final class TransformerEndToEndTest { ...@@ -406,26 +405,6 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withVideoEncoderFormatUnsupported_completesWithError()
throws Exception {
Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false)
.setTransformationRequest(
new TransformationRequest.Builder()
.setVideoMimeType(MimeTypes.VIDEO_H263) // unsupported encoder MIME type
.build())
.build();
MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_VIDEO_ONLY);
transformer.startTransformation(mediaItem, outputPath);
TransformationException exception = TransformerTestRunner.runUntilError(transformer);
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
assertThat(exception.errorCode)
.isEqualTo(TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
}
@Test
public void startTransformation_withIoError_completesWithError() throws Exception { public void startTransformation_withIoError_completesWithError() throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem.fromUri("asset:///non-existing-path.mp4"); MediaItem mediaItem = MediaItem.fromUri("asset:///non-existing-path.mp4");
...@@ -802,11 +781,6 @@ public final class TransformerEndToEndTest { ...@@ -802,11 +781,6 @@ public final class TransformerEndToEndTest {
/* colorFormats= */ ImmutableList.of(), /* colorFormats= */ ImmutableList.of(),
/* isDecoder= */ true); /* isDecoder= */ true);
addCodec( addCodec(
MimeTypes.VIDEO_H263,
throwingCodecConfig,
ImmutableList.of(MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Flexible),
/* isDecoder= */ false);
addCodec(
MimeTypes.AUDIO_AMR_NB, MimeTypes.AUDIO_AMR_NB,
throwingCodecConfig, throwingCodecConfig,
/* colorFormats= */ ImmutableList.of(), /* colorFormats= */ ImmutableList.of(),
......
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