Change argument order to match API council suggestion
By putting Listener as the last argument. PiperOrigin-RevId: 493100906
This commit is contained in:
parent
7ea74444f3
commit
02bf7594e2
@ -45,8 +45,6 @@ public interface FrameProcessor {
|
|||||||
* Creates a new {@link FrameProcessor} instance.
|
* Creates a new {@link FrameProcessor} instance.
|
||||||
*
|
*
|
||||||
* @param context A {@link Context}.
|
* @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 effects The {@link Effect} instances to apply to each frame.
|
||||||
* @param debugViewProvider A {@link DebugViewProvider}.
|
* @param debugViewProvider A {@link DebugViewProvider}.
|
||||||
* @param colorInfo The {@link ColorInfo} for input and output frames.
|
* @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
|
* automatically as {@link FrameProcessor} is done processing them. If {@code false}, the
|
||||||
* {@link FrameProcessor} will block until {@link #releaseOutputFrame(long)} is called, to
|
* {@link FrameProcessor} will block until {@link #releaseOutputFrame(long)} is called, to
|
||||||
* render or drop the frame.
|
* 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.
|
* @return A new instance.
|
||||||
* @throws FrameProcessingException If a problem occurs while creating the {@link
|
* @throws FrameProcessingException If a problem occurs while creating the {@link
|
||||||
* FrameProcessor}.
|
* FrameProcessor}.
|
||||||
*/
|
*/
|
||||||
FrameProcessor create(
|
FrameProcessor create(
|
||||||
Context context,
|
Context context,
|
||||||
Listener listener,
|
|
||||||
Executor executor,
|
|
||||||
List<Effect> effects,
|
List<Effect> effects,
|
||||||
DebugViewProvider debugViewProvider,
|
DebugViewProvider debugViewProvider,
|
||||||
ColorInfo colorInfo,
|
ColorInfo colorInfo,
|
||||||
boolean releaseFramesAutomatically)
|
boolean releaseFramesAutomatically,
|
||||||
|
Executor executor,
|
||||||
|
Listener listener)
|
||||||
throws FrameProcessingException;
|
throws FrameProcessingException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,6 +281,14 @@ public final class GlEffectsFrameProcessorFrameReleaseTest {
|
|||||||
new GlEffectsFrameProcessor.Factory()
|
new GlEffectsFrameProcessor.Factory()
|
||||||
.create(
|
.create(
|
||||||
getApplicationContext(),
|
getApplicationContext(),
|
||||||
|
ImmutableList.of(
|
||||||
|
(GlEffect)
|
||||||
|
(context, useHdr) ->
|
||||||
|
new BlankFrameProducer(inputPresentationTimesUs, useHdr)),
|
||||||
|
DebugViewProvider.NONE,
|
||||||
|
ColorInfo.SDR_BT709_LIMITED,
|
||||||
|
releaseFramesAutomatically,
|
||||||
|
MoreExecutors.directExecutor(),
|
||||||
new FrameProcessor.Listener() {
|
new FrameProcessor.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void onOutputSizeChanged(int width, int height) {
|
public void onOutputSizeChanged(int width, int height) {
|
||||||
@ -314,15 +322,7 @@ public final class GlEffectsFrameProcessorFrameReleaseTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFrameProcessingEnded() {}
|
public void onFrameProcessingEnded() {}
|
||||||
},
|
}));
|
||||||
MoreExecutors.directExecutor(),
|
|
||||||
ImmutableList.of(
|
|
||||||
(GlEffect)
|
|
||||||
(context, useHdr) ->
|
|
||||||
new BlankFrameProducer(inputPresentationTimesUs, useHdr)),
|
|
||||||
DebugViewProvider.NONE,
|
|
||||||
ColorInfo.SDR_BT709_LIMITED,
|
|
||||||
releaseFramesAutomatically));
|
|
||||||
|
|
||||||
glEffectsFrameProcessor.setInputFrameInfo(
|
glEffectsFrameProcessor.setInputFrameInfo(
|
||||||
new FrameInfo(WIDTH, HEIGHT, /* pixelWidthHeightRatio= */ 1, /* streamOffsetUs= */ 0));
|
new FrameInfo(WIDTH, HEIGHT, /* pixelWidthHeightRatio= */ 1, /* streamOffsetUs= */ 0));
|
||||||
|
@ -416,6 +416,11 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
new GlEffectsFrameProcessor.Factory()
|
new GlEffectsFrameProcessor.Factory()
|
||||||
.create(
|
.create(
|
||||||
getApplicationContext(),
|
getApplicationContext(),
|
||||||
|
effects,
|
||||||
|
DebugViewProvider.NONE,
|
||||||
|
ColorInfo.SDR_BT709_LIMITED,
|
||||||
|
/* releaseFramesAutomatically= */ true,
|
||||||
|
MoreExecutors.directExecutor(),
|
||||||
new FrameProcessor.Listener() {
|
new FrameProcessor.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void onOutputSizeChanged(int width, int height) {
|
public void onOutputSizeChanged(int width, int height) {
|
||||||
@ -441,12 +446,7 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
public void onFrameProcessingEnded() {
|
public void onFrameProcessingEnded() {
|
||||||
frameProcessingEnded = true;
|
frameProcessingEnded = true;
|
||||||
}
|
}
|
||||||
},
|
}));
|
||||||
MoreExecutors.directExecutor(),
|
|
||||||
effects,
|
|
||||||
DebugViewProvider.NONE,
|
|
||||||
ColorInfo.SDR_BT709_LIMITED,
|
|
||||||
/* releaseFramesAutomatically= */ true));
|
|
||||||
DecodeOneFrameUtil.decodeOneAssetFileFrame(
|
DecodeOneFrameUtil.decodeOneAssetFileFrame(
|
||||||
INPUT_MP4_ASSET_STRING,
|
INPUT_MP4_ASSET_STRING,
|
||||||
new DecodeOneFrameUtil.Listener() {
|
new DecodeOneFrameUtil.Listener() {
|
||||||
|
@ -69,11 +69,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
private final EGLDisplay eglDisplay;
|
private final EGLDisplay eglDisplay;
|
||||||
private final EGLContext eglContext;
|
private final EGLContext eglContext;
|
||||||
private final DebugViewProvider debugViewProvider;
|
private final DebugViewProvider debugViewProvider;
|
||||||
private final FrameProcessor.Listener frameProcessorListener;
|
|
||||||
private final Executor frameProcessorListenerExecutor;
|
|
||||||
private final boolean sampleFromExternalTexture;
|
private final boolean sampleFromExternalTexture;
|
||||||
private final ColorInfo colorInfo;
|
private final ColorInfo colorInfo;
|
||||||
private final boolean releaseFramesAutomatically;
|
private final boolean releaseFramesAutomatically;
|
||||||
|
private final Executor frameProcessorListenerExecutor;
|
||||||
|
private final FrameProcessor.Listener frameProcessorListener;
|
||||||
private final float[] textureTransformMatrix;
|
private final float[] textureTransformMatrix;
|
||||||
private final Queue<Long> streamOffsetUsQueue;
|
private final Queue<Long> streamOffsetUsQueue;
|
||||||
private final Queue<Pair<TextureInfo, Long>> availableFrames;
|
private final Queue<Pair<TextureInfo, Long>> availableFrames;
|
||||||
@ -102,23 +102,23 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
EGLContext eglContext,
|
EGLContext eglContext,
|
||||||
ImmutableList<GlMatrixTransformation> matrixTransformations,
|
ImmutableList<GlMatrixTransformation> matrixTransformations,
|
||||||
ImmutableList<RgbMatrix> rgbMatrices,
|
ImmutableList<RgbMatrix> rgbMatrices,
|
||||||
FrameProcessor.Listener frameProcessorListener,
|
|
||||||
Executor frameProcessorListenerExecutor,
|
|
||||||
DebugViewProvider debugViewProvider,
|
DebugViewProvider debugViewProvider,
|
||||||
boolean sampleFromExternalTexture,
|
boolean sampleFromExternalTexture,
|
||||||
ColorInfo colorInfo,
|
ColorInfo colorInfo,
|
||||||
boolean releaseFramesAutomatically) {
|
boolean releaseFramesAutomatically,
|
||||||
|
Executor frameProcessorListenerExecutor,
|
||||||
|
FrameProcessor.Listener frameProcessorListener) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.matrixTransformations = matrixTransformations;
|
this.matrixTransformations = matrixTransformations;
|
||||||
this.rgbMatrices = rgbMatrices;
|
this.rgbMatrices = rgbMatrices;
|
||||||
this.eglDisplay = eglDisplay;
|
this.eglDisplay = eglDisplay;
|
||||||
this.eglContext = eglContext;
|
this.eglContext = eglContext;
|
||||||
this.debugViewProvider = debugViewProvider;
|
this.debugViewProvider = debugViewProvider;
|
||||||
this.frameProcessorListener = frameProcessorListener;
|
|
||||||
this.frameProcessorListenerExecutor = frameProcessorListenerExecutor;
|
|
||||||
this.sampleFromExternalTexture = sampleFromExternalTexture;
|
this.sampleFromExternalTexture = sampleFromExternalTexture;
|
||||||
this.colorInfo = colorInfo;
|
this.colorInfo = colorInfo;
|
||||||
this.releaseFramesAutomatically = releaseFramesAutomatically;
|
this.releaseFramesAutomatically = releaseFramesAutomatically;
|
||||||
|
this.frameProcessorListenerExecutor = frameProcessorListenerExecutor;
|
||||||
|
this.frameProcessorListener = frameProcessorListener;
|
||||||
|
|
||||||
textureTransformMatrix = GlUtil.create4x4IdentityMatrix();
|
textureTransformMatrix = GlUtil.create4x4IdentityMatrix();
|
||||||
streamOffsetUsQueue = new ConcurrentLinkedQueue<>();
|
streamOffsetUsQueue = new ConcurrentLinkedQueue<>();
|
||||||
|
@ -68,12 +68,12 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
|
|||||||
@Override
|
@Override
|
||||||
public GlEffectsFrameProcessor create(
|
public GlEffectsFrameProcessor create(
|
||||||
Context context,
|
Context context,
|
||||||
Listener listener,
|
|
||||||
Executor listenerExecutor,
|
|
||||||
List<Effect> effects,
|
List<Effect> effects,
|
||||||
DebugViewProvider debugViewProvider,
|
DebugViewProvider debugViewProvider,
|
||||||
ColorInfo colorInfo,
|
ColorInfo colorInfo,
|
||||||
boolean releaseFramesAutomatically)
|
boolean releaseFramesAutomatically,
|
||||||
|
Executor listenerExecutor,
|
||||||
|
Listener listener)
|
||||||
throws FrameProcessingException {
|
throws FrameProcessingException {
|
||||||
// TODO(b/261188041) Add tests to verify the Listener is invoked on the given Executor.
|
// TODO(b/261188041) Add tests to verify the Listener is invoked on the given Executor.
|
||||||
ExecutorService singleThreadExecutorService = Util.newSingleThreadExecutor(THREAD_NAME);
|
ExecutorService singleThreadExecutorService = Util.newSingleThreadExecutor(THREAD_NAME);
|
||||||
@ -83,13 +83,13 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
|
|||||||
() ->
|
() ->
|
||||||
createOpenGlObjectsAndFrameProcessor(
|
createOpenGlObjectsAndFrameProcessor(
|
||||||
context,
|
context,
|
||||||
listener,
|
|
||||||
listenerExecutor,
|
|
||||||
effects,
|
effects,
|
||||||
debugViewProvider,
|
debugViewProvider,
|
||||||
colorInfo,
|
colorInfo,
|
||||||
releaseFramesAutomatically,
|
releaseFramesAutomatically,
|
||||||
singleThreadExecutorService));
|
singleThreadExecutorService,
|
||||||
|
listenerExecutor,
|
||||||
|
listener));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return glFrameProcessorFuture.get();
|
return glFrameProcessorFuture.get();
|
||||||
@ -115,13 +115,13 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
|
|||||||
@WorkerThread
|
@WorkerThread
|
||||||
private static GlEffectsFrameProcessor createOpenGlObjectsAndFrameProcessor(
|
private static GlEffectsFrameProcessor createOpenGlObjectsAndFrameProcessor(
|
||||||
Context context,
|
Context context,
|
||||||
Listener listener,
|
|
||||||
Executor executor,
|
|
||||||
List<Effect> effects,
|
List<Effect> effects,
|
||||||
DebugViewProvider debugViewProvider,
|
DebugViewProvider debugViewProvider,
|
||||||
ColorInfo colorInfo,
|
ColorInfo colorInfo,
|
||||||
boolean releaseFramesAutomatically,
|
boolean releaseFramesAutomatically,
|
||||||
ExecutorService singleThreadExecutorService)
|
ExecutorService singleThreadExecutorService,
|
||||||
|
Executor executor,
|
||||||
|
Listener listener)
|
||||||
throws GlUtil.GlException, FrameProcessingException {
|
throws GlUtil.GlException, FrameProcessingException {
|
||||||
checkState(Thread.currentThread().getName().equals(THREAD_NAME));
|
checkState(Thread.currentThread().getName().equals(THREAD_NAME));
|
||||||
|
|
||||||
@ -140,11 +140,11 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
|
|||||||
effects,
|
effects,
|
||||||
eglDisplay,
|
eglDisplay,
|
||||||
eglContext,
|
eglContext,
|
||||||
listener,
|
|
||||||
executor,
|
|
||||||
debugViewProvider,
|
debugViewProvider,
|
||||||
colorInfo,
|
colorInfo,
|
||||||
releaseFramesAutomatically);
|
releaseFramesAutomatically,
|
||||||
|
executor,
|
||||||
|
listener);
|
||||||
FrameProcessingTaskExecutor frameProcessingTaskExecutor =
|
FrameProcessingTaskExecutor frameProcessingTaskExecutor =
|
||||||
new FrameProcessingTaskExecutor(singleThreadExecutorService, listener);
|
new FrameProcessingTaskExecutor(singleThreadExecutorService, listener);
|
||||||
chainTextureProcessorsWithListeners(
|
chainTextureProcessorsWithListeners(
|
||||||
@ -174,11 +174,11 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
|
|||||||
List<Effect> effects,
|
List<Effect> effects,
|
||||||
EGLDisplay eglDisplay,
|
EGLDisplay eglDisplay,
|
||||||
EGLContext eglContext,
|
EGLContext eglContext,
|
||||||
Listener listener,
|
|
||||||
Executor executor,
|
|
||||||
DebugViewProvider debugViewProvider,
|
DebugViewProvider debugViewProvider,
|
||||||
ColorInfo colorInfo,
|
ColorInfo colorInfo,
|
||||||
boolean releaseFramesAutomatically)
|
boolean releaseFramesAutomatically,
|
||||||
|
Executor executor,
|
||||||
|
Listener listener)
|
||||||
throws FrameProcessingException {
|
throws FrameProcessingException {
|
||||||
ImmutableList.Builder<GlTextureProcessor> textureProcessorListBuilder =
|
ImmutableList.Builder<GlTextureProcessor> textureProcessorListBuilder =
|
||||||
new ImmutableList.Builder<>();
|
new ImmutableList.Builder<>();
|
||||||
@ -232,12 +232,12 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
|
|||||||
eglContext,
|
eglContext,
|
||||||
matrixTransformationListBuilder.build(),
|
matrixTransformationListBuilder.build(),
|
||||||
rgbMatrixListBuilder.build(),
|
rgbMatrixListBuilder.build(),
|
||||||
listener,
|
|
||||||
executor,
|
|
||||||
debugViewProvider,
|
debugViewProvider,
|
||||||
sampleFromExternalTexture,
|
sampleFromExternalTexture,
|
||||||
colorInfo,
|
colorInfo,
|
||||||
releaseFramesAutomatically));
|
releaseFramesAutomatically,
|
||||||
|
executor,
|
||||||
|
listener));
|
||||||
return textureProcessorListBuilder.build();
|
return textureProcessorListBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,6 +159,15 @@ import org.checkerframework.dataflow.qual.Pure;
|
|||||||
frameProcessor =
|
frameProcessor =
|
||||||
frameProcessorFactory.create(
|
frameProcessorFactory.create(
|
||||||
context,
|
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() {
|
new FrameProcessor.Listener() {
|
||||||
private long lastProcessedFramePresentationTimeUs;
|
private long lastProcessedFramePresentationTimeUs;
|
||||||
|
|
||||||
@ -195,16 +204,7 @@ import org.checkerframework.dataflow.qual.Pure;
|
|||||||
listener.onTransformationError(exception);
|
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) {
|
} catch (FrameProcessingException e) {
|
||||||
throw TransformationException.createForFrameProcessingException(
|
throw TransformationException.createForFrameProcessingException(
|
||||||
e, TransformationException.ERROR_CODE_FRAME_PROCESSING_FAILED);
|
e, TransformationException.ERROR_CODE_FRAME_PROCESSING_FAILED);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user