TextureAssetLoader


@UnstableApi
public final class TextureAssetLoader implements AssetLoader


An AssetLoader implementation that loads videos from traditional GLES texture instances.

Typically instantiated in a custom AssetLoader.Factory saving a reference to the created TextureAssetLoader. Provide video frames as input by calling queueInputTexture, then signal the end of input when finished. Those methods must be called from the same thread, which can be any thread.

Summary

Public constructors

TextureAssetLoader(
    EditedMediaItem editedMediaItem,
    AssetLoader.Listener assetLoaderListener,
    Format format,
    OnInputFrameProcessedListener frameProcessedListener
)

Creates an instance.

Public methods

ImmutableMap<IntegerString>

Return the used decoders' names.

int

Returns the current Transformer.ProgressState and updates progressHolder with the current progress if it is available.

boolean
queueInputTexture(int texId, long presentationTimeUs)

Attempts to provide an input texture.

void

Stops loading data and releases all resources associated with the asset loader.

void

Signals that no further input frames will be rendered.

void

Starts the asset loader.

Inherited Constants

From androidx.media3.transformer.AssetLoader
static final int

Indicates that the asset loader can output decoded samples.

static final int

Indicates that the asset loader can output encoded samples.

Public constructors

TextureAssetLoader

public TextureAssetLoader(
    EditedMediaItem editedMediaItem,
    AssetLoader.Listener assetLoaderListener,
    Format format,
    OnInputFrameProcessedListener frameProcessedListener
)

Creates an instance.

The durationUs, width and height must be set.

Parameters
EditedMediaItem editedMediaItem

Information about the media item for which frames are provided.

AssetLoader.Listener assetLoaderListener

Listener for asset loading events.

Format format

Information about the format of video frames.

OnInputFrameProcessedListener frameProcessedListener

Listener for the event when a frame has been processed. The listener receives a GL sync object (if supported) to allow reusing the texture after it's no longer in use.

Public methods

getDecoderNames

public ImmutableMap<IntegerStringgetDecoderNames()

Return the used decoders' names.

Returns
ImmutableMap<IntegerString>

The decoders' names keyed by track type.

getProgress

@Transformer.ProgressState
public int getProgress(ProgressHolder progressHolder)

Returns the current Transformer.ProgressState and updates progressHolder with the current progress if it is available.

Parameters
ProgressHolder progressHolder

A ProgressHolder, updated to hold the percentage progress if available.

Returns
int

The Transformer.ProgressState.

queueInputTexture

public boolean queueInputTexture(int texId, long presentationTimeUs)

Attempts to provide an input texture.

Must be called on the same thread as signalEndOfVideoInput.

Parameters
int texId

The ID of the texture to queue.

long presentationTimeUs

The presentation time for the texture, in microseconds.

Returns
boolean

Whether the texture was successfully queued. If false, the caller should try again later.

release

public void release()

Stops loading data and releases all resources associated with the asset loader.

signalEndOfVideoInput

public void signalEndOfVideoInput()

Signals that no further input frames will be rendered.

Must be called on the same thread as queueInputTexture.

start

public void start()

Starts the asset loader.