Stay organized with collections Save and categorize content based on your preferences.

GlTextureProcessor

@UnstableApi
public interface GlTextureProcessor

Known direct subclasses
SingleFrameGlTextureProcessor

Manages a GLSL shader program for processing a frame.


Processes frames from one OpenGL 2D texture to another.

The GlTextureProcessor consumes input frames it accepts via queueInputFrame and surrenders each texture back to the caller via its listener once the texture's contents have been processed.

The GlTextureProcessor produces output frames asynchronously and notifies its owner when they are available via its listener. The GlTextureProcessor instance's owner must surrender the texture back to the GlTextureProcessor via releaseOutputFrame when it has finished processing it.

GlTextureProcessor implementations can choose to produce output frames before receiving input frames or process several input frames before producing an output frame. However, GlTextureProcessor implementations cannot assume that they will receive more than one input frame at a time, so they must process each input frame they accept even if they cannot produce output yet.

The methods in this interface must be called on the thread that owns the parent OpenGL context. If the implementation uses another OpenGL context, e.g., on another thread, it must configure it to share data with the context of thread the interface methods are called on.

Summary

Nested types

Listener for frame processing errors.

Listener for input-related frame processing events.

Listener for output-related frame processing events.

Public methods

abstract void
queueInputFrame(TextureInfo inputTexture, long presentationTimeUs)

Processes an input frame if possible.

abstract void

Releases all resources.

abstract void

Notifies the texture processor that the frame on the given output texture is no longer used and can be overwritten.

abstract void

Sets the ErrorListener.

abstract void

Sets the InputListener.

abstract void

Sets the OutputListener.

abstract void

Notifies the GlTextureProcessor that no further input frames belonging to the current input stream will be queued.

Public methods

queueInputFrame

abstract void queueInputFrame(TextureInfo inputTexture, long presentationTimeUs)

Processes an input frame if possible.

The GlTextureProcessor owns the accepted frame until it calls onInputFrameProcessed. The caller should not overwrite or release the texture before the GlTextureProcessor has finished processing it.

This method must only be called when the GlTextureProcessor can accept an input frame.

Parameters
TextureInfo inputTexture

A TextureInfo describing the texture containing the input frame.

long presentationTimeUs

The presentation timestamp of the input frame, in microseconds.

release

abstract void release()

Releases all resources.

Throws
androidx.media3.common.FrameProcessingException androidx.media3.common.FrameProcessingException

If an error occurs while releasing resources.

releaseOutputFrame

abstract void releaseOutputFrame(TextureInfo outputTexture)

Notifies the texture processor that the frame on the given output texture is no longer used and can be overwritten.

setErrorListener

abstract void setErrorListener(GlTextureProcessor.ErrorListener errorListener)

Sets the ErrorListener.

setInputListener

abstract void setInputListener(GlTextureProcessor.InputListener inputListener)

Sets the InputListener.

setOutputListener

abstract void setOutputListener(GlTextureProcessor.OutputListener outputListener)

Sets the OutputListener.

signalEndOfCurrentInputStream

abstract void signalEndOfCurrentInputStream()

Notifies the GlTextureProcessor that no further input frames belonging to the current input stream will be queued.

Input frames that are queued after this method is called belong to a different input stream, so presentation timestamps may reset to start from a smaller presentation timestamp than the last frame of the previous input stream.