GlShaderProgram
@UnstableApi
public interface GlShaderProgram
BaseGlShaderProgram |
A base implementation of |
DebugViewShaderProgram |
|
PassthroughShaderProgram |
A |
SeparableConvolutionShaderProgram |
A |
TimestampAdjustmentShaderProgram |
Changes the frame timestamps using the |
Processes frames from one OpenGL 2D texture to another.
The GlShaderProgram 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 GlShaderProgram produces output frames asynchronously and notifies its owner when they are available via its listener. The GlShaderProgram instance's owner must surrender the texture back to the GlShaderProgram via releaseOutputFrame when it has finished processing it.
GlShaderProgram implementations can choose to produce output frames before receiving input frames or process several input frames before producing an output frame. However,
GlShaderProgram 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 |
|---|
public interface GlShaderProgram.ErrorListenerListener for video frame processing errors. |
public interface GlShaderProgram.InputListenerListener for input-related video frame processing events. |
public interface GlShaderProgram.OutputListenerListener for output-related video frame processing events. |
Public methods |
|
|---|---|
abstract void |
flush()Flushes the |
abstract void |
queueInputFrame(Processes an input frame if possible. |
abstract void |
release()Releases all resources. |
abstract void |
releaseOutputFrame(GlTextureInfo outputTexture)Notifies the |
abstract void |
setErrorListener(Sets the |
abstract void |
setInputListener(GlShaderProgram.InputListener inputListener)Sets the |
abstract void |
setOutputListener(GlShaderProgram.OutputListener outputListener)Sets the |
abstract void |
Notifies the |
Public methods
flush
abstract void flush()
Flushes the GlShaderProgram.
The GlShaderProgram should reclaim the ownership of its allocated textures, notify its InputListener about the flush event, and report its availability if necessary.
The implementation must not output frames until after this method returns.
queueInputFrame
abstract void queueInputFrame(
GlObjectsProvider glObjectsProvider,
GlTextureInfo inputTexture,
long presentationTimeUs
)
Processes an input frame if possible.
The GlShaderProgram owns the accepted frame until it calls onInputFrameProcessed. The caller should not overwrite or release the texture before the GlShaderProgram has finished processing it.
This method must only be called when the GlShaderProgram can accept an input frame.
| Parameters | |
|---|---|
GlObjectsProvider glObjectsProvider |
The |
GlTextureInfo inputTexture |
A |
long presentationTimeUs |
The presentation timestamp of the input frame, in microseconds. |
release
abstract void release()
Releases all resources.
| Throws | |
|---|---|
androidx.media3.common.VideoFrameProcessingException |
If an error occurs while releasing resources. |
releaseOutputFrame
abstract void releaseOutputFrame(GlTextureInfo outputTexture)
Notifies the GlShaderProgram that the frame on the given output texture is no longer used and can be overwritten.
setErrorListener
abstract void setErrorListener(
Executor executor,
GlShaderProgram.ErrorListener errorListener
)
Sets the ErrorListener.
The ErrorListener is invoked on the provided Executor.
setInputListener
abstract void setInputListener(GlShaderProgram.InputListener inputListener)
Sets the InputListener.
The InputListener should be invoked on the thread that owns the parent OpenGL context. For example, DefaultVideoFrameProcessor invokes the InputListener methods on its internal thread.
setOutputListener
abstract void setOutputListener(GlShaderProgram.OutputListener outputListener)
Sets the OutputListener.
The OutputListener should be invoked on the thread that owns the parent OpenGL context. For example, DefaultVideoFrameProcessor invokes the OutputListener methods on its internal thread.
signalEndOfCurrentInputStream
abstract void signalEndOfCurrentInputStream()
Notifies the GlShaderProgram 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.