# RawAssetLoader

Artifact: [androidx.media3:media3-transformer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/transformer/RawAssetLoader.java+class:androidx.media3.transformer.RawAssetLoader)

*** ** * ** ***

<br />

```
@UnstableApi
public final class RawAssetLoader implements AssetLoader
```

<br />

*** ** * ** ***

An `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader` implementation that loads raw audio and/or video data.

Typically instantiated in a custom `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Factory` saving a reference to the created `https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader`.

Provide raw audio data as input by calling `https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader#queueAudioData(java.nio.ByteBuffer,long,boolean)`. This method must always be called from the same thread, which can be any thread.

Provide video frames as input by calling `https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader#queueInputTexture(int,long)`, then `https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader#signalEndOfVideoInput()` 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 |
|---|
| `https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader#RawAssetLoader(androidx.media3.transformer.EditedMediaItem,androidx.media3.transformer.AssetLoader.Listener,androidx.media3.common.Format,androidx.media3.common.Format,androidx.media3.common.OnInputFrameProcessedListener)( https://developer.android.com/reference/androidx/media3/transformer/EditedMediaItem editedMediaItem, https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Listener assetLoaderListener, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format audioFormat, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format videoFormat, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/OnInputFrameProcessedListener frameProcessedListener )` Creates an instance. |

| ### Public methods |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableMap.html<https://developer.android.com/reference/java/lang/Integer.html, https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader#getDecoderNames()()` Return the used decoders' names. |
| `int` | `@https://developer.android.com/reference/androidx/media3/transformer/Transformer.ProgressState https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader#getProgress(androidx.media3.transformer.ProgressHolder)(https://developer.android.com/reference/androidx/media3/transformer/ProgressHolder progressHolder)` Returns the current `https://developer.android.com/reference/androidx/media3/transformer/Transformer.ProgressState` and updates `progressHolder` with the current progress if it is `https://developer.android.com/reference/androidx/media3/transformer/Transformer#PROGRESS_STATE_AVAILABLE()`. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader#queueAudioData(java.nio.ByteBuffer,long,boolean)( https://developer.android.com/reference/java/nio/ByteBuffer.html audioData, long presentationTimeUs, boolean isLast )` Attempts to provide raw audio data. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader#queueInputTexture(int,long)(int texId, long presentationTimeUs)` Attempts to provide an input texture. |
| `void` | `https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader#release()()` Stops loading data and releases all resources associated with the asset loader. |
| `void` | `https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader#signalEndOfVideoInput()()` Signals that no further input frames will be rendered. |
| `void` | `https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader#start()()` Starts the asset loader. |

### Inherited Constants

From [androidx.media3.transformer.AssetLoader](https://developer.android.com/reference/androidx/media3/transformer/AssetLoader) `static final int` `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader#SUPPORTED_OUTPUT_TYPE_DECODED() = 2`

Indicates that the asset loader can output decoded samples.
`static final int` `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader#SUPPORTED_OUTPUT_TYPE_ENCODED() = 1`

Indicates that the asset loader can output encoded samples.

## Public constructors

### RawAssetLoader

```
public RawAssetLoader(
    EditedMediaItem editedMediaItem,
    AssetLoader.Listener assetLoaderListener,
    @Nullable Format audioFormat,
    @Nullable Format videoFormat,
    @Nullable OnInputFrameProcessedListener frameProcessedListener
)
```

Creates an instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/EditedMediaItem editedMediaItem` | The `https://developer.android.com/reference/androidx/media3/transformer/EditedMediaItem` for which raw data is provided. The `https://developer.android.com/reference/androidx/media3/transformer/EditedMediaItem#durationUs()` must be set. |
| `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Listener assetLoaderListener` | Listener for asset loading events. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format audioFormat` | The audio format, or `null` if only video data is provided. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format videoFormat` | The video format, or `null` if only audio data is provided. The `https://developer.android.com/reference/androidx/media3/common/Format#width()` and the `https://developer.android.com/reference/androidx/media3/common/Format#height()` must be set. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/OnInputFrameProcessedListener frameProcessedListener` | 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 methods

### getDecoderNames

```
public ImmutableMap<Integer, String> getDecoderNames()
```

Return the used decoders' names.

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableMap.html<https://developer.android.com/reference/java/lang/Integer.html, https://developer.android.com/reference/java/lang/String.html>` | The decoders' names keyed by `https://developer.android.com/reference/androidx/media3/common/C.TrackType`. |

### getProgress

```
@Transformer.ProgressState
public int getProgress(ProgressHolder progressHolder)
```

Returns the current `https://developer.android.com/reference/androidx/media3/transformer/Transformer.ProgressState` and updates `progressHolder` with the current progress if it is `https://developer.android.com/reference/androidx/media3/transformer/Transformer#PROGRESS_STATE_AVAILABLE()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/ProgressHolder progressHolder` | A `https://developer.android.com/reference/androidx/media3/transformer/ProgressHolder`, updated to hold the percentage progress if `https://developer.android.com/reference/androidx/media3/transformer/Transformer#PROGRESS_STATE_AVAILABLE()`. |

| Returns |
|---|---|
| `int` | The `https://developer.android.com/reference/androidx/media3/transformer/Transformer.ProgressState`. |

### queueAudioData

```
public boolean queueAudioData(
    ByteBuffer audioData,
    long presentationTimeUs,
    boolean isLast
)
```

Attempts to provide raw audio data.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/nio/ByteBuffer.html audioData` | The raw audio data. The `https://developer.android.com/reference/java/nio/ByteBuffer.html` can be reused after calling this method. |
| `long presentationTimeUs` | The presentation time for the raw audio data, in microseconds. |
| `boolean isLast` | Signals the last audio data. |

| Returns |
|---|---|
| `boolean` | Whether the raw audio data was successfully queued. If `false`, the caller should try again later. |

### queueInputTexture

```
public boolean queueInputTexture(int texId, long presentationTimeUs)
```

Attempts to provide an input texture.

Must be called on the same thread as `https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader#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 `https://developer.android.com/reference/androidx/media3/transformer/RawAssetLoader#queueInputTexture(int,long)`.

### start

```
public void start()
```

Starts the asset loader.