Change argument order to match API council suggestion

By putting Listener as the last argument.

PiperOrigin-RevId: 493100906
This commit is contained in:
claincly 2022-12-05 21:42:47 +00:00 committed by Ian Baker
parent 7ea74444f3
commit 02bf7594e2
6 changed files with 55 additions and 55 deletions

View File

@ -45,8 +45,6 @@ public interface FrameProcessor {
* Creates a new {@link FrameProcessor} instance.
*
* @param context A {@link Context}.
* @param listener A {@link Listener}.
* @param executor The {@link Executor} on which the {@code listener} is invoked.
* @param effects The {@link Effect} instances to apply to each frame.
* @param debugViewProvider A {@link DebugViewProvider}.
* @param colorInfo The {@link ColorInfo} for input and output frames.
@ -55,18 +53,20 @@ public interface FrameProcessor {
* automatically as {@link FrameProcessor} is done processing them. If {@code false}, the
* {@link FrameProcessor} 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}.
*/
FrameProcessor create(
Context context,
Listener listener,
Executor executor,
List<Effect> effects,
DebugViewProvider debugViewProvider,
ColorInfo colorInfo,
boolean releaseFramesAutomatically)
boolean releaseFramesAutomatically,
Executor executor,
Listener listener)
throws FrameProcessingException;
}

View File

@ -281,6 +281,14 @@ public final class GlEffectsFrameProcessorFrameReleaseTest {
new GlEffectsFrameProcessor.Factory()
.create(
getApplicationContext(),
ImmutableList.of(
(GlEffect)
(context, useHdr) ->
new BlankFrameProducer(inputPresentationTimesUs, useHdr)),
DebugViewProvider.NONE,
ColorInfo.SDR_BT709_LIMITED,
releaseFramesAutomatically,
MoreExecutors.directExecutor(),
new FrameProcessor.Listener() {
@Override
public void onOutputSizeChanged(int width, int height) {
@ -314,15 +322,7 @@ public final class GlEffectsFrameProcessorFrameReleaseTest {
@Override
public void onFrameProcessingEnded() {}
},
MoreExecutors.directExecutor(),
ImmutableList.of(
(GlEffect)
(context, useHdr) ->
new BlankFrameProducer(inputPresentationTimesUs, useHdr)),
DebugViewProvider.NONE,
ColorInfo.SDR_BT709_LIMITED,
releaseFramesAutomatically));
}));
glEffectsFrameProcessor.setInputFrameInfo(
new FrameInfo(WIDTH, HEIGHT, /* pixelWidthHeightRatio= */ 1, /* streamOffsetUs= */ 0));

View File

@ -416,6 +416,11 @@ public final class GlEffectsFrameProcessorPixelTest {
new GlEffectsFrameProcessor.Factory()
.create(
getApplicationContext(),
effects,
DebugViewProvider.NONE,
ColorInfo.SDR_BT709_LIMITED,
/* releaseFramesAutomatically= */ true,
MoreExecutors.directExecutor(),
new FrameProcessor.Listener() {
@Override
public void onOutputSizeChanged(int width, int height) {
@ -441,12 +446,7 @@ public final class GlEffectsFrameProcessorPixelTest {
public void onFrameProcessingEnded() {
frameProcessingEnded = true;
}
},
MoreExecutors.directExecutor(),
effects,
DebugViewProvider.NONE,
ColorInfo.SDR_BT709_LIMITED,
/* releaseFramesAutomatically= */ true));
}));
DecodeOneFrameUtil.decodeOneAssetFileFrame(
INPUT_MP4_ASSET_STRING,
new DecodeOneFrameUtil.Listener() {

View File

@ -69,11 +69,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private final EGLDisplay eglDisplay;
private final EGLContext eglContext;
private final DebugViewProvider debugViewProvider;
private final FrameProcessor.Listener frameProcessorListener;
private final Executor frameProcessorListenerExecutor;
private final boolean sampleFromExternalTexture;
private final ColorInfo colorInfo;
private final boolean releaseFramesAutomatically;
private final Executor frameProcessorListenerExecutor;
private final FrameProcessor.Listener frameProcessorListener;
private final float[] textureTransformMatrix;
private final Queue<Long> streamOffsetUsQueue;
private final Queue<Pair<TextureInfo, Long>> availableFrames;
@ -102,23 +102,23 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
EGLContext eglContext,
ImmutableList<GlMatrixTransformation> matrixTransformations,
ImmutableList<RgbMatrix> rgbMatrices,
FrameProcessor.Listener frameProcessorListener,
Executor frameProcessorListenerExecutor,
DebugViewProvider debugViewProvider,
boolean sampleFromExternalTexture,
ColorInfo colorInfo,
boolean releaseFramesAutomatically) {
boolean releaseFramesAutomatically,
Executor frameProcessorListenerExecutor,
FrameProcessor.Listener frameProcessorListener) {
this.context = context;
this.matrixTransformations = matrixTransformations;
this.rgbMatrices = rgbMatrices;
this.eglDisplay = eglDisplay;
this.eglContext = eglContext;
this.debugViewProvider = debugViewProvider;
this.frameProcessorListener = frameProcessorListener;
this.frameProcessorListenerExecutor = frameProcessorListenerExecutor;
this.sampleFromExternalTexture = sampleFromExternalTexture;
this.colorInfo = colorInfo;
this.releaseFramesAutomatically = releaseFramesAutomatically;
this.frameProcessorListenerExecutor = frameProcessorListenerExecutor;
this.frameProcessorListener = frameProcessorListener;
textureTransformMatrix = GlUtil.create4x4IdentityMatrix();
streamOffsetUsQueue = new ConcurrentLinkedQueue<>();

View File

@ -68,12 +68,12 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
@Override
public GlEffectsFrameProcessor create(
Context context,
Listener listener,
Executor listenerExecutor,
List<Effect> effects,
DebugViewProvider debugViewProvider,
ColorInfo colorInfo,
boolean releaseFramesAutomatically)
boolean releaseFramesAutomatically,
Executor listenerExecutor,
Listener listener)
throws FrameProcessingException {
// TODO(b/261188041) Add tests to verify the Listener is invoked on the given Executor.
ExecutorService singleThreadExecutorService = Util.newSingleThreadExecutor(THREAD_NAME);
@ -83,13 +83,13 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
() ->
createOpenGlObjectsAndFrameProcessor(
context,
listener,
listenerExecutor,
effects,
debugViewProvider,
colorInfo,
releaseFramesAutomatically,
singleThreadExecutorService));
singleThreadExecutorService,
listenerExecutor,
listener));
try {
return glFrameProcessorFuture.get();
@ -115,13 +115,13 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
@WorkerThread
private static GlEffectsFrameProcessor createOpenGlObjectsAndFrameProcessor(
Context context,
Listener listener,
Executor executor,
List<Effect> effects,
DebugViewProvider debugViewProvider,
ColorInfo colorInfo,
boolean releaseFramesAutomatically,
ExecutorService singleThreadExecutorService)
ExecutorService singleThreadExecutorService,
Executor executor,
Listener listener)
throws GlUtil.GlException, FrameProcessingException {
checkState(Thread.currentThread().getName().equals(THREAD_NAME));
@ -140,11 +140,11 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
effects,
eglDisplay,
eglContext,
listener,
executor,
debugViewProvider,
colorInfo,
releaseFramesAutomatically);
releaseFramesAutomatically,
executor,
listener);
FrameProcessingTaskExecutor frameProcessingTaskExecutor =
new FrameProcessingTaskExecutor(singleThreadExecutorService, listener);
chainTextureProcessorsWithListeners(
@ -174,11 +174,11 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
List<Effect> effects,
EGLDisplay eglDisplay,
EGLContext eglContext,
Listener listener,
Executor executor,
DebugViewProvider debugViewProvider,
ColorInfo colorInfo,
boolean releaseFramesAutomatically)
boolean releaseFramesAutomatically,
Executor executor,
Listener listener)
throws FrameProcessingException {
ImmutableList.Builder<GlTextureProcessor> textureProcessorListBuilder =
new ImmutableList.Builder<>();
@ -232,12 +232,12 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
eglContext,
matrixTransformationListBuilder.build(),
rgbMatrixListBuilder.build(),
listener,
executor,
debugViewProvider,
sampleFromExternalTexture,
colorInfo,
releaseFramesAutomatically));
releaseFramesAutomatically,
executor,
listener));
return textureProcessorListBuilder.build();
}

View File

@ -159,6 +159,15 @@ import org.checkerframework.dataflow.qual.Pure;
frameProcessor =
frameProcessorFactory.create(
context,
effectsListBuilder.build(),
debugViewProvider,
// HDR colors are only used if the MediaCodec encoder supports FEATURE_HdrEditing.
// This implies that the OpenGL EXT_YUV_target extension is supported and hence the
// default FrameProcessor, GlEffectsFrameProcessor, also supports HDR. Otherwise, tone
// mapping is applied, which ensures the decoder outputs SDR output for an HDR input.
encoderWrapper.getSupportedInputColor(),
/* releaseFramesAutomatically= */ true,
MoreExecutors.directExecutor(),
new FrameProcessor.Listener() {
private long lastProcessedFramePresentationTimeUs;
@ -195,16 +204,7 @@ import org.checkerframework.dataflow.qual.Pure;
listener.onTransformationError(exception);
}
}
},
MoreExecutors.directExecutor(),
effectsListBuilder.build(),
debugViewProvider,
// HDR colors are only used if the MediaCodec encoder supports FEATURE_HdrEditing.
// This implies that the OpenGL EXT_YUV_target extension is supported and hence the
// default FrameProcessor, GlEffectsFrameProcessor, also supports HDR. Otherwise, tone
// mapping is applied, which ensures the decoder outputs SDR output for an HDR input.
encoderWrapper.getSupportedInputColor(),
/* releaseFramesAutomatically= */ true);
});
} catch (FrameProcessingException e) {
throw TransformationException.createForFrameProcessingException(
e, TransformationException.ERROR_CODE_FRAME_PROCESSING_FAILED);