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
)

This method is deprecated. Deprecated in Java

Public methods

ImmutableMap<Integer, String>

This method is deprecated. Deprecated in Java

int

This method is deprecated. Deprecated in Java

boolean
queueInputTexture(int texId, long presentationTimeUs)

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

Inherited Constants

From androidx.media3.transformer.AssetLoader
static final int

This field is deprecated. Deprecated in Java

static final int

This field is deprecated. Deprecated in Java

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<Integer, String> getDecoderNames()

Return the used decoders' names.

Returns
ImmutableMap<Integer, String>

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.