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

GlEffectsFrameProcessor

@UnstableApi
public final class GlEffectsFrameProcessor implements FrameProcessor


A FrameProcessor implementation that applies GlEffect instances using OpenGL on a background thread.

Summary

Nested types

A factory for GlEffectsFrameProcessor instances.

Public fields

final Surface

Public methods

Surface

Returns the input Surface, where FrameProcessor consumes input frames from.

int

Returns the number of input frames that have been registered but not processed off the input surface yet.

void

Informs the FrameProcessor that a frame will be queued to its input surface.

void

Releases all resources.

void
releaseOutputFrame(long releaseTimeNs)

Releases the oldest unreleased output frame that has become available at the given releaseTimeNs.

void
setInputFrameInfo(FrameInfo inputFrameInfo)

Sets information about the input frames.

void

Sets the output surface and supporting information.

void

Informs the FrameProcessor that no further input frames should be accepted.

Inherited Constants

From androidx.media3.common.FrameProcessor
static final long

Indicates the frame should be dropped after releaseOutputFrame is invoked.

static final long

Indicates the frame should be released immediately after releaseOutputFrame is invoked.

Public fields

inputSurface

public final Surface inputSurface

Public methods

getInputSurface

public Surface getInputSurface()

Returns the input Surface, where FrameProcessor consumes input frames from.

getPendingInputFrameCount

public int getPendingInputFrameCount()

Returns the number of input frames that have been registered but not processed off the input surface yet.

registerInputFrame

public void registerInputFrame()

Informs the FrameProcessor that a frame will be queued to its input surface.

Must be called before rendering a frame to the frame processor's input surface.

Throws
java.lang.IllegalStateException java.lang.IllegalStateException

If called after signalEndOfInput or before setInputFrameInfo.

release

public void release()

Releases all resources.

If the frame processor is released before it has ended, it will attempt to cancel processing any input frames that have already become available. Input frames that become available after release are ignored.

This method blocks until all resources are released or releasing times out.

releaseOutputFrame

public void releaseOutputFrame(long releaseTimeNs)

Releases the oldest unreleased output frame that has become available at the given releaseTimeNs.

This will either render the output frame to the output surface, or drop the frame, per releaseTimeNs.

This method must only be called if releaseFramesAutomatically was set to false using the Factory and should be called exactly once for each frame that becomes available.

The releaseTimeNs may be passed to eglPresentationTimeANDROID depending on the implementation.

Parameters
long releaseTimeNs

The release time to use for the frame, in nanoseconds. The release time can be before of after the current system time. Use DROP_OUTPUT_FRAME to drop the frame, or RELEASE_OUTPUT_FRAME_IMMEDIATELY to release the frame immediately.

setInputFrameInfo

public void setInputFrameInfo(FrameInfo inputFrameInfo)

Sets information about the input frames.

The new input information is applied from the next frame registered onwards.

Pixels are expanded using the pixelWidthHeightRatio so that the output frames' pixels have a ratio of 1.

The caller should update streamOffsetUs when switching input streams to ensure that frame timestamps are always monotonically increasing.

setOutputSurfaceInfo

public void setOutputSurfaceInfo(@Nullable SurfaceInfo outputSurfaceInfo)

Sets the output surface and supporting information. When output frames are released and not dropped, they will be rendered to this output SurfaceInfo.

The new output SurfaceInfo is applied from the next output frame rendered onwards. If the output SurfaceInfo is null, the FrameProcessor will stop rendering pending frames and resume rendering once a non-null SurfaceInfo is set.

If the dimensions given in SurfaceInfo do not match the output size after applying the final effect the frames are resized before rendering to the surface and letter/pillar-boxing is applied.

The caller is responsible for tracking the lifecycle of the surface including calling this method with a new surface if it is destroyed. When this method returns, the previous output surface is no longer being used and can safely be released by the caller.

signalEndOfInput

public void signalEndOfInput()

Informs the FrameProcessor that no further input frames should be accepted.

Throws
java.lang.IllegalStateException java.lang.IllegalStateException

If called more than once.