@UnstableApi
class RawAssetLoader : AssetLoader


An AssetLoader implementation that loads raw audio and/or video data.

Typically instantiated in a custom AssetLoader.Factory saving a reference to the created RawAssetLoader.

Provide raw audio data as input by calling queueAudioData. This method must always be called from the same thread, which can be any thread.

Provide video frames as input by calling queueInputTexture, then signal the end of input when finished. These two methods must be called from the same thread, which can be any thread.

All other methods are for internal use only and must never be called.

Summary

Public constructors

RawAssetLoader(
    editedMediaItem: EditedMediaItem!,
    assetLoaderListener: AssetLoader.Listener!,
    audioFormat: Format?,
    videoFormat: 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
queueAudioData(
    audioData: ByteBuffer!,
    presentationTimeUs: Long,
    isLast: Boolean
)

Attempts to provide raw audio data.

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

RawAssetLoader

RawAssetLoader(
    editedMediaItem: EditedMediaItem!,
    assetLoaderListener: AssetLoader.Listener!,
    audioFormat: Format?,
    videoFormat: Format?,
    frameProcessedListener: OnInputFrameProcessedListener?
)

Creates an instance.

Parameters
editedMediaItem: EditedMediaItem!

The EditedMediaItem for which raw data is provided. The durationUs must be set.

assetLoaderListener: AssetLoader.Listener!

Listener for asset loading events.

audioFormat: Format?

The audio format, or null if only video data is provided.

videoFormat: Format?

The video format, or null if only audio data is provided. The width and the height must be set.

frameProcessedListener: OnInputFrameProcessedListener?

Listener for the event when a frame has been processed, or null if only audio data is provided. 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.

queueAudioData

fun queueAudioData(
    audioData: ByteBuffer!,
    presentationTimeUs: Long,
    isLast: Boolean
): Boolean

Attempts to provide raw audio data.

Parameters
audioData: ByteBuffer!

The raw audio data. The ByteBuffer can be reused after calling this method.

presentationTimeUs: Long

The presentation time for the raw audio data, in microseconds.

isLast: Boolean

Signals the last audio data.

Returns
Boolean

Whether the raw audio data was successfully queued. If false, the caller should try again later.

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.