# ByteBufferGlEffect.Processor

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

*** ** * ** ***

<br />

```
interface ByteBufferGlEffect.Processor<T>
```

<br />

*** ** * ** ***

A processor that takes in `https://developer.android.com/reference/java/nio/ByteBuffer.html` that represent input image data, and produces results of type `<T>`.

All methods are called on the GL thread.

| Parameters |
|---|---|
| `<T>` | The result type of running the processor. |

## Summary

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/Size!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Processor#configure(int,int)(inputWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, inputHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Configures the instance and returns the dimensions of the image required by `https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Processor#processImage(androidx.media3.effect.ByteBufferGlEffect.Image,long)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Processor#finishProcessingAndBlend(androidx.media3.common.GlTextureInfo,long,T)( outputFrame: https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo!, presentationTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, result: T! )` Finishes processing the frame at `presentationTimeUs`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/GlRect!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Processor#getScaledRegion(long)(presentationTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Selects a region of the input texture that will be scaled to fill the image that is given to `https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Processor#processImage(androidx.media3.effect.ByteBufferGlEffect.Image,long)`. |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<T!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Processor#processImage(androidx.media3.effect.ByteBufferGlEffect.Image,long)(image: https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Image!, presentationTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Processing the image data in the `image`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Processor#release()()` Releases all resources. |

## Public functions

### configure

```
fun configure(inputWidth: Int, inputHeight: Int): Size!
```

Configures the instance and returns the dimensions of the image required by `https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Processor#processImage(androidx.media3.effect.ByteBufferGlEffect.Image,long)`.

When the returned dimensions differ from `inputWidth` and `inputHeight`, the image will be scaled based on `https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Processor#getScaledRegion(long)`.

| Parameters |
|---|---|
| `inputWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The input width in pixels. |
| `inputHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The input height in pixels. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/Size!` | The size in pixels of the image data accepted by `https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Processor#processImage(androidx.media3.effect.ByteBufferGlEffect.Image,long)`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/VideoFrameProcessingException` | On error. |

### finishProcessingAndBlend

```
fun finishProcessingAndBlend(
    outputFrame: GlTextureInfo!,
    presentationTimeUs: Long,
    result: T!
): Unit
```

Finishes processing the frame at `presentationTimeUs`. Use this method to perform custom drawing on the output frame.

The `https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo` contains the image data corresponding to the frame at `presentationTimeUs` when this method is invoked.

| Parameters |
|---|---|
| `outputFrame: https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo!` | The texture info of the frame. |
| `presentationTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The presentation timestamp of the frame, in microseconds. |
| `result: T!` | The result of the asynchronous computation in `https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Processor#processImage(androidx.media3.effect.ByteBufferGlEffect.Image,long)`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/VideoFrameProcessingException` |   |

### getScaledRegion

```
fun getScaledRegion(presentationTimeUs: Long): GlRect!
```

Selects a region of the input texture that will be scaled to fill the image that is given to `https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Processor#processImage(androidx.media3.effect.ByteBufferGlEffect.Image,long)`.

Called once per input frame.

The contents are scaled to fit the image dimensions returned by `https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Processor#configure(int,int)`.

| Parameters |
|---|---|
| `presentationTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The presentation time in microseconds. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/GlRect!` | The rectangular region of the input image that will be scaled to fill the effect input image. |

### processImage

```
fun processImage(image: ByteBufferGlEffect.Image!, presentationTimeUs: Long): ListenableFuture<T!>!
```

Processing the image data in the `image`.

Accessing `image` after the returned future is `https://developer.android.com/reference/java/util/concurrent/Future.html#isDone()` or `https://developer.android.com/reference/java/util/concurrent/Future.html#isCancelled()` can lead to undefined behaviour.

| Parameters |
|---|---|
| `image: https://developer.android.com/reference/kotlin/androidx/media3/effect/ByteBufferGlEffect.Image!` | The image data. |
| `presentationTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The presentation time in microseconds. |

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<T!>!` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` of the result. |

### release

```
fun release(): Unit
```

Releases all resources.

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/VideoFrameProcessingException` | If an error occurs while releasing resources. |