diff --git a/demos/transformer/src/main/java/androidx/media3/demo/transformer/PeriodicVignetteShaderProgram.java b/demos/transformer/src/main/java/androidx/media3/demo/transformer/PeriodicVignetteShaderProgram.java index 81e6549d1f..ffd172b481 100644 --- a/demos/transformer/src/main/java/androidx/media3/demo/transformer/PeriodicVignetteShaderProgram.java +++ b/demos/transformer/src/main/java/androidx/media3/demo/transformer/PeriodicVignetteShaderProgram.java @@ -19,7 +19,7 @@ import static androidx.media3.common.util.Assertions.checkArgument; import android.content.Context; import android.opengl.GLES20; -import androidx.media3.common.FrameProcessingException; +import androidx.media3.common.VideoFrameProcessingException; import androidx.media3.common.util.GlProgram; import androidx.media3.common.util.GlUtil; import androidx.media3.common.util.Size; @@ -59,7 +59,7 @@ import java.io.IOException; * @param minInnerRadius The lower bound of the radius that is unaffected by the effect. * @param maxInnerRadius The upper bound of the radius that is unaffected by the effect. * @param outerRadius The radius after which all pixels are black. - * @throws FrameProcessingException If a problem occurs while reading shader files. + * @throws VideoFrameProcessingException If a problem occurs while reading shader files. */ public PeriodicVignetteShaderProgram( Context context, @@ -69,7 +69,7 @@ import java.io.IOException; float minInnerRadius, float maxInnerRadius, float outerRadius) - throws FrameProcessingException { + throws VideoFrameProcessingException { super(useHdr); checkArgument(minInnerRadius <= maxInnerRadius); checkArgument(maxInnerRadius <= outerRadius); @@ -78,7 +78,7 @@ import java.io.IOException; try { glProgram = new GlProgram(context, VERTEX_SHADER_PATH, FRAGMENT_SHADER_PATH); } catch (IOException | GlUtil.GlException e) { - throw new FrameProcessingException(e); + throw new VideoFrameProcessingException(e); } glProgram.setFloatsUniform("uCenter", new float[] {centerX, centerY}); glProgram.setFloatsUniform("uOuterRadius", new float[] {outerRadius}); @@ -95,7 +95,8 @@ import java.io.IOException; } @Override - public void drawFrame(int inputTexId, long presentationTimeUs) throws FrameProcessingException { + public void drawFrame(int inputTexId, long presentationTimeUs) + throws VideoFrameProcessingException { try { glProgram.use(); glProgram.setSamplerTexIdUniform("uTexSampler", inputTexId, /* texUnitIndex= */ 0); @@ -107,17 +108,17 @@ import java.io.IOException; // The four-vertex triangle strip forms a quad. GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, /* first= */ 0, /* count= */ 4); } catch (GlUtil.GlException e) { - throw new FrameProcessingException(e, presentationTimeUs); + throw new VideoFrameProcessingException(e, presentationTimeUs); } } @Override - public void release() throws FrameProcessingException { + public void release() throws VideoFrameProcessingException { super.release(); try { glProgram.delete(); } catch (GlUtil.GlException e) { - throw new FrameProcessingException(e); + throw new VideoFrameProcessingException(e); } } } diff --git a/demos/transformer/src/withMediaPipe/java/androidx/media3/demo/transformer/MediaPipeShaderProgram.java b/demos/transformer/src/withMediaPipe/java/androidx/media3/demo/transformer/MediaPipeShaderProgram.java index 89d5125020..0af7d4d80b 100644 --- a/demos/transformer/src/withMediaPipe/java/androidx/media3/demo/transformer/MediaPipeShaderProgram.java +++ b/demos/transformer/src/withMediaPipe/java/androidx/media3/demo/transformer/MediaPipeShaderProgram.java @@ -24,7 +24,7 @@ import android.content.Context; import android.opengl.EGL14; import androidx.annotation.Nullable; import androidx.media3.common.C; -import androidx.media3.common.FrameProcessingException; +import androidx.media3.common.VideoFrameProcessingException; import androidx.media3.common.util.LibraryLoader; import androidx.media3.common.util.Util; import androidx.media3.effect.GlShaderProgram; @@ -112,7 +112,7 @@ import java.util.concurrent.Future; futures = new ArrayDeque<>(); inputListener = new InputListener() {}; outputListener = new OutputListener() {}; - errorListener = (frameProcessingException) -> {}; + errorListener = (videoFrameProcessingException) -> {}; errorListenerExecutor = MoreExecutors.directExecutor(); EglManager eglManager = new EglManager(EGL14.eglGetCurrentContext()); frameProcessor = @@ -155,7 +155,7 @@ import java.util.concurrent.Future; frameProcessor.setAsynchronousErrorListener( error -> errorListenerExecutor.execute( - () -> errorListener.onFrameProcessingError(new FrameProcessingException(error)))); + () -> errorListener.onError(new VideoFrameProcessingException(error)))); } @Override @@ -191,7 +191,7 @@ import java.util.concurrent.Future; } catch (InterruptedException e) { Thread.currentThread().interrupt(); errorListenerExecutor.execute( - () -> errorListener.onFrameProcessingError(new FrameProcessingException(e))); + () -> errorListener.onError(new VideoFrameProcessingException(e))); } if (acceptedFrame) { inputListener.onInputFrameProcessed(inputTexture); @@ -213,9 +213,7 @@ import java.util.concurrent.Future; Thread.currentThread().interrupt(); if (errorListener != null) { errorListenerExecutor.execute( - () -> - errorListener.onFrameProcessingError( - new FrameProcessingException(e))); + () -> errorListener.onError(new VideoFrameProcessingException(e))); } } } @@ -254,14 +252,12 @@ import java.util.concurrent.Future; try { if (!singleThreadExecutorService.awaitTermination(RELEASE_WAIT_TIME_MS, MILLISECONDS)) { errorListenerExecutor.execute( - () -> - errorListener.onFrameProcessingError( - new FrameProcessingException("Release timed out"))); + () -> errorListener.onError(new VideoFrameProcessingException("Release timed out"))); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); errorListenerExecutor.execute( - () -> errorListener.onFrameProcessingError(new FrameProcessingException(e))); + () -> errorListener.onError(new VideoFrameProcessingException(e))); } frameProcessor.close(); @@ -294,11 +290,11 @@ import java.util.concurrent.Future; futures.remove().get(); } catch (ExecutionException e) { errorListenerExecutor.execute( - () -> errorListener.onFrameProcessingError(new FrameProcessingException(e))); + () -> errorListener.onError(new VideoFrameProcessingException(e))); } catch (InterruptedException e) { Thread.currentThread().interrupt(); errorListenerExecutor.execute( - () -> errorListener.onFrameProcessingError(new FrameProcessingException(e))); + () -> errorListener.onError(new VideoFrameProcessingException(e))); } } } diff --git a/libraries/common/src/main/java/androidx/media3/common/PlaybackException.java b/libraries/common/src/main/java/androidx/media3/common/PlaybackException.java index 0ae8e30f57..db54acf7c4 100644 --- a/libraries/common/src/main/java/androidx/media3/common/PlaybackException.java +++ b/libraries/common/src/main/java/androidx/media3/common/PlaybackException.java @@ -230,10 +230,10 @@ public class PlaybackException extends Exception implements Bundleable { // Frame processing errors (7xxx). - /** Caused by a failure when initializing a {@link FrameProcessor}. */ - @UnstableApi public static final int ERROR_CODE_FRAME_PROCESSOR_INIT_FAILED = 7000; - /** Caused by a failure when processing a frame. */ - @UnstableApi public static final int ERROR_CODE_FRAME_PROCESSING_FAILED = 7001; + /** Caused by a failure when initializing a {@link VideoFrameProcessor}. */ + @UnstableApi public static final int ERROR_CODE_VIDEO_FRAME_PROCESSOR_INIT_FAILED = 7000; + /** Caused by a failure when processing a video frame. */ + @UnstableApi public static final int ERROR_CODE_VIDEO_FRAME_PROCESSING_FAILED = 7001; /** * Player implementations that want to surface custom errors can use error codes greater than this @@ -312,10 +312,10 @@ public class PlaybackException extends Exception implements Bundleable { return "ERROR_CODE_DRM_DEVICE_REVOKED"; case ERROR_CODE_DRM_LICENSE_EXPIRED: return "ERROR_CODE_DRM_LICENSE_EXPIRED"; - case ERROR_CODE_FRAME_PROCESSOR_INIT_FAILED: - return "ERROR_CODE_FRAME_PROCESSOR_INIT_FAILED"; - case ERROR_CODE_FRAME_PROCESSING_FAILED: - return "ERROR_CODE_FRAME_PROCESSING_FAILED"; + case ERROR_CODE_VIDEO_FRAME_PROCESSOR_INIT_FAILED: + return "ERROR_CODE_VIDEO_FRAME_PROCESSOR_INIT_FAILED"; + case ERROR_CODE_VIDEO_FRAME_PROCESSING_FAILED: + return "ERROR_CODE_VIDEO_FRAME_PROCESSING_FAILED"; default: if (errorCode >= CUSTOM_ERROR_CODE_BASE) { return "custom error code"; diff --git a/libraries/common/src/main/java/androidx/media3/common/FrameProcessingException.java b/libraries/common/src/main/java/androidx/media3/common/VideoFrameProcessingException.java similarity index 66% rename from libraries/common/src/main/java/androidx/media3/common/FrameProcessingException.java rename to libraries/common/src/main/java/androidx/media3/common/VideoFrameProcessingException.java index 80083b0e9e..fc112e988a 100644 --- a/libraries/common/src/main/java/androidx/media3/common/FrameProcessingException.java +++ b/libraries/common/src/main/java/androidx/media3/common/VideoFrameProcessingException.java @@ -22,25 +22,26 @@ import androidx.media3.common.util.UnstableApi; * to video frames. */ @UnstableApi -public final class FrameProcessingException extends Exception { +public final class VideoFrameProcessingException extends Exception { /** - * Wraps the given exception in a {@code FrameProcessingException} if it is not already a {@code - * FrameProcessingException} and returns the exception otherwise. + * Wraps the given exception in a {@code VideoFrameProcessingException} if it is not already a + * {@code VideoFrameProcessingException} and returns the exception otherwise. */ - public static FrameProcessingException from(Exception exception) { + public static VideoFrameProcessingException from(Exception exception) { return from(exception, /* presentationTimeUs= */ C.TIME_UNSET); } /** - * Wraps the given exception in a {@code FrameProcessingException} with the given timestamp if it - * is not already a {@code FrameProcessingException} and returns the exception otherwise. + * Wraps the given exception in a {@code VideoFrameProcessingException} with the given timestamp + * if it is not already a {@code VideoFrameProcessingException} and returns the exception + * otherwise. */ - public static FrameProcessingException from(Exception exception, long presentationTimeUs) { - if (exception instanceof FrameProcessingException) { - return (FrameProcessingException) exception; + public static VideoFrameProcessingException from(Exception exception, long presentationTimeUs) { + if (exception instanceof VideoFrameProcessingException) { + return (VideoFrameProcessingException) exception; } else { - return new FrameProcessingException(exception, presentationTimeUs); + return new VideoFrameProcessingException(exception, presentationTimeUs); } } @@ -55,7 +56,7 @@ public final class FrameProcessingException extends Exception { * * @param message The detail message for this exception. */ - public FrameProcessingException(String message) { + public VideoFrameProcessingException(String message) { this(message, /* presentationTimeUs= */ C.TIME_UNSET); } @@ -65,7 +66,7 @@ public final class FrameProcessingException extends Exception { * @param message The detail message for this exception. * @param presentationTimeUs The timestamp of the frame for which the exception occurred. */ - public FrameProcessingException(String message, long presentationTimeUs) { + public VideoFrameProcessingException(String message, long presentationTimeUs) { super(message); this.presentationTimeUs = presentationTimeUs; } @@ -76,7 +77,7 @@ public final class FrameProcessingException extends Exception { * @param message The detail message for this exception. * @param cause The cause of this exception. */ - public FrameProcessingException(String message, Throwable cause) { + public VideoFrameProcessingException(String message, Throwable cause) { this(message, cause, /* presentationTimeUs= */ C.TIME_UNSET); } @@ -87,7 +88,7 @@ public final class FrameProcessingException extends Exception { * @param cause The cause of this exception. * @param presentationTimeUs The timestamp of the frame for which the exception occurred. */ - public FrameProcessingException(String message, Throwable cause, long presentationTimeUs) { + public VideoFrameProcessingException(String message, Throwable cause, long presentationTimeUs) { super(message, cause); this.presentationTimeUs = presentationTimeUs; } @@ -97,7 +98,7 @@ public final class FrameProcessingException extends Exception { * * @param cause The cause of this exception. */ - public FrameProcessingException(Throwable cause) { + public VideoFrameProcessingException(Throwable cause) { this(cause, /* presentationTimeUs= */ C.TIME_UNSET); } @@ -107,7 +108,7 @@ public final class FrameProcessingException extends Exception { * @param cause The cause of this exception. * @param presentationTimeUs The timestamp of the frame for which the exception occurred. */ - public FrameProcessingException(Throwable cause, long presentationTimeUs) { + public VideoFrameProcessingException(Throwable cause, long presentationTimeUs) { super(cause); this.presentationTimeUs = presentationTimeUs; } diff --git a/libraries/common/src/main/java/androidx/media3/common/FrameProcessor.java b/libraries/common/src/main/java/androidx/media3/common/VideoFrameProcessor.java similarity index 78% rename from libraries/common/src/main/java/androidx/media3/common/FrameProcessor.java rename to libraries/common/src/main/java/androidx/media3/common/VideoFrameProcessor.java index b91509fb48..0d141d4188 100644 --- a/libraries/common/src/main/java/androidx/media3/common/FrameProcessor.java +++ b/libraries/common/src/main/java/androidx/media3/common/VideoFrameProcessor.java @@ -25,7 +25,7 @@ import java.util.List; import java.util.concurrent.Executor; /** - * Interface for a frame processor that applies changes to individual video frames. + * Interface for a video frame processor that applies changes to individual video frames. * *
The changes are specified by {@link Effect} instances passed to {@link Factory#create}.
*
@@ -37,13 +37,13 @@ import java.util.concurrent.Executor;
* to the input {@link Surface}.
*/
@UnstableApi
-public interface FrameProcessor {
+public interface VideoFrameProcessor {
// TODO(b/243036513): Allow effects to be replaced.
- /** A factory for {@link FrameProcessor} instances. */
+ /** A factory for {@link VideoFrameProcessor} instances. */
interface Factory {
/**
- * Creates a new {@link FrameProcessor} instance.
+ * Creates a new {@link VideoFrameProcessor} instance.
*
* @param context A {@link Context}.
* @param effects The {@link Effect} instances to apply to each frame. Applied on the {@code
@@ -55,18 +55,18 @@ public interface FrameProcessor {
* video) or not (e.g. from a {@link Bitmap}). See the
* SurfaceTexture docs for more information on external textures.
- * @param releaseFramesAutomatically If {@code true}, the {@link FrameProcessor} will render
- * output frames to the {@linkplain #setOutputSurfaceInfo(SurfaceInfo) output surface}
- * automatically as {@link FrameProcessor} is done processing them. If {@code false}, the
- * {@link FrameProcessor} will block until {@link #releaseOutputFrame(long)} is called, to
+ * @param releaseFramesAutomatically If {@code true}, the instance will render output frames to
+ * the {@linkplain #setOutputSurfaceInfo(SurfaceInfo) output surface} automatically as
+ * {@link VideoFrameProcessor} is done processing them. If {@code false}, the {@link
+ * VideoFrameProcessor} will block until {@link #releaseOutputFrame(long)} is called, to
* render or drop the frame.
* @param executor The {@link Executor} on which the {@code listener} is invoked.
* @param listener A {@link Listener}.
* @return A new instance.
- * @throws FrameProcessingException If a problem occurs while creating the {@link
- * FrameProcessor}.
+ * @throws VideoFrameProcessingException If a problem occurs while creating the {@link
+ * VideoFrameProcessor}.
*/
- FrameProcessor create(
+ VideoFrameProcessor create(
Context context,
List If an error occurred, consuming and producing further frames will not work as expected and
- * the {@link FrameProcessor} should be released.
+ * the {@link VideoFrameProcessor} should be released.
*/
- void onFrameProcessingError(FrameProcessingException exception);
+ void onError(VideoFrameProcessingException exception);
- /** Called after the {@link FrameProcessor} has produced its final output frame. */
- void onFrameProcessingEnded();
+ /** Called after the {@link VideoFrameProcessor} has produced its final output frame. */
+ void onEnded();
}
/**
@@ -127,14 +127,14 @@ public interface FrameProcessor {
long DROP_OUTPUT_FRAME = -2;
/**
- * Provides an input {@link Bitmap} to the {@link FrameProcessor}.
+ * Provides an input {@link Bitmap} to the {@code VideoFrameProcessor}.
*
- * This method should only be used for when the {@link FrameProcessor}'s {@code
+ * This method should only be used for when the {@code VideoFrameProcessor}'s {@code
* isInputTextureExternal} parameter is set to {@code false}.
*
* Can be called on any thread.
*
- * @param inputBitmap The {@link Bitmap} queued to the {@link FrameProcessor}.
+ * @param inputBitmap The {@link Bitmap} queued to the {@code VideoFrameProcessor}.
* @param durationUs The duration for which to display the {@code inputBitmap}, in microseconds.
* @param frameRate The frame rate at which to display the {@code inputBitmap}, in frames per
* second.
@@ -144,9 +144,10 @@ public interface FrameProcessor {
void queueInputBitmap(Bitmap inputBitmap, long durationUs, float frameRate);
/**
- * Returns the input {@link Surface}, where {@link FrameProcessor} consumes input frames from.
+ * Returns the input {@link Surface}, where {@code VideoFrameProcessor} consumes input frames
+ * from.
*
- * This method should only be used for when the {@link FrameProcessor}'s {@code
+ * This method should only be used for when the {@code VideoFrameProcessor}'s {@code
* isInputTextureExternal} parameter is set to {@code true}.
*
* Can be called on any thread.
@@ -171,11 +172,11 @@ public interface FrameProcessor {
void setInputFrameInfo(FrameInfo inputFrameInfo);
/**
- * Informs the {@code FrameProcessor} that a frame will be queued to its input surface.
+ * Informs the {@code VideoFrameProcessor} that a frame will be queued to its input surface.
*
- * Must be called before rendering a frame to the frame processor's input surface.
+ * Must be called before rendering a frame to the {@code VideoFrameProcessor}'s input surface.
*
- * This method should only be used for when the {@link FrameProcessor}'s {@code
+ * This method should only be used for when the {@code VideoFrameProcessor}'s {@code
* isInputTextureExternal} parameter is set to {@code true}.
*
* Can be called on any thread.
@@ -189,7 +190,7 @@ public interface FrameProcessor {
* Returns the number of input frames that have been {@linkplain #registerInputFrame() registered}
* but not processed off the {@linkplain #getInputSurface() input surface} yet.
*
- * This method should only be used for when the {@link FrameProcessor}'s {@code
+ * This method should only be used for when the {@code VideoFrameProcessor}'s {@code
* isInputTextureExternal} parameter is set to {@code true}.
*
* Can be called on any thread.
@@ -201,7 +202,7 @@ public interface FrameProcessor {
* dropped, they will be rendered to this output {@link SurfaceInfo}.
*
* The new output {@link SurfaceInfo} is applied from the next output frame rendered onwards.
- * If the output {@link SurfaceInfo} is {@code null}, the {@code FrameProcessor} will stop
+ * If the output {@link SurfaceInfo} is {@code null}, the {@code VideoFrameProcessor} will stop
* rendering pending frames and resume rendering once a non-null {@link SurfaceInfo} is set.
*
* If the dimensions given in {@link SurfaceInfo} do not match the {@linkplain
@@ -235,7 +236,7 @@ public interface FrameProcessor {
void releaseOutputFrame(long releaseTimeNs);
/**
- * Informs the {@code FrameProcessor} that no further input frames should be accepted.
+ * Informs the {@code VideoFrameProcessor} that no further input frames should be accepted.
*
* Can be called on any thread.
*
@@ -244,12 +245,12 @@ public interface FrameProcessor {
void signalEndOfInput();
/**
- * Flushes the {@code FrameProcessor}.
+ * Flushes the {@code VideoFrameProcessor}.
*
* All the frames that are {@linkplain #registerInputFrame() registered} prior to calling this
* method are no longer considered to be registered when this method returns.
*
- * This method should only be used for when the {@link FrameProcessor}'s {@code
+ * This method should only be used for when the {@code VideoFrameProcessor}'s {@code
* isInputTextureExternal} parameter is set to {@code true}.
*
* {@link Listener} methods invoked prior to calling this method should be ignored.
@@ -259,10 +260,9 @@ public interface FrameProcessor {
/**
* Releases all resources.
*
- * 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.
+ * If the {@code VideoFrameProcessor} is released before it has {@linkplain Listener#onEnded()
+ * 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 resources are released or releasing times out.
*
diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java
index 5a27ef319c..2fcfcb02fe 100644
--- a/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java
+++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java
@@ -33,7 +33,7 @@ import android.graphics.Color;
import android.opengl.EGLContext;
import android.opengl.EGLDisplay;
import android.opengl.EGLSurface;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.Size;
import androidx.media3.test.utils.BitmapPixelTestUtil;
@@ -50,7 +50,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
* BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output
- * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}.
+ * bitmaps as recommended in {@link DefaultVideoFrameProcessorPixelTest}.
*/
@RunWith(AndroidJUnit4.class)
public class ContrastPixelTest {
@@ -89,7 +89,7 @@ public class ContrastPixelTest {
}
@After
- public void release() throws GlUtil.GlException, FrameProcessingException {
+ public void release() throws GlUtil.GlException, VideoFrameProcessingException {
if (contrastShaderProgram != null) {
contrastShaderProgram.release();
}
@@ -198,7 +198,7 @@ public class ContrastPixelTest {
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
}
- private void setupOutputTexture(int outputWidth, int outputHeight) throws GlUtil.GlException {
+ private void setupOutputTexture(int outputWidth, int outputHeight) throws Exception {
int outputTexId =
GlUtil.createTexture(
outputWidth, outputHeight, /* useHighPrecisionColorComponents= */ false);
diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java
index a588203b55..6a519be660 100644
--- a/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java
+++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java
@@ -30,7 +30,7 @@ import android.graphics.Bitmap;
import android.opengl.EGLContext;
import android.opengl.EGLDisplay;
import android.opengl.EGLSurface;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.Size;
import androidx.media3.test.utils.BitmapPixelTestUtil;
@@ -48,7 +48,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
* BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output
- * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}.
+ * bitmaps as recommended in {@link DefaultVideoFrameProcessorPixelTest}.
*/
@RunWith(AndroidJUnit4.class)
public final class CropPixelTest {
@@ -82,7 +82,7 @@ public final class CropPixelTest {
}
@After
- public void release() throws GlUtil.GlException, FrameProcessingException {
+ public void release() throws GlUtil.GlException, VideoFrameProcessingException {
if (cropShaderProgram != null) {
cropShaderProgram.release();
}
diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/DefaultVideoFrameProcessorPixelTest.java
similarity index 86%
rename from libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java
rename to libraries/effect/src/androidTest/java/androidx/media3/effect/DefaultVideoFrameProcessorPixelTest.java
index 0ecda747d0..8b99ff266d 100644
--- a/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java
+++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/DefaultVideoFrameProcessorPixelTest.java
@@ -27,10 +27,10 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import androidx.media3.common.Effect;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.Size;
import androidx.media3.test.utils.BitmapPixelTestUtil;
-import androidx.media3.test.utils.FrameProcessorTestRunner;
+import androidx.media3.test.utils.VideoFrameProcessorTestRunner;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.common.collect.ImmutableList;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@@ -39,10 +39,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
/**
- * Pixel test for frame processing via {@link GlEffectsFrameProcessor}.
+ * Pixel test for video frame processing via {@link DefaultVideoFrameProcessor}.
*
- * Uses a {@link GlEffectsFrameProcessor} to process one frame, and checks that the actual output
- * matches expected output, either from a golden file or from another edit.
+ * Uses a {@link DefaultVideoFrameProcessor} to process one frame, and checks that the actual
+ * output matches expected output, either from a golden file or from another edit.
*
* 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
@@ -50,7 +50,7 @@ import org.junit.runner.RunWith;
* bitmaps.
*/
@RunWith(AndroidJUnit4.class)
-public final class GlEffectsFrameProcessorPixelTest {
+public final class DefaultVideoFrameProcessorPixelTest {
public static final String ORIGINAL_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/electrical_colors/original.png";
public static final String WRAPPED_CROP_PNG_ASSET_PATH =
@@ -81,20 +81,20 @@ public final class GlEffectsFrameProcessorPixelTest {
/** Input video of which we only use the first frame. */
private static final String INPUT_SDR_MP4_ASSET_STRING = "media/mp4/sample.mp4";
- private @MonotonicNonNull FrameProcessorTestRunner frameProcessorTestRunner;
+ private @MonotonicNonNull VideoFrameProcessorTestRunner videoFrameProcessorTestRunner;
@After
public void release() {
- checkNotNull(frameProcessorTestRunner).release();
+ checkNotNull(videoFrameProcessorTestRunner).release();
}
@Test
public void noEffects_matchesGoldenFile() throws Exception {
String testId = "noEffects_matchesGoldenFile";
- frameProcessorTestRunner = getDefaultFrameProcessorTestRunnerBuilder(testId).build();
+ videoFrameProcessorTestRunner = getDefaultFrameProcessorTestRunnerBuilder(testId).build();
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -105,11 +105,11 @@ public final class GlEffectsFrameProcessorPixelTest {
@Test
public void noEffects_withImageInput_matchesGoldenFile() throws Exception {
String testId = "noEffects_withImageInput_matchesGoldenFile";
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId).setIsInputTextureExternal(false).build();
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processImageFrameAndEnd(expectedBitmap);
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processImageFrameAndEnd(expectedBitmap);
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -120,7 +120,7 @@ public final class GlEffectsFrameProcessorPixelTest {
@Test
public void wrappedCrop_withImageInput_matchesGoldenFile() throws Exception {
String testId = "wrappedCrop_withImageInput_matchesGoldenFile";
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setIsInputTextureExternal(false)
.setEffects(
@@ -134,7 +134,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap originalBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
Bitmap expectedBitmap = readBitmap(WRAPPED_CROP_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processImageFrameAndEnd(originalBitmap);
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processImageFrameAndEnd(originalBitmap);
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -148,13 +148,13 @@ public final class GlEffectsFrameProcessorPixelTest {
@Test
public void noEffects_withFrameCache_matchesGoldenFile() throws Exception {
String testId = "noEffects_withFrameCache_matchesGoldenFile";
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setEffects(new FrameCache(/* capacity= */ 5))
.build();
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -165,11 +165,11 @@ public final class GlEffectsFrameProcessorPixelTest {
@Test
public void setPixelWidthHeightRatio_matchesGoldenFile() throws Exception {
String testId = "setPixelWidthHeightRatio_matchesGoldenFile";
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId).setPixelWidthHeightRatio(2f).build();
Bitmap expectedBitmap = readBitmap(SCALE_WIDE_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -182,13 +182,13 @@ public final class GlEffectsFrameProcessorPixelTest {
String testId = "matrixTransformation_matchesGoldenFile";
Matrix translateRightMatrix = new Matrix();
translateRightMatrix.postTranslate(/* dx= */ 1, /* dy= */ 0);
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setEffects((MatrixTransformation) (long presentationTimeNs) -> translateRightMatrix)
.build();
Bitmap expectedBitmap = readBitmap(TRANSLATE_RIGHT_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -201,7 +201,7 @@ public final class GlEffectsFrameProcessorPixelTest {
String testId = "matrixAndScaleToFitTransformation_matchesGoldenFile";
Matrix translateRightMatrix = new Matrix();
translateRightMatrix.postTranslate(/* dx= */ 1, /* dy= */ 0);
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setEffects(
(MatrixTransformation) (long presentationTimeUs) -> translateRightMatrix,
@@ -209,7 +209,7 @@ public final class GlEffectsFrameProcessorPixelTest {
.build();
Bitmap expectedBitmap = readBitmap(TRANSLATE_THEN_ROTATE_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -222,13 +222,13 @@ public final class GlEffectsFrameProcessorPixelTest {
String testId = "bitmapOverlay_matchesGoldenFile";
Bitmap overlayBitmap = readBitmap(OVERLAY_PNG_ASSET_PATH);
BitmapOverlay bitmapOverlay = BitmapOverlay.createStaticBitmapOverlay(overlayBitmap);
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setEffects(new OverlayEffect(ImmutableList.of(bitmapOverlay)))
.build();
Bitmap expectedBitmap = readBitmap(BITMAP_OVERLAY_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -241,7 +241,7 @@ public final class GlEffectsFrameProcessorPixelTest {
String testId = "scaleToFitAndMatrixTransformation_matchesGoldenFile";
Matrix translateRightMatrix = new Matrix();
translateRightMatrix.postTranslate(/* dx= */ 1, /* dy= */ 0);
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setEffects(
new ScaleToFitTransformation.Builder().setRotationDegrees(45).build(),
@@ -249,7 +249,7 @@ public final class GlEffectsFrameProcessorPixelTest {
.build();
Bitmap expectedBitmap = readBitmap(ROTATE_THEN_TRANSLATE_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -260,13 +260,13 @@ public final class GlEffectsFrameProcessorPixelTest {
@Test
public void presentation_createForHeight_matchesGoldenFile() throws Exception {
String testId = "presentation_createForHeight_matchesGoldenFile";
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setEffects(Presentation.createForHeight(480))
.build();
Bitmap expectedBitmap = readBitmap(REQUEST_OUTPUT_HEIGHT_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -277,7 +277,7 @@ public final class GlEffectsFrameProcessorPixelTest {
@Test
public void cropThenPresentation_matchesGoldenFile() throws Exception {
String testId = "cropThenPresentation_matchesGoldenFile";
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setEffects(
new Crop(
@@ -287,7 +287,7 @@ public final class GlEffectsFrameProcessorPixelTest {
.build();
Bitmap expectedBitmap = readBitmap(CROP_THEN_ASPECT_RATIO_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -298,13 +298,13 @@ public final class GlEffectsFrameProcessorPixelTest {
@Test
public void scaleToFitTransformation_rotate45_matchesGoldenFile() throws Exception {
String testId = "scaleToFitTransformation_rotate45_matchesGoldenFile";
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setEffects(new ScaleToFitTransformation.Builder().setRotationDegrees(45).build())
.build();
Bitmap expectedBitmap = readBitmap(ROTATE45_SCALE_TO_FIT_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -315,7 +315,7 @@ public final class GlEffectsFrameProcessorPixelTest {
@Test
public void twoWrappedScaleToFitTransformations_matchesGoldenFile() throws Exception {
String testId = "twoWrappedScaleToFitTransformations_matchesGoldenFile";
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setEffects(
new GlEffectWrapper(
@@ -327,7 +327,7 @@ public final class GlEffectsFrameProcessorPixelTest {
.build();
Bitmap expectedBitmap = readBitmap(ROTATE_THEN_SCALE_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -346,20 +346,20 @@ public final class GlEffectsFrameProcessorPixelTest {
}
full10StepRotationAndCenterCrop.add(centerCrop);
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setOutputFileLabel("centerCrop")
.setEffects(centerCrop)
.build();
- Bitmap centerCropResultBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
- frameProcessorTestRunner.release();
- frameProcessorTestRunner =
+ Bitmap centerCropResultBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
+ videoFrameProcessorTestRunner.release();
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setOutputFileLabel("full10StepRotationAndCenterCrop")
.setEffects(full10StepRotationAndCenterCrop.build())
.build();
Bitmap fullRotationAndCenterCropResultBitmap =
- frameProcessorTestRunner.processFirstFrameAndEnd();
+ videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -371,11 +371,11 @@ public final class GlEffectsFrameProcessorPixelTest {
@Test
public void increaseBrightness_matchesGoldenFile() throws Exception {
String testId = "increaseBrightness_matchesGoldenFile";
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId).setEffects(new Brightness(0.5f)).build();
Bitmap expectedBitmap = readBitmap(INCREASE_BRIGHTNESS_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -399,7 +399,7 @@ public final class GlEffectsFrameProcessorPixelTest {
new RgbAdjustment.Builder().setBlueScale(5).build(),
new Rotation(/* degrees= */ 90),
centerCrop);
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setOutputFileLabel("centerCrop")
.setEffects(
@@ -407,16 +407,16 @@ public final class GlEffectsFrameProcessorPixelTest {
centerCrop)
.build();
Bitmap centerCropAndBrightnessIncreaseResultBitmap =
- frameProcessorTestRunner.processFirstFrameAndEnd();
+ videoFrameProcessorTestRunner.processFirstFrameAndEnd();
- frameProcessorTestRunner.release();
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner.release();
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setOutputFileLabel("full4StepRotationBrightnessIncreaseAndCenterCrop")
.setEffects(increaseBrightnessFullRotationCenterCrop)
.build();
Bitmap fullRotationBrightnessIncreaseAndCenterCropResultBitmap =
- frameProcessorTestRunner.processFirstFrameAndEnd();
+ videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -446,7 +446,7 @@ public final class GlEffectsFrameProcessorPixelTest {
new Rotation(/* degrees= */ 90),
new FrameCache(/* capacity= */ 2),
centerCrop);
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setOutputFileLabel("centerCrop")
.setEffects(
@@ -454,16 +454,16 @@ public final class GlEffectsFrameProcessorPixelTest {
centerCrop)
.build();
Bitmap centerCropAndBrightnessIncreaseResultBitmap =
- frameProcessorTestRunner.processFirstFrameAndEnd();
- frameProcessorTestRunner.release();
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner.processFirstFrameAndEnd();
+ videoFrameProcessorTestRunner.release();
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setOutputFileLabel("full4StepRotationBrightnessIncreaseAndCenterCrop")
.setEffects(increaseBrightnessFullRotationCenterCrop)
.build();
Bitmap fullRotationBrightnessIncreaseAndCenterCropResultBitmap =
- frameProcessorTestRunner.processFirstFrameAndEnd();
+ videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -477,7 +477,7 @@ public final class GlEffectsFrameProcessorPixelTest {
@Test
public void grayscaleThenIncreaseRedChannel_matchesGoldenFile() throws Exception {
String testId = "grayscaleThenIncreaseRedChannel_matchesGoldenFile";
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setEffects(
RgbFilter.createGrayscaleFilter(),
@@ -485,7 +485,7 @@ public final class GlEffectsFrameProcessorPixelTest {
.build();
Bitmap expectedBitmap = readBitmap(GRAYSCALE_THEN_INCREASE_RED_CHANNEL_PNG_ASSET_PATH);
- Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ Bitmap actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
@@ -496,11 +496,11 @@ public final class GlEffectsFrameProcessorPixelTest {
// TODO(b/227624622): Add a test for HDR input after BitmapPixelTestUtil can read HDR bitmaps,
// using GlEffectWrapper to ensure usage of intermediate textures.
- private FrameProcessorTestRunner.Builder getDefaultFrameProcessorTestRunnerBuilder(
+ private VideoFrameProcessorTestRunner.Builder getDefaultFrameProcessorTestRunnerBuilder(
String testId) {
- return new FrameProcessorTestRunner.Builder()
+ return new VideoFrameProcessorTestRunner.Builder()
.setTestId(testId)
- .setFrameProcessorFactory(new GlEffectsFrameProcessor.Factory())
+ .setVideoFrameProcessorFactory(new DefaultVideoFrameProcessor.Factory())
.setVideoAssetPath(INPUT_SDR_MP4_ASSET_STRING);
}
@@ -538,10 +538,10 @@ public final class GlEffectsFrameProcessorPixelTest {
}
/**
- * Wraps a {@link GlEffect} to prevent the {@link GlEffectsFrameProcessor} from detecting its
+ * Wraps a {@link GlEffect} to prevent the {@link DefaultVideoFrameProcessor} from detecting its
* class and optimizing it.
*
- * This ensures that {@link GlEffectsFrameProcessor} uses a separate {@link GlShaderProgram}
+ * This ensures that {@link DefaultVideoFrameProcessor} uses a separate {@link GlShaderProgram}
* for the wrapped {@link GlEffect} rather than merging it with preceding or subsequent {@link
* GlEffect} instances and applying them in one combined {@link GlShaderProgram}.
*/
@@ -555,7 +555,7 @@ public final class GlEffectsFrameProcessorPixelTest {
@Override
public GlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
- throws FrameProcessingException {
+ throws VideoFrameProcessingException {
return effect.toGlShaderProgram(context, useHdr);
}
}
diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorFrameReleaseTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/DefaultVideoFrameProcessorVideoFrameReleaseTest.java
similarity index 85%
rename from libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorFrameReleaseTest.java
rename to libraries/effect/src/androidTest/java/androidx/media3/effect/DefaultVideoFrameProcessorVideoFrameReleaseTest.java
index 0cead4de84..9df85e69a0 100644
--- a/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorFrameReleaseTest.java
+++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/DefaultVideoFrameProcessorVideoFrameReleaseTest.java
@@ -27,9 +27,9 @@ import androidx.annotation.Nullable;
import androidx.media3.common.ColorInfo;
import androidx.media3.common.DebugViewProvider;
import androidx.media3.common.FrameInfo;
-import androidx.media3.common.FrameProcessingException;
-import androidx.media3.common.FrameProcessor;
import androidx.media3.common.SurfaceInfo;
+import androidx.media3.common.VideoFrameProcessingException;
+import androidx.media3.common.VideoFrameProcessor;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.Util;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -50,9 +50,9 @@ import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
-/** Tests for frame release in {@link GlEffectsFrameProcessor}. */
+/** Tests for frame release in {@link DefaultVideoFrameProcessor}. */
@RunWith(AndroidJUnit4.class)
-public final class GlEffectsFrameProcessorFrameReleaseTest {
+public final class DefaultVideoFrameProcessorVideoFrameReleaseTest {
private static final int WIDTH = 200;
private static final int HEIGHT = 100;
@@ -68,12 +68,12 @@ public final class GlEffectsFrameProcessorFrameReleaseTest {
private final LinkedBlockingQueue 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
* BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output
- * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}.
+ * bitmaps as recommended in {@link DefaultVideoFrameProcessorPixelTest}.
*/
@RunWith(AndroidJUnit4.class)
public final class HslAdjustmentPixelTest {
@@ -100,7 +100,7 @@ public final class HslAdjustmentPixelTest {
}
@After
- public void release() throws GlUtil.GlException, FrameProcessingException {
+ public void release() throws GlUtil.GlException, VideoFrameProcessingException {
if (hslProcessor != null) {
hslProcessor.release();
}
diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixShaderProgramPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixShaderProgramPixelTest.java
index f66545e738..a5b5999eff 100644
--- a/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixShaderProgramPixelTest.java
+++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixShaderProgramPixelTest.java
@@ -30,7 +30,7 @@ import android.graphics.Matrix;
import android.opengl.EGLContext;
import android.opengl.EGLDisplay;
import android.opengl.EGLSurface;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.GlUtil;
import androidx.media3.test.utils.BitmapPixelTestUtil;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -47,7 +47,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
* BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output
- * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}.
+ * bitmaps as recommended in {@link DefaultVideoFrameProcessorPixelTest}.
*/
@RunWith(AndroidJUnit4.class)
public final class MatrixShaderProgramPixelTest {
@@ -87,7 +87,7 @@ public final class MatrixShaderProgramPixelTest {
}
@After
- public void release() throws GlUtil.GlException, FrameProcessingException {
+ public void release() throws GlUtil.GlException, VideoFrameProcessingException {
if (matrixShaderProgram != null) {
matrixShaderProgram.release();
}
diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayShaderProgramPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayShaderProgramPixelTest.java
index 943efd87f6..d55ebe4093 100644
--- a/libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayShaderProgramPixelTest.java
+++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayShaderProgramPixelTest.java
@@ -35,7 +35,7 @@ import android.opengl.Matrix;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.Size;
import androidx.media3.test.utils.BitmapPixelTestUtil;
@@ -54,7 +54,7 @@ import org.junit.runner.RunWith;
* Expected bitmaps are taken from an emulator, so tests on different emulators or physical
* devices may fail. To test on other devices, please increase the {@link
* BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output
- * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}.
+ * bitmaps as recommended in {@link DefaultVideoFrameProcessorPixelTest}.
*/
@RunWith(AndroidJUnit4.class)
public class OverlayShaderProgramPixelTest {
@@ -101,7 +101,7 @@ public class OverlayShaderProgramPixelTest {
}
@After
- public void release() throws GlUtil.GlException, FrameProcessingException {
+ public void release() throws GlUtil.GlException, VideoFrameProcessingException {
if (overlayShaderProgram != null) {
overlayShaderProgram.release();
}
diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java
index 9614e7f9e3..fdd39e63cf 100644
--- a/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java
+++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java
@@ -31,7 +31,7 @@ import android.opengl.EGLContext;
import android.opengl.EGLDisplay;
import android.opengl.EGLSurface;
import androidx.media3.common.C;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.Size;
import androidx.media3.test.utils.BitmapPixelTestUtil;
@@ -49,7 +49,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
* BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output
- * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}.
+ * bitmaps as recommended in {@link DefaultVideoFrameProcessorPixelTest}.
*/
@RunWith(AndroidJUnit4.class)
public final class PresentationPixelTest {
@@ -91,7 +91,7 @@ public final class PresentationPixelTest {
}
@After
- public void release() throws GlUtil.GlException, FrameProcessingException {
+ public void release() throws GlUtil.GlException, VideoFrameProcessingException {
if (presentationShaderProgram != null) {
presentationShaderProgram.release();
}
diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java
index d668be3f98..5fbb74b2cc 100644
--- a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java
+++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java
@@ -33,7 +33,7 @@ import android.graphics.Color;
import android.opengl.EGLContext;
import android.opengl.EGLDisplay;
import android.opengl.EGLSurface;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.Size;
import androidx.media3.test.utils.BitmapPixelTestUtil;
@@ -52,7 +52,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
* BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output
- * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}.
+ * bitmaps as recommended in {@link DefaultVideoFrameProcessorPixelTest}.
*/
@RunWith(AndroidJUnit4.class)
public final class RgbAdjustmentPixelTest {
@@ -99,7 +99,7 @@ public final class RgbAdjustmentPixelTest {
}
@After
- public void release() throws GlUtil.GlException, FrameProcessingException {
+ public void release() throws GlUtil.GlException, VideoFrameProcessingException {
if (matrixShaderProgram != null) {
matrixShaderProgram.release();
}
diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java
index acec4526d3..551330c9c5 100644
--- a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java
+++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java
@@ -31,7 +31,7 @@ import android.graphics.Bitmap;
import android.opengl.EGLContext;
import android.opengl.EGLDisplay;
import android.opengl.EGLSurface;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.Size;
import androidx.media3.test.utils.BitmapPixelTestUtil;
@@ -49,7 +49,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
* BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output
- * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}.
+ * bitmaps as recommended in {@link DefaultVideoFrameProcessorPixelTest}.
*/
@RunWith(AndroidJUnit4.class)
public final class RgbFilterPixelTest {
@@ -94,7 +94,7 @@ public final class RgbFilterPixelTest {
}
@After
- public void release() throws GlUtil.GlException, FrameProcessingException {
+ public void release() throws GlUtil.GlException, VideoFrameProcessingException {
if (matrixShaderProgram != null) {
matrixShaderProgram.release();
}
diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java
index 56a1a89d73..48500f8833 100644
--- a/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java
+++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java
@@ -32,7 +32,7 @@ import android.graphics.Color;
import android.opengl.EGLContext;
import android.opengl.EGLDisplay;
import android.opengl.EGLSurface;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.Size;
import androidx.media3.test.utils.BitmapPixelTestUtil;
@@ -49,7 +49,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
* BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output
- * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}.
+ * bitmaps as recommended in {@link DefaultVideoFrameProcessorPixelTest}.
*/
@RunWith(AndroidJUnit4.class)
public class SingleColorLutPixelTest {
@@ -88,7 +88,7 @@ public class SingleColorLutPixelTest {
}
@After
- public void release() throws GlUtil.GlException, FrameProcessingException {
+ public void release() throws GlUtil.GlException, VideoFrameProcessingException {
if (colorLutShaderProgram != null) {
colorLutShaderProgram.release();
}
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/BitmapOverlay.java b/libraries/effect/src/main/java/androidx/media3/effect/BitmapOverlay.java
index 0066d05a2d..a72b3c8e0f 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/BitmapOverlay.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/BitmapOverlay.java
@@ -21,7 +21,7 @@ import android.graphics.Bitmap;
import android.net.Uri;
import android.opengl.GLES20;
import android.opengl.GLUtils;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.BitmapLoader;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.Size;
@@ -44,9 +44,9 @@ public abstract class BitmapOverlay extends TextureOverlay {
* Returns the overlay bitmap displayed at the specified timestamp.
*
* @param presentationTimeUs The presentation timestamp of the current frame, in microseconds.
- * @throws FrameProcessingException If an error occurs while processing or drawing the frame.
+ * @throws VideoFrameProcessingException If an error occurs while processing or drawing the frame.
*/
- public abstract Bitmap getBitmap(long presentationTimeUs) throws FrameProcessingException;
+ public abstract Bitmap getBitmap(long presentationTimeUs) throws VideoFrameProcessingException;
/**
* {@inheritDoc}
@@ -61,7 +61,7 @@ public abstract class BitmapOverlay extends TextureOverlay {
}
@Override
- public int getTextureId(long presentationTimeUs) throws FrameProcessingException {
+ public int getTextureId(long presentationTimeUs) throws VideoFrameProcessingException {
Bitmap bitmap = getBitmap(presentationTimeUs);
if (bitmap != lastBitmap) {
try {
@@ -79,7 +79,7 @@ public abstract class BitmapOverlay extends TextureOverlay {
/* border= */ 0);
GlUtil.checkGlError();
} catch (GlUtil.GlException e) {
- throw new FrameProcessingException(e);
+ throw new VideoFrameProcessingException(e);
}
}
return lastTextureId;
@@ -134,14 +134,14 @@ public abstract class BitmapOverlay extends TextureOverlay {
private @MonotonicNonNull Bitmap lastBitmap;
@Override
- public Bitmap getBitmap(long presentationTimeUs) throws FrameProcessingException {
+ public Bitmap getBitmap(long presentationTimeUs) throws VideoFrameProcessingException {
if (lastBitmap == null) {
BitmapLoader bitmapLoader = new SimpleBitmapLoader();
ListenableFuture If invoking the {@code listener} on {@link GlEffectsFrameProcessor}'s internal thread is
- * desired, pass a {@link MoreExecutors#directExecutor() direct listenerExecutor}.
+ * If invoking the {@code listener} on {@link DefaultVideoFrameProcessor}'s internal thread
+ * is desired, pass a {@link MoreExecutors#directExecutor() direct listenerExecutor}.
*/
@Override
- public GlEffectsFrameProcessor create(
+ public DefaultVideoFrameProcessor create(
Context context,
List All {@link Effect} instances must be {@link GlEffect} instances.
*
@@ -163,7 +163,7 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
* commands will be called on that thread.
*/
@WorkerThread
- private static GlEffectsFrameProcessor createOpenGlObjectsAndFrameProcessor(
+ private static DefaultVideoFrameProcessor createOpenGlObjectsAndFrameProcessor(
Context context,
List This method should only be used for when the {@link FrameProcessor}'s {@code
+ * This method should only be used for when the {@link VideoFrameProcessor}'s {@code
* isInputTextureExternal} parameter is set to {@code true}.
*
* @param width The default width for input buffers, in pixels.
@@ -476,7 +477,7 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
checkState(
!releaseFramesAutomatically,
"Calling this method is not allowed when releaseFramesAutomatically is enabled");
- frameProcessingTaskExecutor.submitWithHighPriority(
+ videoFrameProcessingTaskExecutor.submitWithHighPriority(
() -> finalShaderProgramWrapper.releaseOutputFrame(releaseTimeNs));
}
@@ -485,20 +486,20 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
checkState(!inputStreamEnded);
inputStreamEnded = true;
if (inputInternalTextureManager != null) {
- frameProcessingTaskExecutor.submit(inputInternalTextureManager::signalEndOfInput);
+ videoFrameProcessingTaskExecutor.submit(inputInternalTextureManager::signalEndOfInput);
}
if (inputExternalTextureManager != null) {
- frameProcessingTaskExecutor.submit(inputExternalTextureManager::signalEndOfInput);
+ videoFrameProcessingTaskExecutor.submit(inputExternalTextureManager::signalEndOfInput);
}
}
@Override
public void flush() {
try {
- frameProcessingTaskExecutor.flush();
+ videoFrameProcessingTaskExecutor.flush();
CountDownLatch latch = new CountDownLatch(1);
checkNotNull(inputExternalTextureManager).setOnFlushCompleteListener(latch::countDown);
- frameProcessingTaskExecutor.submit(finalShaderProgramWrapper::flush);
+ videoFrameProcessingTaskExecutor.submit(finalShaderProgramWrapper::flush);
latch.await();
inputExternalTextureManager.setOnFlushCompleteListener(null);
} catch (InterruptedException e) {
@@ -509,7 +510,7 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
@Override
public void release() {
try {
- frameProcessingTaskExecutor.release(
+ videoFrameProcessingTaskExecutor.release(
/* releaseTask= */ this::releaseShaderProgramsAndDestroyGlContext, RELEASE_WAIT_TIME_MS);
} catch (InterruptedException unexpected) {
Thread.currentThread().interrupt();
@@ -548,7 +549,7 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
*/
@WorkerThread
private void releaseShaderProgramsAndDestroyGlContext()
- throws GlUtil.GlException, FrameProcessingException {
+ throws GlUtil.GlException, VideoFrameProcessingException {
for (int i = 0; i < allShaderPrograms.size(); i++) {
allShaderPrograms.get(i).release();
}
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java b/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java
index 95f3fe5f4e..080818257d 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java
@@ -23,8 +23,8 @@ import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import androidx.media3.common.C;
import androidx.media3.common.FrameInfo;
-import androidx.media3.common.FrameProcessingException;
-import androidx.media3.common.FrameProcessor;
+import androidx.media3.common.VideoFrameProcessingException;
+import androidx.media3.common.VideoFrameProcessor;
import androidx.media3.common.util.GlUtil;
import androidx.media3.effect.GlShaderProgram.InputListener;
import java.util.Queue;
@@ -37,7 +37,7 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
/* package */ final class ExternalTextureManager implements InputListener {
- private final FrameProcessingTaskExecutor frameProcessingTaskExecutor;
+ private final VideoFrameProcessingTaskExecutor videoFrameProcessingTaskExecutor;
private final ExternalShaderProgram externalShaderProgram;
private final int externalTexId;
private final Surface surface;
@@ -61,7 +61,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Nullable private volatile FrameInfo currentFrame;
// TODO(b/238302341) Remove the use of after flush task, block the calling thread instead.
- @Nullable private volatile FrameProcessingTask onFlushCompleteTask;
+ @Nullable private volatile VideoFrameProcessingTask onFlushCompleteTask;
private long previousStreamOffsetUs;
@@ -70,21 +70,21 @@ import java.util.concurrent.atomic.AtomicInteger;
*
* @param externalShaderProgram The {@link ExternalShaderProgram} for which this {@code
* ExternalTextureManager} will be set as the {@link InputListener}.
- * @param frameProcessingTaskExecutor The {@link FrameProcessingTaskExecutor}.
- * @throws FrameProcessingException If a problem occurs while creating the external texture.
+ * @param videoFrameProcessingTaskExecutor The {@link VideoFrameProcessingTaskExecutor}.
+ * @throws VideoFrameProcessingException If a problem occurs while creating the external texture.
*/
// The onFrameAvailableListener will not be invoked until the constructor returns.
@SuppressWarnings("nullness:method.invocation.invalid")
public ExternalTextureManager(
ExternalShaderProgram externalShaderProgram,
- FrameProcessingTaskExecutor frameProcessingTaskExecutor)
- throws FrameProcessingException {
+ VideoFrameProcessingTaskExecutor videoFrameProcessingTaskExecutor)
+ throws VideoFrameProcessingException {
this.externalShaderProgram = externalShaderProgram;
- this.frameProcessingTaskExecutor = frameProcessingTaskExecutor;
+ this.videoFrameProcessingTaskExecutor = videoFrameProcessingTaskExecutor;
try {
externalTexId = GlUtil.createExternalTexture();
} catch (GlUtil.GlException e) {
- throw new FrameProcessingException(e);
+ throw new VideoFrameProcessingException(e);
}
surfaceTexture = new SurfaceTexture(externalTexId);
textureTransformMatrix = new float[16];
@@ -93,7 +93,7 @@ import java.util.concurrent.atomic.AtomicInteger;
previousStreamOffsetUs = C.TIME_UNSET;
surfaceTexture.setOnFrameAvailableListener(
unused ->
- frameProcessingTaskExecutor.submit(
+ videoFrameProcessingTaskExecutor.submit(
() -> {
if (numberOfFramesToDropOnBecomingAvailable > 0) {
numberOfFramesToDropOnBecomingAvailable--;
@@ -119,7 +119,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Override
public void onReadyToAcceptInputFrame() {
- frameProcessingTaskExecutor.submit(
+ videoFrameProcessingTaskExecutor.submit(
() -> {
externalShaderProgramInputCapacity.incrementAndGet();
maybeQueueFrameToExternalShaderProgram();
@@ -128,7 +128,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Override
public void onInputFrameProcessed(TextureInfo inputTexture) {
- frameProcessingTaskExecutor.submit(
+ videoFrameProcessingTaskExecutor.submit(
() -> {
currentFrame = null;
maybeQueueFrameToExternalShaderProgram();
@@ -136,13 +136,13 @@ import java.util.concurrent.atomic.AtomicInteger;
}
/** Sets the task to run on completing flushing, or {@code null} to clear any task. */
- public void setOnFlushCompleteListener(@Nullable FrameProcessingTask task) {
+ public void setOnFlushCompleteListener(@Nullable VideoFrameProcessingTask task) {
onFlushCompleteTask = task;
}
@Override
public void onFlush() {
- frameProcessingTaskExecutor.submit(this::flush);
+ videoFrameProcessingTaskExecutor.submit(this::flush);
}
/**
@@ -169,10 +169,10 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
* Signals the end of the input.
*
- * @see FrameProcessor#signalEndOfInput()
+ * @see VideoFrameProcessor#signalEndOfInput()
*/
public void signalEndOfInput() {
- frameProcessingTaskExecutor.submit(
+ videoFrameProcessingTaskExecutor.submit(
() -> {
inputStreamEnded = true;
if (pendingFrames.isEmpty() && currentFrame == null) {
@@ -204,7 +204,7 @@ import java.util.concurrent.atomic.AtomicInteger;
if (onFlushCompleteTask == null || numberOfFramesToDropOnBecomingAvailable > 0) {
return;
}
- frameProcessingTaskExecutor.submitWithHighPriority(onFlushCompleteTask);
+ videoFrameProcessingTaskExecutor.submitWithHighPriority(onFlushCompleteTask);
}
@WorkerThread
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixShaderProgramWrapper.java b/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixShaderProgramWrapper.java
index f0f177d208..95e50ac8ff 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixShaderProgramWrapper.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixShaderProgramWrapper.java
@@ -36,9 +36,9 @@ import androidx.annotation.WorkerThread;
import androidx.media3.common.C;
import androidx.media3.common.ColorInfo;
import androidx.media3.common.DebugViewProvider;
-import androidx.media3.common.FrameProcessingException;
-import androidx.media3.common.FrameProcessor;
import androidx.media3.common.SurfaceInfo;
+import androidx.media3.common.VideoFrameProcessingException;
+import androidx.media3.common.VideoFrameProcessor;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.Log;
import androidx.media3.common.util.Size;
@@ -59,7 +59,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
* the frames to the dimensions specified by the provided {@link SurfaceInfo}.
*
* This wrapper is used for the final {@link GlShaderProgram} instance in the chain of {@link
- * GlShaderProgram} instances used by {@link FrameProcessor}.
+ * GlShaderProgram} instances used by {@link VideoFrameProcessor}.
*/
/* package */ final class FinalMatrixShaderProgramWrapper implements ExternalShaderProgram {
@@ -76,8 +76,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private final ColorInfo inputColorInfo;
private final ColorInfo outputColorInfo;
private final boolean releaseFramesAutomatically;
- private final Executor frameProcessorListenerExecutor;
- private final FrameProcessor.Listener frameProcessorListener;
+ private final Executor videoFrameProcessorListenerExecutor;
+ private final VideoFrameProcessor.Listener videoFrameProcessorListener;
private final float[] textureTransformMatrix;
private final Queue Example usage: cache the processed frames when presenting them on screen, to accommodate for
- * the possible fluctuation in frame processing time between frames.
+ * the possible fluctuation in video frame processing time between frames.
*/
@UnstableApi
public final class FrameCache implements GlEffect {
@@ -51,7 +51,7 @@ public final class FrameCache implements GlEffect {
@Override
public GlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
- throws FrameProcessingException {
+ throws VideoFrameProcessingException {
return new FrameCacheShaderProgram(context, capacity, useHdr);
}
}
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/FrameCacheShaderProgram.java b/libraries/effect/src/main/java/androidx/media3/effect/FrameCacheShaderProgram.java
index 172fc1d1ec..f0a89c984c 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/FrameCacheShaderProgram.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/FrameCacheShaderProgram.java
@@ -19,7 +19,7 @@ import static androidx.media3.common.util.Assertions.checkState;
import android.content.Context;
import android.opengl.GLES20;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.GlProgram;
import androidx.media3.common.util.GlUtil;
import com.google.common.collect.Iterables;
@@ -54,7 +54,7 @@ import java.util.concurrent.Executor;
/** Creates a new instance. */
public FrameCacheShaderProgram(Context context, int capacity, boolean useHdr)
- throws FrameProcessingException {
+ throws VideoFrameProcessingException {
freeOutputTextures = new ArrayDeque<>();
inUseOutputTextures = new ArrayDeque<>();
try {
@@ -64,7 +64,7 @@ import java.util.concurrent.Executor;
VERTEX_SHADER_TRANSFORMATION_ES2_PATH,
FRAGMENT_SHADER_TRANSFORMATION_ES2_PATH);
} catch (IOException | GlUtil.GlException e) {
- throw FrameProcessingException.from(e);
+ throw VideoFrameProcessingException.from(e);
}
this.capacity = capacity;
this.useHdr = useHdr;
@@ -80,7 +80,7 @@ import java.util.concurrent.Executor;
inputListener = new InputListener() {};
outputListener = new OutputListener() {};
- errorListener = frameProcessingException -> {};
+ errorListener = videoFrameProcessingException -> {};
errorListenerExecutor = MoreExecutors.directExecutor();
}
@@ -129,7 +129,7 @@ import java.util.concurrent.Executor;
outputListener.onOutputFrameAvailable(outputTexture, presentationTimeUs);
} catch (GlUtil.GlException | NoSuchElementException e) {
errorListenerExecutor.execute(
- () -> errorListener.onFrameProcessingError(FrameProcessingException.from(e)));
+ () -> errorListener.onError(VideoFrameProcessingException.from(e)));
}
}
@@ -167,11 +167,11 @@ import java.util.concurrent.Executor;
}
@Override
- public void release() throws FrameProcessingException {
+ public void release() throws VideoFrameProcessingException {
try {
deleteAllOutputTextures();
} catch (GlUtil.GlException e) {
- throw new FrameProcessingException(e);
+ throw new VideoFrameProcessingException(e);
}
}
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/GlEffect.java b/libraries/effect/src/main/java/androidx/media3/effect/GlEffect.java
index 817a66febc..b891e2be74 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/GlEffect.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/GlEffect.java
@@ -17,7 +17,7 @@ package androidx.media3.effect;
import android.content.Context;
import androidx.media3.common.Effect;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.UnstableApi;
/**
@@ -36,10 +36,11 @@ public interface GlEffect extends Effect {
* @param context A {@link Context}.
* @param useHdr Whether input textures come from an HDR source. If {@code true}, colors will be
* in linear RGB BT.2020. If {@code false}, colors will be in linear RGB BT.709.
- * @throws FrameProcessingException If an error occurs while creating the {@link GlShaderProgram}.
+ * @throws VideoFrameProcessingException If an error occurs while creating the {@link
+ * GlShaderProgram}.
*/
GlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
- throws FrameProcessingException;
+ throws VideoFrameProcessingException;
/**
* Returns whether a {@link GlEffect} applies no change at every timestamp.
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/GlMatrixTransformation.java b/libraries/effect/src/main/java/androidx/media3/effect/GlMatrixTransformation.java
index 26ba322604..6136405d8a 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/GlMatrixTransformation.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/GlMatrixTransformation.java
@@ -17,7 +17,7 @@ package androidx.media3.effect;
import android.content.Context;
import android.opengl.Matrix;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.Size;
import androidx.media3.common.util.UnstableApi;
import com.google.common.collect.ImmutableList;
@@ -54,7 +54,7 @@ public interface GlMatrixTransformation extends GlEffect {
@Override
default SingleFrameGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
- throws FrameProcessingException {
+ throws VideoFrameProcessingException {
return MatrixShaderProgram.create(
context,
/* matrixTransformations= */ ImmutableList.of(this),
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/GlShaderProgram.java b/libraries/effect/src/main/java/androidx/media3/effect/GlShaderProgram.java
index a7511c270d..b8983e6743 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/GlShaderProgram.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/GlShaderProgram.java
@@ -15,7 +15,7 @@
*/
package androidx.media3.effect;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.UnstableApi;
import java.util.concurrent.Executor;
@@ -47,7 +47,7 @@ import java.util.concurrent.Executor;
public interface GlShaderProgram {
/**
- * Listener for input-related frame processing events.
+ * Listener for input-related video frame processing events.
*
* This listener can be called from any thread.
*/
@@ -81,7 +81,7 @@ public interface GlShaderProgram {
}
/**
- * Listener for output-related frame processing events.
+ * Listener for output-related video frame processing events.
*
* This listener can be called from any thread.
*/
@@ -108,26 +108,26 @@ public interface GlShaderProgram {
}
/**
- * Listener for frame processing errors.
+ * Listener for video frame processing errors.
*
* This listener can be called from any thread.
*/
interface ErrorListener {
/**
- * Called when an exception occurs during asynchronous frame processing.
+ * Called when an exception occurs during asynchronous video frame processing.
*
* If an error occurred, consuming and producing further frames will not work as expected and
* the {@link GlShaderProgram} should be released.
*/
- void onFrameProcessingError(FrameProcessingException e);
+ void onError(VideoFrameProcessingException e);
}
/**
* Sets the {@link InputListener}.
*
* The {@link InputListener} should be invoked on the thread that owns the parent OpenGL
- * context. For example, {@link GlEffectsFrameProcessor} invokes the {@link InputListener} methods
- * on its internal thread.
+ * context. For example, {@link DefaultVideoFrameProcessor} invokes the {@link InputListener}
+ * methods on its internal thread.
*/
void setInputListener(InputListener inputListener);
@@ -135,7 +135,7 @@ public interface GlShaderProgram {
* Sets the {@link OutputListener}.
*
* The {@link OutputListener} should be invoked on the thread that owns the parent OpenGL
- * context. For example, {@link GlEffectsFrameProcessor} invokes the {@link OutputListener}
+ * context. For example, {@link DefaultVideoFrameProcessor} invokes the {@link OutputListener}
* methods on its internal thread.
*/
void setOutputListener(OutputListener outputListener);
@@ -190,7 +190,7 @@ public interface GlShaderProgram {
/**
* Releases all resources.
*
- * @throws FrameProcessingException If an error occurs while releasing resources.
+ * @throws VideoFrameProcessingException If an error occurs while releasing resources.
*/
- void release() throws FrameProcessingException;
+ void release() throws VideoFrameProcessingException;
}
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/HslAdjustment.java b/libraries/effect/src/main/java/androidx/media3/effect/HslAdjustment.java
index 36eaf4272c..92a90ad64c 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/HslAdjustment.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/HslAdjustment.java
@@ -19,7 +19,7 @@ package androidx.media3.effect;
import static androidx.media3.common.util.Assertions.checkArgument;
import android.content.Context;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.UnstableApi;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -114,7 +114,7 @@ public class HslAdjustment implements GlEffect {
@Override
public SingleFrameGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
- throws FrameProcessingException {
+ throws VideoFrameProcessingException {
return new HslShaderProgram(context, /* hslAdjustment= */ this, useHdr);
}
}
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/HslShaderProgram.java b/libraries/effect/src/main/java/androidx/media3/effect/HslShaderProgram.java
index 0244045152..5e436d91b9 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/HslShaderProgram.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/HslShaderProgram.java
@@ -20,7 +20,7 @@ import static androidx.media3.common.util.Assertions.checkArgument;
import android.content.Context;
import android.opengl.GLES20;
-import androidx.media3.common.FrameProcessingException;
+import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.util.GlProgram;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.Size;
@@ -40,10 +40,10 @@ import java.io.IOException;
* @param hslAdjustment The {@link HslAdjustment} to apply to each frame in order.
* @param useHdr Whether input textures come from an HDR source. If {@code true}, colors will be
* in linear RGB BT.2020. If {@code false}, colors will be in linear RGB BT.709.
- * @throws FrameProcessingException If a problem occurs while reading shader files.
+ * @throws VideoFrameProcessingException If a problem occurs while reading shader files.
*/
public HslShaderProgram(Context context, HslAdjustment hslAdjustment, boolean useHdr)
- throws FrameProcessingException {
+ throws VideoFrameProcessingException {
super(useHdr);
// TODO(b/241241680): Check if HDR <-> HSL works the same or not.
checkArgument(!useHdr, "HDR is not yet supported.");
@@ -51,7 +51,7 @@ import java.io.IOException;
try {
glProgram = new GlProgram(context, VERTEX_SHADER_PATH, FRAGMENT_SHADER_PATH);
} catch (IOException | GlUtil.GlException e) {
- throw new FrameProcessingException(e);
+ throw new VideoFrameProcessingException(e);
}
// Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y.
@@ -78,7 +78,8 @@ import java.io.IOException;
}
@Override
- public void drawFrame(int inputTexId, long presentationTimeUs) throws FrameProcessingException {
+ public void drawFrame(int inputTexId, long presentationTimeUs)
+ throws VideoFrameProcessingException {
try {
glProgram.use();
glProgram.setSamplerTexIdUniform("uTexSampler", inputTexId, /* texUnitIndex= */ 0);
@@ -87,7 +88,7 @@ import java.io.IOException;
// The four-vertex triangle strip forms a quad.
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, /* first= */ 0, /* count= */ 4);
} catch (GlUtil.GlException e) {
- throw new FrameProcessingException(e, presentationTimeUs);
+ throw new VideoFrameProcessingException(e, presentationTimeUs);
}
}
}
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/InternalTextureManager.java b/libraries/effect/src/main/java/androidx/media3/effect/InternalTextureManager.java
index 2d24a9426f..a7e9b5d4e5 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/InternalTextureManager.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/InternalTextureManager.java
@@ -23,22 +23,23 @@ import android.opengl.GLES20;
import android.opengl.GLUtils;
import androidx.annotation.WorkerThread;
import androidx.media3.common.C;
-import androidx.media3.common.FrameProcessingException;
-import androidx.media3.common.FrameProcessor;
+import androidx.media3.common.VideoFrameProcessingException;
+import androidx.media3.common.VideoFrameProcessor;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.UnstableApi;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
/**
- * Forwards a frame produced from a {@link Bitmap} to a {@link GlShaderProgram} for consumption.
+ * Forwards a video frame produced from a {@link Bitmap} to a {@link GlShaderProgram} for
+ * consumption.
*
* Methods in this class can be called from any thread.
*/
@UnstableApi
/* package */ final class InternalTextureManager implements GlShaderProgram.InputListener {
private final GlShaderProgram shaderProgram;
- private final FrameProcessingTaskExecutor frameProcessingTaskExecutor;
+ private final VideoFrameProcessingTaskExecutor videoFrameProcessingTaskExecutor;
// The queue holds all bitmaps with one or more frames pending to be sent downstream.
private final Queue Public methods can be called from any thread.
*
* The wrapper handles calling {@link
- * FrameProcessor.Listener#onFrameProcessingError(FrameProcessingException)} for errors that occur
- * during these tasks. The listener is invoked from the {@link ExecutorService}. Errors are assumed
- * to be non-recoverable, so the {@code FrameProcessingTaskExecutor} should be released if an error
+ * VideoFrameProcessor.Listener#onError(VideoFrameProcessingException)} for errors that occur during
+ * these tasks. The listener is invoked from the {@link ExecutorService}. Errors are assumed to be
+ * non-recoverable, so the {@code VideoFrameProcessingTaskExecutor} should be released if an error
* occurs.
*
- * {@linkplain #submitWithHighPriority(FrameProcessingTask) High priority tasks} are always
- * executed before {@linkplain #submit(FrameProcessingTask) default priority tasks}. Tasks with
+ * {@linkplain #submitWithHighPriority(VideoFrameProcessingTask) High priority tasks} are always
+ * executed before {@linkplain #submit(VideoFrameProcessingTask) default priority tasks}. Tasks with
* equal priority are executed in FIFO order.
*/
-/* package */ final class FrameProcessingTaskExecutor {
+/* package */ final class VideoFrameProcessingTaskExecutor {
private final ExecutorService singleThreadExecutorService;
- private final FrameProcessor.Listener listener;
+ private final VideoFrameProcessor.Listener listener;
private final Object lock;
@GuardedBy("lock")
- private final ArrayDeque Tasks that were previously {@linkplain #submit(FrameProcessingTask) submitted} without
+ * Tasks that were previously {@linkplain #submit(VideoFrameProcessingTask) submitted} without
* high-priority and have not started executing will be executed after this task is complete.
*/
- public void submitWithHighPriority(FrameProcessingTask task) {
+ public void submitWithHighPriority(VideoFrameProcessingTask task) {
synchronized (lock) {
if (shouldCancelTasks) {
return;
@@ -111,7 +111,7 @@ import java.util.concurrent.RejectedExecutionException;
/**
* Flushes all scheduled tasks.
*
- * During flush, the {@code FrameProcessingTaskExecutor} ignores the {@linkplain #submit
+ * During flush, the {@code VideoFrameProcessingTaskExecutor} ignores the {@linkplain #submit
* submission of new tasks}. The tasks that are submitted before flushing are either executed or
* canceled when this method returns.
*/
@@ -137,12 +137,12 @@ import java.util.concurrent.RejectedExecutionException;
/**
* Cancels remaining tasks, runs the given release task, and shuts down the background thread.
*
- * @param releaseTask A {@link FrameProcessingTask} to execute before shutting down the background
- * thread.
+ * @param releaseTask A {@link VideoFrameProcessingTask} to execute before shutting down the
+ * background thread.
* @param releaseWaitTimeMs How long to wait for the release task to terminate, in milliseconds.
* @throws InterruptedException If interrupted while releasing resources.
*/
- public void release(FrameProcessingTask releaseTask, long releaseWaitTimeMs)
+ public void release(VideoFrameProcessingTask releaseTask, long releaseWaitTimeMs)
throws InterruptedException {
synchronized (lock) {
shouldCancelTasks = true;
@@ -153,16 +153,16 @@ import java.util.concurrent.RejectedExecutionException;
singleThreadExecutorService.shutdown();
try {
if (!singleThreadExecutorService.awaitTermination(releaseWaitTimeMs, MILLISECONDS)) {
- listener.onFrameProcessingError(new FrameProcessingException("Release timed out"));
+ listener.onError(new VideoFrameProcessingException("Release timed out"));
}
releaseFuture.get();
} catch (ExecutionException e) {
- listener.onFrameProcessingError(new FrameProcessingException(e));
+ listener.onError(new VideoFrameProcessingException(e));
}
}
private Future> wrapTaskAndSubmitToExecutorService(
- FrameProcessingTask defaultPriorityTask, boolean isFlushOrReleaseTask) {
+ VideoFrameProcessingTask defaultPriorityTask, boolean isFlushOrReleaseTask) {
return singleThreadExecutorService.submit(
() -> {
try {
@@ -172,7 +172,7 @@ import java.util.concurrent.RejectedExecutionException;
}
}
- @Nullable FrameProcessingTask nextHighPriorityTask;
+ @Nullable VideoFrameProcessingTask nextHighPriorityTask;
while (true) {
synchronized (lock) {
// Lock only polling to prevent blocking the public method calls.
@@ -199,6 +199,6 @@ import java.util.concurrent.RejectedExecutionException;
}
shouldCancelTasks = true;
}
- listener.onFrameProcessingError(FrameProcessingException.from(exception));
+ listener.onError(VideoFrameProcessingException.from(exception));
}
}
diff --git a/libraries/effect/src/test/java/androidx/media3/effect/ChainingGlShaderProgramListenerTest.java b/libraries/effect/src/test/java/androidx/media3/effect/ChainingGlShaderProgramListenerTest.java
index 915295360b..28cadf9bc5 100644
--- a/libraries/effect/src/test/java/androidx/media3/effect/ChainingGlShaderProgramListenerTest.java
+++ b/libraries/effect/src/test/java/androidx/media3/effect/ChainingGlShaderProgramListenerTest.java
@@ -18,7 +18,7 @@ package androidx.media3.effect;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import androidx.media3.common.FrameProcessor;
+import androidx.media3.common.VideoFrameProcessor;
import androidx.media3.common.util.Util;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.After;
@@ -30,20 +30,22 @@ import org.junit.runner.RunWith;
public final class ChainingGlShaderProgramListenerTest {
private static final long EXECUTOR_WAIT_TIME_MS = 100;
- private final FrameProcessor.Listener mockFrameProcessorListener =
- mock(FrameProcessor.Listener.class);
- private final FrameProcessingTaskExecutor frameProcessingTaskExecutor =
- new FrameProcessingTaskExecutor(
+ private final VideoFrameProcessor.Listener mockFrameProcessorListener =
+ mock(VideoFrameProcessor.Listener.class);
+ private final VideoFrameProcessingTaskExecutor videoFrameProcessingTaskExecutor =
+ new VideoFrameProcessingTaskExecutor(
Util.newSingleThreadExecutor("Test"), mockFrameProcessorListener);
private final GlShaderProgram mockProducingGlShaderProgram = mock(GlShaderProgram.class);
private final GlShaderProgram mockConsumingGlShaderProgram = mock(GlShaderProgram.class);
private final ChainingGlShaderProgramListener chainingGlShaderProgramListener =
new ChainingGlShaderProgramListener(
- mockProducingGlShaderProgram, mockConsumingGlShaderProgram, frameProcessingTaskExecutor);
+ mockProducingGlShaderProgram,
+ mockConsumingGlShaderProgram,
+ videoFrameProcessingTaskExecutor);
@After
public void release() throws InterruptedException {
- frameProcessingTaskExecutor.release(/* releaseTask= */ () -> {}, EXECUTOR_WAIT_TIME_MS);
+ videoFrameProcessingTaskExecutor.release(/* releaseTask= */ () -> {}, EXECUTOR_WAIT_TIME_MS);
}
@Test
diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java
index 5d523c7be2..173e2f76ff 100644
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java
@@ -53,11 +53,11 @@ import androidx.media3.common.DrmInitData;
import androidx.media3.common.Effect;
import androidx.media3.common.Format;
import androidx.media3.common.FrameInfo;
-import androidx.media3.common.FrameProcessingException;
-import androidx.media3.common.FrameProcessor;
import androidx.media3.common.MimeTypes;
import androidx.media3.common.PlaybackException;
import androidx.media3.common.SurfaceInfo;
+import androidx.media3.common.VideoFrameProcessingException;
+import androidx.media3.common.VideoFrameProcessor;
import androidx.media3.common.VideoSize;
import androidx.media3.common.util.Log;
import androidx.media3.common.util.MediaFormatUtil;
@@ -148,7 +148,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
private final Context context;
private final VideoFrameReleaseHelper frameReleaseHelper;
private final EventDispatcher eventDispatcher;
- private final FrameProcessorManager frameProcessorManager;
+ private final VideoFrameProcessorManager videoFrameProcessorManager;
private final long allowedJoiningTimeMs;
private final int maxDroppedFramesToNotify;
private final boolean deviceNeedsNoPostProcessWorkaround;
@@ -352,7 +352,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
this.context = context.getApplicationContext();
frameReleaseHelper = new VideoFrameReleaseHelper(this.context);
eventDispatcher = new EventDispatcher(eventHandler, eventListener);
- frameProcessorManager = new FrameProcessorManager(frameReleaseHelper, /* renderer= */ this);
+ videoFrameProcessorManager =
+ new VideoFrameProcessorManager(frameReleaseHelper, /* renderer= */ this);
deviceNeedsNoPostProcessWorkaround = deviceNeedsNoPostProcessWorkaround();
joiningDeadlineMs = C.TIME_UNSET;
scalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
@@ -563,8 +564,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
@Override
protected void onPositionReset(long positionUs, boolean joining) throws ExoPlaybackException {
super.onPositionReset(positionUs, joining);
- if (frameProcessorManager.isEnabled()) {
- frameProcessorManager.flush();
+ if (videoFrameProcessorManager.isEnabled()) {
+ videoFrameProcessorManager.flush();
}
clearRenderedFirstFrame();
frameReleaseHelper.onPositionReset();
@@ -581,8 +582,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
@Override
public boolean isEnded() {
boolean isEnded = super.isEnded();
- if (frameProcessorManager.isEnabled()) {
- isEnded &= frameProcessorManager.releasedLastFrame();
+ if (videoFrameProcessorManager.isEnabled()) {
+ isEnded &= videoFrameProcessorManager.releasedLastFrame();
}
return isEnded;
}
@@ -590,7 +591,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
@Override
public boolean isReady() {
if (super.isReady()
- && (!frameProcessorManager.isEnabled() || frameProcessorManager.isReady())
+ && (!videoFrameProcessorManager.isEnabled() || videoFrameProcessorManager.isReady())
&& (renderedFirstFrameAfterReset
|| (placeholderSurface != null && displaySurface == placeholderSurface)
|| getCodec() == null
@@ -650,8 +651,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
try {
super.onReset();
} finally {
- if (frameProcessorManager.isEnabled()) {
- frameProcessorManager.reset();
+ if (videoFrameProcessorManager.isEnabled()) {
+ videoFrameProcessorManager.reset();
}
if (placeholderSurface != null) {
releasePlaceholderSurface();
@@ -691,14 +692,14 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
case MSG_SET_VIDEO_EFFECTS:
@SuppressWarnings("unchecked")
List When frame processing is {@linkplain FrameProcessorManager#isEnabled()} enabled}, this
- * method renders to {@link FrameProcessorManager}'s {@linkplain
- * FrameProcessorManager#getInputSurface() input surface}.
+ * When video frame processing is {@linkplain VideoFrameProcessorManager#isEnabled()} enabled},
+ * this method renders to {@link VideoFrameProcessorManager}'s {@linkplain
+ * VideoFrameProcessorManager#getInputSurface() input surface}.
*
* @param codec The codec that owns the output buffer.
* @param index The index of the output buffer to drop.
@@ -1548,7 +1550,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
TraceUtil.endSection();
decoderCounters.renderedOutputBufferCount++;
consecutiveDroppedFrameCount = 0;
- if (!frameProcessorManager.isEnabled()) {
+ if (!videoFrameProcessorManager.isEnabled()) {
lastRenderRealtimeUs = SystemClock.elapsedRealtime() * 1000;
maybeNotifyVideoSizeChanged(decodedVideoSize);
maybeNotifyRenderedFirstFrame();
@@ -1559,9 +1561,9 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
* Renders the output buffer with the specified index. This method is only called if the platform
* API version of the device is 21 or later.
*
- * When frame processing is {@linkplain FrameProcessorManager#isEnabled()} enabled}, this
- * method renders to {@link FrameProcessorManager}'s {@linkplain
- * FrameProcessorManager#getInputSurface() input surface}.
+ * When video frame processing is {@linkplain VideoFrameProcessorManager#isEnabled()} enabled},
+ * this method renders to {@link VideoFrameProcessorManager}'s {@linkplain
+ * VideoFrameProcessorManager#getInputSurface() input surface}.
*
* @param codec The codec that owns the output buffer.
* @param index The index of the output buffer to drop.
@@ -1576,7 +1578,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
TraceUtil.endSection();
decoderCounters.renderedOutputBufferCount++;
consecutiveDroppedFrameCount = 0;
- if (!frameProcessorManager.isEnabled()) {
+ if (!videoFrameProcessorManager.isEnabled()) {
lastRenderRealtimeUs = SystemClock.elapsedRealtime() * 1000;
maybeNotifyVideoSizeChanged(decodedVideoSize);
maybeNotifyRenderedFirstFrame();
@@ -1834,8 +1836,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
return new MediaCodecVideoDecoderException(cause, codecInfo, displaySurface);
}
- /** Manages {@link FrameProcessor} interactions. */
- private static final class FrameProcessorManager {
+ /** Manages {@link VideoFrameProcessor} interactions. */
+ private static final class VideoFrameProcessorManager {
/** The threshold for releasing a processed frame. */
private static final long EARLY_THRESHOLD_US = 50_000;
@@ -1848,7 +1850,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
private final ArrayDeque Caller must ensure frame processing {@linkplain #isEnabled() is enabled} before calling
- * this method.
+ * Caller must ensure video frame processing {@linkplain #isEnabled() is enabled} before
+ * calling this method.
*/
public void flush() {
- checkStateNotNull(frameProcessor);
- frameProcessor.flush();
+ checkStateNotNull(videoFrameProcessor);
+ videoFrameProcessor.flush();
processedFramesTimestampsUs.clear();
handler.removeCallbacksAndMessages(/* token= */ null);
@@ -1939,14 +1945,14 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
/**
- * Tries to enable frame processing.
+ * Tries to enable video frame processing.
*
- * Caller must ensure frame processing {@linkplain #isEnabled() is not enabled} before
+ * Caller must ensure video frame processing {@linkplain #isEnabled() is not enabled} before
* calling this method.
*
- * @param inputFormat The {@link Format} that is input into the {@link FrameProcessor}.
- * @return Whether frame processing is enabled.
- * @throws ExoPlaybackException When enabling the {@link FrameProcessor} failed.
+ * @param inputFormat The {@link Format} that is input into the {@link VideoFrameProcessor}.
+ * @return Whether video frame processing is enabled.
+ * @throws ExoPlaybackException When enabling the {@link VideoFrameProcessor} failed.
*/
@CanIgnoreReturnValue
public boolean maybeEnable(Format inputFormat) throws ExoPlaybackException {
@@ -1981,11 +1987,11 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
// Insert as the first effect as if the decoder has applied the rotation.
videoEffects.add(
/* index= */ 0,
- FrameProcessorAccessor.createRotationEffect(inputFormat.rotationDegrees));
+ VideoFrameProcessorAccessor.createRotationEffect(inputFormat.rotationDegrees));
}
- frameProcessor =
- FrameProcessorAccessor.getFrameProcessorFactory()
+ videoFrameProcessor =
+ VideoFrameProcessorAccessor.getFrameProcessorFactory()
.create(
renderer.context,
checkNotNull(videoEffects),
@@ -1995,19 +2001,20 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
/* isInputTextureExternal= */ true,
/* releaseFramesAutomatically= */ false,
/* executor= */ handler::post,
- new FrameProcessor.Listener() {
+ new VideoFrameProcessor.Listener() {
@Override
public void onOutputSizeChanged(int width, int height) {
- @Nullable Format inputFormat = FrameProcessorManager.this.inputFormat;
+ @Nullable Format inputFormat = VideoFrameProcessorManager.this.inputFormat;
checkStateNotNull(inputFormat);
// TODO(b/264889146): Handle Effect that changes output size based on pts.
processedFrameSize =
new VideoSize(
width,
height,
- // FrameProcessor is configured to produce rotation free frames.
+ // VideoFrameProcessor is configured to produce rotation free
+ // frames.
/* unappliedRotationDegrees= */ 0,
- // FrameProcessor always outputs pixelWidthHeightRatio 1.
+ // VideoFrameProcessor always outputs pixelWidthHeightRatio 1.
/* pixelWidthHeightRatio= */ 1.f);
pendingOutputSizeChange = true;
}
@@ -2031,27 +2038,27 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
@Override
- public void onFrameProcessingError(FrameProcessingException exception) {
+ public void onError(VideoFrameProcessingException exception) {
renderer.setPendingPlaybackException(
renderer.createRendererException(
exception,
inputFormat,
- PlaybackException.ERROR_CODE_FRAME_PROCESSING_FAILED));
+ PlaybackException.ERROR_CODE_VIDEO_FRAME_PROCESSING_FAILED));
}
@Override
- public void onFrameProcessingEnded() {
+ public void onEnded() {
throw new IllegalStateException();
}
});
} catch (Exception e) {
throw renderer.createRendererException(
- e, inputFormat, PlaybackException.ERROR_CODE_FRAME_PROCESSOR_INIT_FAILED);
+ e, inputFormat, PlaybackException.ERROR_CODE_VIDEO_FRAME_PROCESSOR_INIT_FAILED);
}
if (currentSurfaceAndSize != null) {
Size outputSurfaceSize = currentSurfaceAndSize.second;
- frameProcessor.setOutputSurfaceInfo(
+ videoFrameProcessor.setOutputSurfaceInfo(
new SurfaceInfo(
currentSurfaceAndSize.first,
outputSurfaceSize.getWidth(),
@@ -2063,20 +2070,20 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
/**
- * Returns the {@linkplain FrameProcessor#getInputSurface input surface} of the {@link
- * FrameProcessor}.
+ * Returns the {@linkplain VideoFrameProcessor#getInputSurface input surface} of the {@link
+ * VideoFrameProcessor}.
*
- * Caller must ensure the {@code FrameProcessorManager} {@link #isEnabled()} before calling
- * this method.
+ * Caller must ensure the {@code VideoFrameProcessorManager} {@link #isEnabled()} before
+ * calling this method.
*/
public Surface getInputSurface() {
- return checkNotNull(frameProcessor).getInputSurface();
+ return checkNotNull(videoFrameProcessor).getInputSurface();
}
/**
* Sets the output surface info.
*
- * @param outputSurface The {@link Surface} to which {@link FrameProcessor} outputs.
+ * @param outputSurface The {@link Surface} to which {@link VideoFrameProcessor} outputs.
* @param outputResolution The {@link Size} of the output resolution.
*/
public void setOutputSurfaceInfo(Surface outputSurface, Size outputResolution) {
@@ -2087,7 +2094,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
currentSurfaceAndSize = Pair.create(outputSurface, outputResolution);
if (isEnabled()) {
- checkNotNull(frameProcessor)
+ checkNotNull(videoFrameProcessor)
.setOutputSurfaceInfo(
new SurfaceInfo(
outputSurface, outputResolution.getWidth(), outputResolution.getHeight()));
@@ -2097,22 +2104,22 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
/**
* Clears the set output surface info.
*
- * Caller must ensure the {@code FrameProcessorManager} {@link #isEnabled()} before calling
- * this method.
+ * Caller must ensure the {@code VideoFrameProcessorManager} {@link #isEnabled()} before
+ * calling this method.
*/
public void clearOutputSurfaceInfo() {
- checkNotNull(frameProcessor).setOutputSurfaceInfo(null);
+ checkNotNull(videoFrameProcessor).setOutputSurfaceInfo(null);
currentSurfaceAndSize = null;
}
/**
* Sets the input surface info.
*
- * Caller must ensure the {@code FrameProcessorManager} {@link #isEnabled()} before calling
- * this method.
+ * Caller must ensure the {@code VideoFrameProcessorManager} {@link #isEnabled()} before
+ * calling this method.
*/
public void setInputFormat(Format inputFormat) {
- checkNotNull(frameProcessor)
+ checkNotNull(videoFrameProcessor)
.setInputFrameInfo(
new FrameInfo.Builder(inputFormat.width, inputFormat.height)
.setPixelWidthHeightRatio(inputFormat.pixelWidthHeightRatio)
@@ -2127,7 +2134,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
}
- /** Sets the necessary {@link MediaFormat} keys for frame processing. */
+ /** Sets the necessary {@link MediaFormat} keys for video frame processing. */
@SuppressWarnings("InlinedApi")
public MediaFormat amendMediaFormatKeys(MediaFormat mediaFormat) {
if (Util.SDK_INT >= 29
@@ -2140,31 +2147,32 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
/**
* Must be called when the codec is initialized.
*
- * Sets the {@code frameProcessorMaxPendingFrameCount} based on the {@code codecName}.
+ * Sets the {@code videoFrameProcessorMaxPendingFrameCount} based on the {@code codecName}.
*/
public void onCodecInitialized(String codecName) {
- frameProcessorMaxPendingFrameCount =
+ videoFrameProcessorMaxPendingFrameCount =
Util.getMaxPendingFramesCountForMediaCodecEncoders(
renderer.context, codecName, /* requestedHdrToneMapping= */ false);
}
/**
- * Tries to {@linkplain FrameProcessor#registerInputFrame register an input frame}.
+ * Tries to {@linkplain VideoFrameProcessor#registerInputFrame register an input frame}.
*
- * Caller must ensure the {@code FrameProcessorManager} {@link #isEnabled()} before calling
- * this method.
+ * Caller must ensure the {@code VideoFrameProcessorManager} {@link #isEnabled()} before
+ * calling this method.
*
* @param format The {@link Format} associated with the frame.
* @param isLastBuffer Whether the buffer is the last from the decoder to register.
- * @return Whether {@link MediaCodec} should render the frame to {@link FrameProcessor}.
+ * @return Whether {@link MediaCodec} should render the frame to {@link VideoFrameProcessor}.
*/
public boolean maybeRegisterFrame(
Format format, long presentationTimestampUs, boolean isLastBuffer) {
- checkStateNotNull(frameProcessor);
- checkState(frameProcessorMaxPendingFrameCount != C.LENGTH_UNSET);
+ checkStateNotNull(videoFrameProcessor);
+ checkState(videoFrameProcessorMaxPendingFrameCount != C.LENGTH_UNSET);
checkState(!registeredLastFrame);
- if (frameProcessor.getPendingInputFrameCount() < frameProcessorMaxPendingFrameCount) {
- frameProcessor.registerInputFrame();
+ if (videoFrameProcessor.getPendingInputFrameCount()
+ < videoFrameProcessorMaxPendingFrameCount) {
+ videoFrameProcessor.registerInputFrame();
if (currentFrameFormat == null) {
currentFrameFormat = Pair.create(presentationTimestampUs, format);
@@ -2185,11 +2193,11 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
/**
* Releases the processed frames to the {@linkplain #setOutputSurfaceInfo output surface}.
*
- * Caller must ensure the {@code FrameProcessorManager} {@link #isEnabled()} before calling
- * this method.
+ * Caller must ensure the {@code VideoFrameProcessorManager} {@link #isEnabled()} before
+ * calling this method.
*/
public void releaseProcessedFrames(long positionUs, long elapsedRealtimeUs) {
- checkStateNotNull(frameProcessor);
+ checkStateNotNull(videoFrameProcessor);
while (!processedFramesTimestampsUs.isEmpty()) {
boolean isStarted = renderer.getState() == STATE_STARTED;
long bufferPresentationTimeUs = checkNotNull(processedFramesTimestampsUs.peek());
@@ -2205,7 +2213,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
boolean shouldReleaseFrameImmediately = renderer.shouldForceRender(positionUs, earlyUs);
if (shouldReleaseFrameImmediately) {
releaseProcessedFrameInternal(
- FrameProcessor.RELEASE_OUTPUT_FRAME_IMMEDIATELY, isLastFrame);
+ VideoFrameProcessor.RELEASE_OUTPUT_FRAME_IMMEDIATELY, isLastFrame);
break;
} else if (!isStarted || positionUs == renderer.initialPositionUs) {
return;
@@ -2224,9 +2232,9 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
earlyUs = (adjustedFrameReleaseTimeNs - System.nanoTime()) / 1000;
// TODO(b/238302341) Handle very late buffers and drop to key frame. Need to flush
- // FrameProcessor input frames in this case.
+ // VideoFrameProcessor input frames in this case.
if (renderer.shouldDropOutputBuffer(earlyUs, elapsedRealtimeUs, isLastFrame)) {
- releaseProcessedFrameInternal(FrameProcessor.DROP_OUTPUT_FRAME, isLastFrame);
+ releaseProcessedFrameInternal(VideoFrameProcessor.DROP_OUTPUT_FRAME, isLastFrame);
continue;
}
@@ -2249,12 +2257,12 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
/**
* Releases the resources.
*
- * Caller must ensure frame processing {@linkplain #isEnabled() is not enabled} before
+ * Caller must ensure video frame processing {@linkplain #isEnabled() is not enabled} before
* calling this method.
*/
public void reset() {
- checkNotNull(frameProcessor).release();
- frameProcessor = null;
+ checkNotNull(videoFrameProcessor).release();
+ videoFrameProcessor = null;
if (handler != null) {
handler.removeCallbacksAndMessages(/* token= */ null);
}
@@ -2266,11 +2274,11 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
private void releaseProcessedFrameInternal(long releaseTimeNs, boolean isLastFrame) {
- checkStateNotNull(frameProcessor);
- frameProcessor.releaseOutputFrame(releaseTimeNs);
+ checkStateNotNull(videoFrameProcessor);
+ videoFrameProcessor.releaseOutputFrame(releaseTimeNs);
processedFramesTimestampsUs.remove();
renderer.lastRenderRealtimeUs = SystemClock.elapsedRealtime() * 1000;
- if (releaseTimeNs != FrameProcessor.DROP_OUTPUT_FRAME) {
+ if (releaseTimeNs != VideoFrameProcessor.DROP_OUTPUT_FRAME) {
renderer.maybeNotifyRenderedFirstFrame();
}
if (isLastFrame) {
@@ -2278,12 +2286,12 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
}
- private static final class FrameProcessorAccessor {
+ private static final class VideoFrameProcessorAccessor {
private static @MonotonicNonNull Constructor> scaleToFitTransformationBuilderConstructor;
private static @MonotonicNonNull Method setRotationMethod;
private static @MonotonicNonNull Method buildScaleToFitTransformationMethod;
- private static @MonotonicNonNull Constructor> frameProcessorFactorConstructor;
+ private static @MonotonicNonNull Constructor> videoFrameProcessorFactoryConstructor;
public static Effect createRotationEffect(float rotationDegrees) throws Exception {
prepare();
@@ -2292,16 +2300,16 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
return (Effect) checkNotNull(buildScaleToFitTransformationMethod.invoke(builder));
}
- public static FrameProcessor.Factory getFrameProcessorFactory() throws Exception {
+ public static VideoFrameProcessor.Factory getFrameProcessorFactory() throws Exception {
prepare();
- return (FrameProcessor.Factory) frameProcessorFactorConstructor.newInstance();
+ return (VideoFrameProcessor.Factory) videoFrameProcessorFactoryConstructor.newInstance();
}
@EnsuresNonNull({
"ScaleToFitEffectBuilder",
"SetRotationMethod",
"SetRotationMethod",
- "FrameProcessorFactoryClass"
+ "VideoFrameProcessorFactoryClass"
})
private static void prepare() throws Exception {
if (scaleToFitTransformationBuilderConstructor == null
@@ -2316,9 +2324,9 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
buildScaleToFitTransformationMethod =
scaleToFitTransformationBuilderClass.getMethod("build");
}
- if (frameProcessorFactorConstructor == null) {
- frameProcessorFactorConstructor =
- Class.forName("androidx.media3.effect.GlEffectsFrameProcessor$Factory")
+ if (videoFrameProcessorFactoryConstructor == null) {
+ videoFrameProcessorFactoryConstructor =
+ Class.forName("androidx.media3.effect.DefaultVideoFrameProcessor$Factory")
.getConstructor();
}
}
diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/FrameProcessorTestRunner.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/VideoFrameProcessorTestRunner.java
similarity index 76%
rename from libraries/test_utils/src/main/java/androidx/media3/test/utils/FrameProcessorTestRunner.java
rename to libraries/test_utils/src/main/java/androidx/media3/test/utils/VideoFrameProcessorTestRunner.java
index e64850792b..3e3d430c69 100644
--- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/FrameProcessorTestRunner.java
+++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/VideoFrameProcessorTestRunner.java
@@ -33,9 +33,9 @@ import androidx.media3.common.ColorInfo;
import androidx.media3.common.DebugViewProvider;
import androidx.media3.common.Effect;
import androidx.media3.common.FrameInfo;
-import androidx.media3.common.FrameProcessingException;
-import androidx.media3.common.FrameProcessor;
import androidx.media3.common.SurfaceInfo;
+import androidx.media3.common.VideoFrameProcessingException;
+import androidx.media3.common.VideoFrameProcessor;
import androidx.media3.common.util.UnstableApi;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.MoreExecutors;
@@ -44,18 +44,18 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
-/** A test runner for {@link FrameProcessor} tests. */
+/** A test runner for {@link VideoFrameProcessor} tests. */
@UnstableApi
@RequiresApi(19)
-public final class FrameProcessorTestRunner {
+public final class VideoFrameProcessorTestRunner {
- /** A builder for {@link FrameProcessorTestRunner} instances. */
+ /** A builder for {@link VideoFrameProcessorTestRunner} instances. */
public static final class Builder {
/** The ratio of width over height, for each pixel in a frame. */
private static final float DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO = 1;
private @MonotonicNonNull String testId;
- private FrameProcessor.@MonotonicNonNull Factory frameProcessorFactory;
+ private VideoFrameProcessor.@MonotonicNonNull Factory videoFrameProcessorFactory;
private @MonotonicNonNull String videoAssetPath;
private @MonotonicNonNull String outputFileLabel;
private @MonotonicNonNull ImmutableList This is a required value.
*/
@CanIgnoreReturnValue
- public Builder setFrameProcessorFactory(FrameProcessor.Factory frameProcessorFactory) {
- this.frameProcessorFactory = frameProcessorFactory;
+ public Builder setVideoFrameProcessorFactory(
+ VideoFrameProcessor.Factory videoFrameProcessorFactory) {
+ this.videoFrameProcessorFactory = videoFrameProcessorFactory;
return this;
}
@@ -171,7 +172,7 @@ public final class FrameProcessorTestRunner {
return this;
}
/**
- * Sets the input track type. See {@link FrameProcessor.Factory#create}.
+ * Sets the input track type. See {@link VideoFrameProcessor.Factory#create}.
*
* The default value is {@code true}.
*/
@@ -181,14 +182,14 @@ public final class FrameProcessorTestRunner {
return this;
}
- public FrameProcessorTestRunner build() throws FrameProcessingException {
+ public VideoFrameProcessorTestRunner build() throws VideoFrameProcessingException {
checkStateNotNull(testId, "testId must be set.");
- checkStateNotNull(frameProcessorFactory, "frameProcessorFactory must be set.");
+ checkStateNotNull(videoFrameProcessorFactory, "videoFrameProcessorFactory must be set.");
checkStateNotNull(videoAssetPath, "videoAssetPath must be set.");
- return new FrameProcessorTestRunner(
+ return new VideoFrameProcessorTestRunner(
testId,
- frameProcessorFactory,
+ videoFrameProcessorFactory,
videoAssetPath,
outputFileLabel == null ? "" : outputFileLabel,
effects == null ? ImmutableList.of() : effects,
@@ -200,25 +201,25 @@ public final class FrameProcessorTestRunner {
}
/**
- * Time to wait for the decoded frame to populate the {@link FrameProcessor} instance's input
- * surface and the {@link FrameProcessor} to finish processing the frame, in milliseconds.
+ * Time to wait for the decoded frame to populate the {@link VideoFrameProcessor} instance's input
+ * surface and the {@link VideoFrameProcessor} to finish processing the frame, in milliseconds.
*/
- private static final int FRAME_PROCESSING_WAIT_MS = 5000;
+ private static final int VIDEO_FRAME_PROCESSING_WAIT_MS = 5000;
private final String testId;
private final String videoAssetPath;
private final String outputFileLabel;
private final float pixelWidthHeightRatio;
- private final AtomicReference Uses a {@link GlEffectsFrameProcessor} to process one frame, and checks that the actual output
- * matches expected output, either from a golden file or from another edit.
+ * Uses a {@link DefaultVideoFrameProcessor} to process one frame, and checks that the actual
+ * output matches expected output, either from a golden file or from another edit.
*/
// TODO(b/263395272): Move this test to effects/mh tests.
@RunWith(AndroidJUnit4.class)
@@ -75,12 +75,12 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
"OpenGL-based HDR to SDR tone mapping is unsupported below API 29.";
private static final String SKIP_REASON_NO_YUV = "Device lacks YUV extension support.";
- private @MonotonicNonNull FrameProcessorTestRunner frameProcessorTestRunner;
+ private @MonotonicNonNull VideoFrameProcessorTestRunner videoFrameProcessorTestRunner;
@After
public void release() {
- if (frameProcessorTestRunner != null) {
- frameProcessorTestRunner.release();
+ if (videoFrameProcessorTestRunner != null) {
+ videoFrameProcessorTestRunner.release();
}
}
@@ -114,7 +114,7 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
.setColorRange(C.COLOR_RANGE_LIMITED)
.setColorTransfer(C.COLOR_TRANSFER_GAMMA_2_2)
.build();
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setVideoAssetPath(INPUT_HLG_MP4_ASSET_STRING)
.setInputColorInfo(hlgColor)
@@ -124,7 +124,7 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
Bitmap actualBitmap;
try {
- actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
} catch (UnsupportedOperationException e) {
if (e.getMessage() != null
&& e.getMessage().equals(DecodeOneFrameUtil.NO_DECODER_SUPPORT_ERROR_STRING)) {
@@ -177,7 +177,7 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
.setColorRange(C.COLOR_RANGE_LIMITED)
.setColorTransfer(C.COLOR_TRANSFER_GAMMA_2_2)
.build();
- frameProcessorTestRunner =
+ videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId)
.setVideoAssetPath(INPUT_PQ_MP4_ASSET_STRING)
.setInputColorInfo(pqColor)
@@ -187,7 +187,7 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
Bitmap actualBitmap;
try {
- actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
+ actualBitmap = videoFrameProcessorTestRunner.processFirstFrameAndEnd();
} catch (UnsupportedOperationException e) {
if (e.getMessage() != null
&& e.getMessage().equals(DecodeOneFrameUtil.NO_DECODER_SUPPORT_ERROR_STRING)) {
@@ -209,10 +209,10 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
.isAtMost(MAXIMUM_DEVICE_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
}
- private FrameProcessorTestRunner.Builder getDefaultFrameProcessorTestRunnerBuilder(
+ private VideoFrameProcessorTestRunner.Builder getDefaultFrameProcessorTestRunnerBuilder(
String testId) {
- return new FrameProcessorTestRunner.Builder()
+ return new VideoFrameProcessorTestRunner.Builder()
.setTestId(testId)
- .setFrameProcessorFactory(new GlEffectsFrameProcessor.Factory());
+ .setVideoFrameProcessorFactory(new DefaultVideoFrameProcessor.Factory());
}
}
diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/Effects.java b/libraries/transformer/src/main/java/androidx/media3/transformer/Effects.java
index e984703223..22d8213623 100644
--- a/libraries/transformer/src/main/java/androidx/media3/transformer/Effects.java
+++ b/libraries/transformer/src/main/java/androidx/media3/transformer/Effects.java
@@ -16,11 +16,11 @@
package androidx.media3.transformer;
import androidx.media3.common.Effect;
-import androidx.media3.common.FrameProcessor;
import androidx.media3.common.MediaItem;
+import androidx.media3.common.VideoFrameProcessor;
import androidx.media3.common.audio.AudioProcessor;
import androidx.media3.common.util.UnstableApi;
-import androidx.media3.effect.GlEffectsFrameProcessor;
+import androidx.media3.effect.DefaultVideoFrameProcessor;
import com.google.common.collect.ImmutableList;
import java.util.List;
@@ -45,19 +45,19 @@ public final class Effects {
*/
public final ImmutableList This is equivalent to calling {@link Effects#Effects(List, List, FrameProcessor.Factory)}
- * with a {@link GlEffectsFrameProcessor.Factory}.
+ * This is equivalent to calling {@link Effects#Effects(List, List,
+ * VideoFrameProcessor.Factory)} with a {@link DefaultVideoFrameProcessor.Factory}.
*/
public Effects(List