ByteBufferGlEffect.Processor


public interface ByteBufferGlEffect.Processor<T>


A processor that takes in ByteBuffers that represent input image data, and produces results of type <T>.

All methods are called on the GL thread.

Parameters
<T>

The result type of running the processor.

Summary

Public methods

abstract Size
configure(int inputWidth, int inputHeight)

Configures the instance and returns the dimensions of the image required by processImage.

abstract void
finishProcessingAndBlend(
    GlTextureInfo outputFrame,
    long presentationTimeUs,
    T result
)

Finishes processing the frame at presentationTimeUs.

abstract GlRect
getScaledRegion(long presentationTimeUs)

Selects a region of the input texture that will be scaled to fill the image that is given to processImage.

abstract ListenableFuture<T>
processImage(ByteBufferGlEffect.Image image, long presentationTimeUs)

Processing the image data in the image.

abstract void

Releases all resources.

Public methods

configure

abstract Size configure(int inputWidth, int inputHeight)

Configures the instance and returns the dimensions of the image required by processImage.

When the returned dimensions differ from inputWidth and inputHeight, the image will be scaled based on getScaledRegion.

Parameters
int inputWidth

The input width in pixels.

int inputHeight

The input height in pixels.

Returns
Size

The size in pixels of the image data accepted by processImage.

finishProcessingAndBlend

abstract void finishProcessingAndBlend(
    GlTextureInfo outputFrame,
    long presentationTimeUs,
    T result
)

Finishes processing the frame at presentationTimeUs. Use this method to perform custom drawing on the output frame.

The outputFrame contains the image data corresponding to the frame at presentationTimeUs when this method is invoked.

Parameters
GlTextureInfo outputFrame

The texture info of the frame.

long presentationTimeUs

The presentation timestamp of the frame, in microseconds.

T result

The result of the asynchronous computation in processImage.

getScaledRegion

abstract GlRect getScaledRegion(long presentationTimeUs)

Selects a region of the input texture that will be scaled to fill the image that is given to processImage.

Called once per input frame.

The contents are scaled to fit the image dimensions returned by configure.

Parameters
long presentationTimeUs

The presentation time in microseconds.

Returns
GlRect

The rectangular region of the input image that will be scaled to fill the effect input image.

processImage

abstract ListenableFuture<T> processImage(ByteBufferGlEffect.Image image, long presentationTimeUs)

Processing the image data in the image.

Accessing image after the returned future is done or cancelled can lead to undefined behaviour.

Parameters
ByteBufferGlEffect.Image image

The image data.

long presentationTimeUs

The presentation time in microseconds.

Returns
ListenableFuture<T>

A ListenableFuture of the result.

release

abstract void release()

Releases all resources.

Throws
androidx.media3.common.VideoFrameProcessingException

If an error occurs while releasing resources.