diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/BitmapTestUtil.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/BitmapTestUtil.java index f91967a980..71be4d40a8 100644 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/BitmapTestUtil.java +++ b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/BitmapTestUtil.java @@ -39,7 +39,7 @@ import java.io.InputStream; import java.nio.ByteBuffer; /** - * Utilities for instrumentation tests for the {@link FrameProcessorChain} and {@link + * Utilities for instrumentation tests for the {@link GlEffectsFrameProcessor} and {@link * SingleFrameGlTextureProcessor SingleFrameGlTextureProcessors}. */ public class BitmapTestUtil { diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/CropPixelTest.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/CropPixelTest.java index 065e6ae8bd..2c74675cbd 100644 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/CropPixelTest.java +++ b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/CropPixelTest.java @@ -41,7 +41,7 @@ import org.junit.runner.RunWith; *
Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link * BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output bitmaps - * as recommended in {@link FrameProcessorChainPixelTest}. + * as recommended in {@link GlEffectsFrameProcessorPixelTest}. */ @RunWith(AndroidJUnit4.class) public final class CropPixelTest { diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/FrameProcessorChainPixelTest.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/GlEffectsFrameProcessorPixelTest.java similarity index 93% rename from library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/FrameProcessorChainPixelTest.java rename to library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/GlEffectsFrameProcessorPixelTest.java index 54955779ea..d900297eb1 100644 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/FrameProcessorChainPixelTest.java +++ b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/GlEffectsFrameProcessorPixelTest.java @@ -46,7 +46,7 @@ import org.junit.Test; import org.junit.runner.RunWith; /** - * Pixel test for frame processing via {@link FrameProcessorChain}. + * Pixel test for frame processing via {@link GlEffectsFrameProcessor}. * *
Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link @@ -54,7 +54,7 @@ import org.junit.runner.RunWith; * bitmaps. */ @RunWith(AndroidJUnit4.class) -public final class FrameProcessorChainPixelTest { +public final class GlEffectsFrameProcessorPixelTest { public static final String ORIGINAL_PNG_ASSET_PATH = "media/bitmap/sample_mp4_first_frame/original.png"; public static final String SCALE_WIDE_PNG_ASSET_PATH = @@ -79,8 +79,9 @@ public final class FrameProcessorChainPixelTest { /** Timeout for dequeueing buffers from the codec, in microseconds. */ private static final int DEQUEUE_TIMEOUT_US = 5_000_000; /** - * Time to wait for the decoded frame to populate the {@link FrameProcessorChain}'s input surface - * and the {@link FrameProcessorChain} to finish processing the frame, in milliseconds. + * Time to wait for the decoded frame to populate the {@link GlEffectsFrameProcessor} instance's + * input surface and the {@link GlEffectsFrameProcessor} to finish processing the frame, in + * milliseconds. */ private static final int FRAME_PROCESSING_WAIT_MS = 5000; /** The ratio of width over height, for each pixel in a frame. */ @@ -90,14 +91,14 @@ public final class FrameProcessorChainPixelTest { new AtomicReference<>(); private @MonotonicNonNull MediaFormat mediaFormat; - private @MonotonicNonNull FrameProcessorChain frameProcessorChain; + private @MonotonicNonNull GlEffectsFrameProcessor glEffectsFrameProcessor; private volatile @MonotonicNonNull ImageReader outputImageReader; private volatile boolean frameProcessingEnded; @After public void release() { - if (frameProcessorChain != null) { - frameProcessorChain.release(); + if (glEffectsFrameProcessor != null) { + glEffectsFrameProcessor.release(); } } @@ -321,8 +322,8 @@ public final class FrameProcessorChainPixelTest { /** * Set up and prepare the first frame from an input video, as well as relevant test - * infrastructure. The frame will be sent towards the {@link FrameProcessorChain}, and may be - * accessed on the {@link FrameProcessorChain}'s output {@code outputImageReader}. + * infrastructure. The frame will be sent towards the {@link GlEffectsFrameProcessor}, and output + * may be accessed on the {@code outputImageReader}. * * @param pixelWidthHeightRatio The ratio of width over height for each pixel. * @param effects The {@link GlEffect GlEffects} to apply to the input frame. @@ -350,11 +351,11 @@ public final class FrameProcessorChainPixelTest { int inputWidth = checkNotNull(mediaFormat).getInteger(MediaFormat.KEY_WIDTH); int inputHeight = mediaFormat.getInteger(MediaFormat.KEY_HEIGHT); - frameProcessorChain = + glEffectsFrameProcessor = checkNotNull( - FrameProcessorChain.create( + GlEffectsFrameProcessor.create( context, - new FrameProcessorChain.Listener() { + new GlEffectsFrameProcessor.Listener() { @Override public void onFrameProcessingError(FrameProcessingException exception) { frameProcessingException.set(exception); @@ -382,13 +383,16 @@ public final class FrameProcessorChainPixelTest { }, Transformer.DebugViewProvider.NONE, /* enableExperimentalHdrEditing= */ false)); - frameProcessorChain.registerInputFrame(); + glEffectsFrameProcessor.registerInputFrame(); // Queue the first video frame from the extractor. String mimeType = checkNotNull(mediaFormat.getString(MediaFormat.KEY_MIME)); mediaCodec = MediaCodec.createDecoderByType(mimeType); mediaCodec.configure( - mediaFormat, frameProcessorChain.getInputSurface(), /* crypto= */ null, /* flags= */ 0); + mediaFormat, + glEffectsFrameProcessor.getInputSurface(), + /* crypto= */ null, + /* flags= */ 0); mediaCodec.start(); int inputBufferIndex = mediaCodec.dequeueInputBuffer(DEQUEUE_TIMEOUT_US); assertThat(inputBufferIndex).isNotEqualTo(MediaCodec.INFO_TRY_AGAIN_LATER); @@ -429,15 +433,15 @@ public final class FrameProcessorChainPixelTest { } private Bitmap processFirstFrameAndEnd() throws InterruptedException { - checkNotNull(frameProcessorChain).signalEndOfInputStream(); + checkNotNull(glEffectsFrameProcessor).signalEndOfInputStream(); Thread.sleep(FRAME_PROCESSING_WAIT_MS); assertThat(frameProcessingEnded).isTrue(); assertThat(frameProcessingException.get()).isNull(); - Image frameProcessorChainOutputImage = checkNotNull(outputImageReader).acquireLatestImage(); + Image frameProcessorOutputImage = checkNotNull(outputImageReader).acquireLatestImage(); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromRgba8888Image(frameProcessorChainOutputImage); - frameProcessorChainOutputImage.close(); + BitmapTestUtil.createArgb8888BitmapFromRgba8888Image(frameProcessorOutputImage); + frameProcessorOutputImage.close(); return actualBitmap; } @@ -475,11 +479,11 @@ public final class FrameProcessorChainPixelTest { } /** - * Wraps a {@link GlEffect} to prevent the {@link FrameProcessorChain} from detecting its class - * and optimizing it. + * Wraps a {@link GlEffect} to prevent the {@link GlEffectsFrameProcessor} from detecting its + * class and optimizing it. * - *
This ensures that {@link FrameProcessorChain} uses a separate {@link GlTextureProcessor} for - * the wrapped {@link GlEffect} rather than merging it with preceding or subsequent {@link + *
This ensures that {@link GlEffectsFrameProcessor} uses a separate {@link GlTextureProcessor} + * for the wrapped {@link GlEffect} rather than merging it with preceding or subsequent {@link * GlEffect} instances and applying them in one combined {@link GlTextureProcessor}. */ private static final class GlEffectWrapper implements GlEffect { diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/MatrixTransformationProcessorPixelTest.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/MatrixTransformationProcessorPixelTest.java index 95136c4b17..6895ec78f3 100644 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/MatrixTransformationProcessorPixelTest.java +++ b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/MatrixTransformationProcessorPixelTest.java @@ -40,7 +40,7 @@ import org.junit.runner.RunWith; *
Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link * BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output bitmaps - * as recommended in {@link FrameProcessorChainPixelTest}. + * as recommended in {@link GlEffectsFrameProcessorPixelTest}. */ @RunWith(AndroidJUnit4.class) public final class MatrixTransformationProcessorPixelTest { diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/PresentationPixelTest.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/PresentationPixelTest.java index 2eaac1e870..4403f30153 100644 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/PresentationPixelTest.java +++ b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/PresentationPixelTest.java @@ -42,7 +42,7 @@ import org.junit.runner.RunWith; *
Expected images are taken from an emulator, so tests on different emulators or physical
* devices may fail. To test on other devices, please increase the {@link
* BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output bitmaps
- * as recommended in {@link FrameProcessorChainPixelTest}.
+ * as recommended in {@link GlEffectsFrameProcessorPixelTest}.
*/
@RunWith(AndroidJUnit4.class)
public final class PresentationPixelTest {
diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/ChainingGlTextureProcessorListener.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/ChainingGlTextureProcessorListener.java
index 519949a220..1dd04bd747 100644
--- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/ChainingGlTextureProcessorListener.java
+++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/ChainingGlTextureProcessorListener.java
@@ -31,7 +31,7 @@ import java.util.Queue;
@Nullable private final GlTextureProcessor previousGlTextureProcessor;
@Nullable private final GlTextureProcessor nextGlTextureProcessor;
private final FrameProcessingTaskExecutor frameProcessingTaskExecutor;
- private final FrameProcessorChain.Listener frameProcessorChainListener;
+ private final GlEffectsFrameProcessor.Listener frameProcessorListener;
private final Queue This wrapper is used for the final {@link GlTextureProcessor} instance in the chain of {@link
- * GlTextureProcessor} instances used by {@link FrameProcessorChain}.
+ * GlTextureProcessor} instances used by {@link GlEffectsFrameProcessor}.
*/
/* package */ final class FinalMatrixTransformationProcessorWrapper implements GlTextureProcessor {
@@ -60,7 +60,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private final SurfaceInfo.Provider outputSurfaceProvider;
private final long streamOffsetUs;
private final Transformer.DebugViewProvider debugViewProvider;
- private final FrameProcessorChain.Listener frameProcessorChainListener;
+ private final GlEffectsFrameProcessor.Listener frameProcessorListener;
private final boolean enableExperimentalHdrEditing;
private int inputWidth;
@@ -78,7 +78,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
ImmutableList The {@code FinalMatrixTransformationProcessorWrapper} will only call {@link
* Listener#onInputFrameProcessed(TextureInfo)}. Other events are handled via the {@link
- * FrameProcessorChain.Listener} passed to the constructor.
+ * GlEffectsFrameProcessor.Listener} passed to the constructor.
*/
@Override
public void setListener(Listener listener) {
@@ -130,7 +130,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/* presentationTimeNs= */ (presentationTimeUs + streamOffsetUs) * 1000);
EGL14.eglSwapBuffers(eglDisplay, outputEglSurface);
} catch (FrameProcessingException | GlUtil.GlException e) {
- frameProcessorChainListener.onFrameProcessingError(
+ frameProcessorListener.onFrameProcessingError(
FrameProcessingException.from(e, presentationTimeUs));
}
@@ -247,7 +247,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Override
public void signalEndOfInputStream() {
- frameProcessorChainListener.onFrameProcessingEnded();
+ frameProcessorListener.onFrameProcessingEnded();
}
@Override
diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/FrameProcessingTaskExecutor.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/FrameProcessingTaskExecutor.java
index 4605e5a7d8..b1af683111 100644
--- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/FrameProcessingTaskExecutor.java
+++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/FrameProcessingTaskExecutor.java
@@ -30,19 +30,19 @@ import java.util.concurrent.atomic.AtomicBoolean;
* instances.
*
* The wrapper handles calling {@link
- * FrameProcessorChain.Listener#onFrameProcessingError(FrameProcessingException)} for errors that
- * occur during these tasks.
+ * GlEffectsFrameProcessor.Listener#onFrameProcessingError(FrameProcessingException)} for errors
+ * that occur during these tasks.
*/
/* package */ final class FrameProcessingTaskExecutor {
private final ExecutorService singleThreadExecutorService;
- private final FrameProcessorChain.Listener listener;
+ private final GlEffectsFrameProcessor.Listener listener;
private final ConcurrentLinkedQueue Input becomes available on its {@linkplain #getInputSurface() input surface} asynchronously
* and is processed on a background thread as it becomes available. All input frames should be
@@ -47,20 +47,21 @@ import java.util.concurrent.atomic.AtomicInteger;
* Listener, float, int, int, long, List, SurfaceInfo.Provider, Transformer.DebugViewProvider,
* boolean) output surface}.
*/
-// TODO(b/227625423): Factor out FrameProcessor interface and rename this class to GlFrameProcessor.
-/* package */ final class FrameProcessorChain {
+// TODO(b/227625423): Factor out FrameProcessor interface
+/* package */ final class GlEffectsFrameProcessor {
/**
* Listener for asynchronous frame processing events.
*
- * This listener is only called from the {@link FrameProcessorChain}'s background thread.
+ * This listener is only called from the {@link GlEffectsFrameProcessor} instance's background
+ * thread.
*/
public interface Listener {
/**
* Called when an exception occurs during asynchronous frame processing.
*
* If an error occurred, consuming and producing further frames will not work as expected and
- * the {@link FrameProcessorChain} should be released.
+ * the {@link GlEffectsFrameProcessor} should be released.
*/
void onFrameProcessingError(FrameProcessingException exception);
@@ -86,9 +87,9 @@ import java.util.concurrent.atomic.AtomicInteger;
* @throws FrameProcessingException If reading shader files fails, or an OpenGL error occurs while
* creating and configuring the OpenGL components.
*/
- public static FrameProcessorChain create(
+ public static GlEffectsFrameProcessor create(
Context context,
- FrameProcessorChain.Listener listener,
+ GlEffectsFrameProcessor.Listener listener,
float pixelWidthHeightRatio,
int inputWidth,
int inputHeight,
@@ -103,10 +104,10 @@ import java.util.concurrent.atomic.AtomicInteger;
ExecutorService singleThreadExecutorService = Util.newSingleThreadExecutor(THREAD_NAME);
- Future This method must be executed using the {@code singleThreadExecutorService}, as later OpenGL
* commands will be called on that thread.
*/
@WorkerThread
- private static FrameProcessorChain createOpenGlObjectsAndFrameProcessorChain(
+ private static GlEffectsFrameProcessor createOpenGlObjectsAndFrameProcessor(
Context context,
- FrameProcessorChain.Listener listener,
+ GlEffectsFrameProcessor.Listener listener,
float pixelWidthHeightRatio,
int inputWidth,
int inputHeight,
@@ -196,7 +197,7 @@ import java.util.concurrent.atomic.AtomicInteger;
chainTextureProcessorsWithListeners(
externalTextureProcessor, textureProcessors, frameProcessingTaskExecutor, listener);
- return new FrameProcessorChain(
+ return new GlEffectsFrameProcessor(
eglDisplay,
eglContext,
frameProcessingTaskExecutor,
@@ -244,7 +245,7 @@ import java.util.concurrent.atomic.AtomicInteger;
ImmutableList.Builder Must be called before rendering a frame to the frame processor chain's input surface.
+ * Must be called before rendering a frame to the frame processor's input surface.
*
* @throws IllegalStateException If called after {@link #signalEndOfInputStream()}.
*/
@@ -394,7 +395,7 @@ import java.util.concurrent.atomic.AtomicInteger;
}
/**
- * Informs the {@code FrameProcessorChain} that no further input frames should be accepted.
+ * Informs the {@code GlEffectsFrameProcessor} that no further input frames should be accepted.
*
* @throws IllegalStateException If called more than once.
*/
@@ -407,12 +408,12 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
* Releases all resources.
*
- * If the frame processor chain is released before it has {@linkplain
+ * If the frame processor is released before it has {@linkplain
* Listener#onFrameProcessingEnded() ended}, it will attempt to cancel processing any input frames
* that have already become available. Input frames that become available after release are
* ignored.
*
- * This method blocks until all OpenGL resources are released or releasing times out.
+ * This method blocks until all resources are released or releasing times out.
*/
public void release() {
try {
diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformationException.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformationException.java
index 3dd5b7e988..fdb122decf 100644
--- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformationException.java
+++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformationException.java
@@ -272,15 +272,15 @@ public final class TransformationException extends Exception {
}
/**
- * Creates an instance for a {@link FrameProcessorChain} related exception.
+ * Creates an instance for a {@link GlEffectsFrameProcessor} related exception.
*
* @param cause The cause of the failure.
* @param errorCode See {@link #errorCode}.
* @return The created instance.
*/
- /* package */ static TransformationException createForFrameProcessorChain(
- Throwable cause, int errorCode) {
- return new TransformationException("FrameProcessorChain error", cause, errorCode);
+ /* package */ static TransformationException createForFrameProcessingException(
+ FrameProcessingException cause, int errorCode) {
+ return new TransformationException("Frame processing error", cause, errorCode);
}
/**
diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoTranscodingSamplePipeline.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoTranscodingSamplePipeline.java
index 96b743f0d1..3282944998 100644
--- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoTranscodingSamplePipeline.java
+++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoTranscodingSamplePipeline.java
@@ -44,7 +44,7 @@ import org.checkerframework.dataflow.qual.Pure;
private final Codec decoder;
private final ArrayList