GlTextureFrameRenderer


@ExperimentalApi
class GlTextureFrameRenderer : RenderingPacketConsumer, GlShaderProgram.InputListener, FinalShaderProgramWrapper.Listener


A PacketConsumer implementation that renders GlTextureFrames to an output android.view.Surface.

Summary

Public companion functions

GlTextureFrameRenderer
create(
    context: Context,
    glExecutorService: ListeningExecutorService,
    glObjectsProvider: GlObjectsProvider,
    errorHandler: Consumer<VideoFrameProcessingException>,
    listener: GlTextureFrameRenderer.Listener
)

Creates a new instance of GlTextureFrameRenderer.

Public functions

open Unit
onFrameRendered(presentationTimeUs: Long)

Called when a frame is rendered to the output surface.

open Unit

Called when the GlShaderProgram has processed an input frame.

open Unit

Called when one input stream is fully processed following signalEndOfCurrentInputStream.

open Unit

Called when the GlShaderProgram is ready to accept another input frame.

open suspend Unit

Consumes a single GlTextureFrame, first configuring the renderer if required and queuing the frame to the shader program.

open suspend Unit

Releases all resources associated with this renderer.

open Unit

Updates the output surface information with new SurfaceInfo, or null if the surface is no longer available.

Inherited functions

From androidx.media3.effect.GlShaderProgram.InputListener
open Unit

Called when the GlShaderProgram has been flushed.

Public companion functions

create

fun create(
    context: Context,
    glExecutorService: ListeningExecutorService,
    glObjectsProvider: GlObjectsProvider,
    errorHandler: Consumer<VideoFrameProcessingException>,
    listener: GlTextureFrameRenderer.Listener
): GlTextureFrameRenderer

Creates a new instance of GlTextureFrameRenderer.

Parameters
context: Context

The application context.

glExecutorService: ListeningExecutorService

The executor service to be used for GL operations.

glObjectsProvider: GlObjectsProvider

Provider for GL objects (textures, buffers, etc.).

errorHandler: Consumer<VideoFrameProcessingException>

A consumer to handle any VideoFrameProcessingExceptions that occur.

listener: GlTextureFrameRenderer.Listener

A Listener to be notified of events from the renderer.

Public functions

onFrameRendered

open fun onFrameRendered(presentationTimeUs: Long): Unit

Called when a frame is rendered to the output surface.

onInputFrameProcessed

open fun onInputFrameProcessed(inputTexture: GlTextureInfo): Unit

Called when the GlShaderProgram has processed an input frame.

The implementation shall not assume the GlShaderProgram is ready to accept another input frame when this method is called.

Parameters
inputTexture: GlTextureInfo

The GlTextureInfo that was used to queue the input frame.

onInputStreamProcessed

open fun onInputStreamProcessed(): Unit

Called when one input stream is fully processed following signalEndOfCurrentInputStream.

onReadyToAcceptInputFrame

open fun onReadyToAcceptInputFrame(): Unit

Called when the GlShaderProgram is ready to accept another input frame.

For each time this method is called, queueInputFrame can be called once.

queuePacket

open suspend fun queuePacket(packet: PacketConsumer.Packet<GlTextureFrame>): Unit

Consumes a single GlTextureFrame, first configuring the renderer if required and queuing the frame to the shader program.

This method suspends until the frame is fully rendered. If the renderer is released while waiting, it gracefully exits.

release

open suspend fun release(): Unit

Releases all resources associated with this renderer.

This method cancels any pending render operations, releases the inputConsumer, and destroys the underlying GL shader program. It ensures that no further frames are processed after being called.

setRenderOutput

open fun setRenderOutput(output: SurfaceInfo?): Unit

Updates the output surface information with new SurfaceInfo, or null if the surface is no longer available.