Improve texture asset loader documentation

Add documentation for threading requirements at the class level (in
addition to existing documentation on the methods) to improve
discoverablility. Also fix a couple of nits in the javadoc (US English
spelling, avoid passive voice) and in `OnInputFrameProcessedListener`.

PiperOrigin-RevId: 546303732
This commit is contained in:
andrewlewis 2023-07-07 17:32:56 +01:00 committed by Rohit Singh
parent 4adb5d771e
commit a0bc8d95c2
2 changed files with 15 additions and 6 deletions

View File

@ -25,10 +25,12 @@ public interface OnInputFrameProcessedListener {
* Called when the given input frame has been processed. * Called when the given input frame has been processed.
* *
* @param textureId The identifier of the processed texture. * @param textureId The identifier of the processed texture.
* @param syncObject A GL sync object that has been inserted into the GL command stream after the * @param syncObject A GL sync object (see https://www.khronos.org/opengl/wiki/Sync_Object) that
* last write of texture. Value is 0 if and only if the {@code GLES30#glFenceSync} failed or * has been inserted into the GL command stream after the last use of the texture. Value is 0
* the EGL context version is less than openGL 3.0. The sync object must be {@link * if and only if the {@code GLES30#glFenceSync} failed or the EGL context version is less
* than OpenGL 3.0. The sync object must be {@link
* androidx.media3.common.util.GlUtil#deleteSyncObject deleted} after use. * androidx.media3.common.util.GlUtil#deleteSyncObject deleted} after use.
* @throws VideoFrameProcessingException Thrown if an error was encountered handling the event.
*/ */
void onInputFrameProcessed(int textureId, long syncObject) throws VideoFrameProcessingException; void onInputFrameProcessed(int textureId, long syncObject) throws VideoFrameProcessingException;
} }

View File

@ -36,9 +36,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
* android.opengl.GLES10#GL_TEXTURE_2D traditional GLES texture} instances. * android.opengl.GLES10#GL_TEXTURE_2D traditional GLES texture} instances.
* *
* <p>Typically instantiated in a custom {@link AssetLoader.Factory} saving a reference to the * <p>Typically instantiated in a custom {@link AssetLoader.Factory} saving a reference to the
* created {@link TextureAssetLoader}. Input is provided calling {@link #queueInputTexture} to * created {@link TextureAssetLoader}. Provide video frames as input by calling {@link
* provide all the video frames, then {@link #signalEndOfVideoInput() signalling the end of input} * #queueInputTexture}, then {@link #signalEndOfVideoInput() signal the end of input} when finished.
* when finished. * Those methods must be called from the same thread, which can be any thread.
*/ */
@UnstableApi @UnstableApi
public final class TextureAssetLoader implements AssetLoader { public final class TextureAssetLoader implements AssetLoader {
@ -59,6 +59,13 @@ public final class TextureAssetLoader implements AssetLoader {
* *
* <p>The {@link EditedMediaItem#durationUs}, {@link Format#width} and {@link Format#height} must * <p>The {@link EditedMediaItem#durationUs}, {@link Format#width} and {@link Format#height} must
* be set. * be set.
*
* @param editedMediaItem Information about the media item for which frames are provided.
* @param assetLoaderListener Listener for asset loading events.
* @param format Information about the format of video frames.
* @param frameProcessedListener Listener for the event when a frame has been processed. The
* listener receives a GL sync object (if supported) to allow reusing the texture after it's
* no longer in use.
*/ */
public TextureAssetLoader( public TextureAssetLoader(
EditedMediaItem editedMediaItem, EditedMediaItem editedMediaItem,