TextureOverlay


@UnstableApi
public abstract class TextureOverlay

Known direct subclasses
Known indirect subclasses
DrawableOverlay

Creates a TextureOverlay from Drawable.

TextOverlay

Creates a TextureOverlay from text.


Creates overlays from OpenGL textures.

Summary

Public constructors

Public methods

void
configure(Size videoSize)

Set up resources for the overlay given the input video’s dimensions.

OverlaySettings
getOverlaySettings(long presentationTimeUs)

Returns the OverlaySettings controlling how the overlay is displayed at the specified timestamp.

abstract int
getTextureId(long presentationTimeUs)

Returns the overlay texture identifier displayed at the specified timestamp.

abstract Size
getTextureSize(long presentationTimeUs)

Returns the pixel width and height of the overlay texture displayed at the specified timestamp.

float[]
getVertexTransformation(long presentationTimeUs)

Returns a 4x4 OpenGL matrix, controlling how the vertices of the overlay are displayed at the specified timestamp.

void

Releases all resources.

Public constructors

TextureOverlay

public TextureOverlay()

Public methods

configure

public void configure(Size videoSize)

Set up resources for the overlay given the input video’s dimensions.

This method will be called before drawing the first frame and before drawing subsequent frames with different input dimensions.

Parameters
Size videoSize

The width and height of the input video, in pixels.

getOverlaySettings

public OverlaySettings getOverlaySettings(long presentationTimeUs)

Returns the OverlaySettings controlling how the overlay is displayed at the specified timestamp.

Parameters
long presentationTimeUs

The presentation timestamp of the current frame, in microseconds.

getTextureId

public abstract int getTextureId(long presentationTimeUs)

Returns the overlay texture identifier displayed at the specified timestamp.

Parameters
long presentationTimeUs

The presentation timestamp of the current frame, in microseconds.

Throws
androidx.media3.common.VideoFrameProcessingException

If an error occurs while processing or drawing the frame.

getTextureSize

public abstract Size getTextureSize(long presentationTimeUs)

Returns the pixel width and height of the overlay texture displayed at the specified timestamp.

This method must be called after getTextureId.

Parameters
long presentationTimeUs

The presentation timestamp of the current frame, in microseconds.

getVertexTransformation

public float[] getVertexTransformation(long presentationTimeUs)

Returns a 4x4 OpenGL matrix, controlling how the vertices of the overlay are displayed at the specified timestamp.

Applied before overlay settings.

Parameters
long presentationTimeUs

The presentation timestamp of the current frame, in microseconds.

release

public void release()

Releases all resources.

Throws
androidx.media3.common.VideoFrameProcessingException

If an error occurs while releasing resources.