Effect: Clarify threading for VideoFrameProcessor methods.

All methods in VideoFrameProcessor are expected to be called by the owning thread,
as far as I understand (vs. 10 threads each queuing frames/textures/streams, which
invalidates blocking done by registerInputStream and flush)

PiperOrigin-RevId: 582295240
This commit is contained in:
huangdarwin 2023-11-14 06:04:23 -08:00 committed by Copybara-Service
parent aa1ec981a3
commit 28c095d8d0
3 changed files with 3 additions and 22 deletions

View File

@ -40,6 +40,9 @@ import java.util.concurrent.Executor;
* <p>Manages its input {@link Surface}, which can be accessed via {@link #getInputSurface()}. The * <p>Manages its input {@link Surface}, which can be accessed via {@link #getInputSurface()}. The
* output {@link Surface} must be set by the caller using {@link * output {@link Surface} must be set by the caller using {@link
* #setOutputSurfaceInfo(SurfaceInfo)}. * #setOutputSurfaceInfo(SurfaceInfo)}.
*
* <p>{@code VideoFrameProcessor} instances can be created from any thread, but instance methods for
* each {@linkplain #registerInputStream stream} must be called from the same thread.
*/ */
@UnstableApi @UnstableApi
public interface VideoFrameProcessor { public interface VideoFrameProcessor {
@ -173,8 +176,6 @@ public interface VideoFrameProcessor {
* <p>Can be called many times after {@link #registerInputStream(int, List, FrameInfo) registering * <p>Can be called many times after {@link #registerInputStream(int, List, FrameInfo) registering
* the input stream} to put multiple frames in the same input stream. * the input stream} to put multiple frames in the same input stream.
* *
* <p>Can be called on any thread.
*
* @param inputBitmap The {@link Bitmap} queued to the {@code VideoFrameProcessor}. * @param inputBitmap The {@link Bitmap} queued to the {@code VideoFrameProcessor}.
* @param inStreamOffsetsUs The times within the current stream that the bitmap should be shown * @param inStreamOffsetsUs The times within the current stream that the bitmap should be shown
* at. The timestamps should be monotonically increasing. * at. The timestamps should be monotonically increasing.
@ -191,8 +192,6 @@ public interface VideoFrameProcessor {
* <p>It must be only called after {@link #setOnInputFrameProcessedListener} and {@link * <p>It must be only called after {@link #setOnInputFrameProcessedListener} and {@link
* #registerInputStream} have been called. * #registerInputStream} have been called.
* *
* <p>Can be called on any thread.
*
* @param textureId The ID of the texture queued to the {@code VideoFrameProcessor}. * @param textureId The ID of the texture queued to the {@code VideoFrameProcessor}.
* @param presentationTimeUs The presentation time of the queued texture, in microseconds. * @param presentationTimeUs The presentation time of the queued texture, in microseconds.
* @return Whether the texture was successfully queued. A return value of {@code false} indicates * @return Whether the texture was successfully queued. A return value of {@code false} indicates
@ -204,8 +203,6 @@ public interface VideoFrameProcessor {
/** /**
* Sets the {@link OnInputFrameProcessedListener}. * Sets the {@link OnInputFrameProcessedListener}.
* *
* <p>Can be called on any thread.
*
* @param listener The {@link OnInputFrameProcessedListener}. * @param listener The {@link OnInputFrameProcessedListener}.
*/ */
void setOnInputFrameProcessedListener(OnInputFrameProcessedListener listener); void setOnInputFrameProcessedListener(OnInputFrameProcessedListener listener);
@ -218,8 +215,6 @@ public interface VideoFrameProcessor {
* VideoFrameProcessor} until {@link #registerInputStream} is called with {@link * VideoFrameProcessor} until {@link #registerInputStream} is called with {@link
* #INPUT_TYPE_SURFACE}. * #INPUT_TYPE_SURFACE}.
* *
* <p>Can be called on any thread.
*
* @throws UnsupportedOperationException If the {@code VideoFrameProcessor} does not accept * @throws UnsupportedOperationException If the {@code VideoFrameProcessor} does not accept
* {@linkplain #INPUT_TYPE_SURFACE surface input}. * {@linkplain #INPUT_TYPE_SURFACE surface input}.
*/ */
@ -238,8 +233,6 @@ public interface VideoFrameProcessor {
* is when {@link Listener#onInputStreamRegistered(int, List, FrameInfo)} is called after the * is when {@link Listener#onInputStreamRegistered(int, List, FrameInfo)} is called after the
* underlying processing pipeline has been adapted to the registered input stream. * underlying processing pipeline has been adapted to the registered input stream.
* *
* <p>Can be called on any thread.
*
* @param inputType The {@link InputType} of the new input stream. * @param inputType The {@link InputType} of the new input stream.
* @param effects The list of {@link Effect effects} to apply to the new input stream. * @param effects The list of {@link Effect effects} to apply to the new input stream.
* @param frameInfo The {@link FrameInfo} of the new input stream. * @param frameInfo The {@link FrameInfo} of the new input stream.
@ -253,8 +246,6 @@ public interface VideoFrameProcessor {
* <p>Must be called before rendering a frame to the input surface. The caller must not render * <p>Must be called before rendering a frame to the input surface. The caller must not render
* frames to the {@linkplain #getInputSurface input surface} when {@code false} is returned. * frames to the {@linkplain #getInputSurface input surface} when {@code false} is returned.
* *
* <p>Can be called on any thread.
*
* @return Whether the input frame was successfully registered. If {@link * @return Whether the input frame was successfully registered. If {@link
* #registerInputStream(int, List, FrameInfo)} is called, this method returns {@code false} * #registerInputStream(int, List, FrameInfo)} is called, this method returns {@code false}
* until {@link Listener#onInputStreamRegistered(int, List, FrameInfo)} is called. Otherwise, * until {@link Listener#onInputStreamRegistered(int, List, FrameInfo)} is called. Otherwise,
@ -270,8 +261,6 @@ public interface VideoFrameProcessor {
/** /**
* Returns the number of input frames that have been made available to the {@code * Returns the number of input frames that have been made available to the {@code
* VideoFrameProcessor} but have not been processed yet. * VideoFrameProcessor} but have not been processed yet.
*
* <p>Can be called on any thread.
*/ */
int getPendingInputFrameCount(); int getPendingInputFrameCount();
@ -317,8 +306,6 @@ public interface VideoFrameProcessor {
/** /**
* Informs the {@code VideoFrameProcessor} that no further input frames should be accepted. * Informs the {@code VideoFrameProcessor} that no further input frames should be accepted.
* *
* <p>Can be called on any thread.
*
* @throws IllegalStateException If called more than once. * @throws IllegalStateException If called more than once.
*/ */
void signalEndOfInput(); void signalEndOfInput();
@ -347,8 +334,6 @@ public interface VideoFrameProcessor {
* *
* <p>This method blocks until all resources are released or releasing times out. * <p>This method blocks until all resources are released or releasing times out.
* *
* <p>Can be called on any thread.
*
* <p>This {@link VideoFrameProcessor} instance must not be used after this method is called. * <p>This {@link VideoFrameProcessor} instance must not be used after this method is called.
*/ */
void release(); void release();

View File

@ -36,8 +36,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/** /**
* Forwards a video frame produced from a {@link Bitmap} to a {@link GlShaderProgram} for * Forwards a video frame produced from a {@link Bitmap} to a {@link GlShaderProgram} for
* consumption. * consumption.
*
* <p>Public methods in this class can be called from any thread.
*/ */
@UnstableApi @UnstableApi
/* package */ final class BitmapTextureManager extends TextureManager { /* package */ final class BitmapTextureManager extends TextureManager {

View File

@ -29,8 +29,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/** /**
* Forwards frames made available via {@linkplain GLES10#GL_TEXTURE_2D traditional GLES textures} to * Forwards frames made available via {@linkplain GLES10#GL_TEXTURE_2D traditional GLES textures} to
* a {@link GlShaderProgram} for consumption. * a {@link GlShaderProgram} for consumption.
*
* <p>Public methods in this class can be called from any thread.
*/ */
/* package */ final class TexIdTextureManager extends TextureManager { /* package */ final class TexIdTextureManager extends TextureManager {
private final FrameConsumptionManager frameConsumptionManager; private final FrameConsumptionManager frameConsumptionManager;