TextureAssetLoader


@UnstableApi
class TextureAssetLoader : 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!,
    assetLoaderListener: AssetLoader.Listener!,
    format: Format!,
    frameProcessedListener: OnInputFrameProcessedListener!
)

Creates an instance.

Public functions

ImmutableMap<Int!, String!>!

Return the used decoders' names.

Int

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

Boolean
queueInputTexture(texId: Int, presentationTimeUs: Long)

Attempts to provide an input texture.

Unit

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

Unit

Signals that no further input frames will be rendered.

Unit

Starts the asset loader.

Inherited Constants

From androidx.media3.transformer.AssetLoader
const Int

Indicates that the asset loader can output decoded samples.

const Int

Indicates that the asset loader can output encoded samples.

Public constructors

TextureAssetLoader

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

Creates an instance.

The durationUs, width and height must be set.

Parameters
editedMediaItem: EditedMediaItem!

Information about the media item for which frames are provided.

assetLoaderListener: AssetLoader.Listener!

Listener for asset loading events.

format: Format!

Information about the format of video frames.

frameProcessedListener: OnInputFrameProcessedListener!

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 functions

getDecoderNames

fun getDecoderNames(): ImmutableMap<Int!, String!>!

Return the used decoders' names.

Returns
ImmutableMap<Int!, String!>!

The decoders' names keyed by track type.

getProgress

@Transformer.ProgressState
fun getProgress(progressHolder: ProgressHolder!): Int

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.

queueInputTexture

fun queueInputTexture(texId: Int, presentationTimeUs: Long): Boolean

Attempts to provide an input texture.

Must be called on the same thread as signalEndOfVideoInput.

Parameters
texId: Int

The ID of the texture to queue.

presentationTimeUs: Long

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

fun release(): Unit

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

signalEndOfVideoInput

fun signalEndOfVideoInput(): Unit

Signals that no further input frames will be rendered.

Must be called on the same thread as queueInputTexture.

start

fun start(): Unit

Starts the asset loader.