# 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 />

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

## Public methods

### configure

```
abstract Size configure(int inputWidth, int inputHeight)
```

Configures the instance and returns the dimensions of the image required by `https://developer.android.com/reference/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/androidx/media3/effect/ByteBufferGlEffect.Processor#getScaledRegion(long)`.

| Parameters |
|---|---|
| `int inputWidth` | The input width in pixels. |
| `int inputHeight` | The input height in pixels. |

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

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

### finishProcessingAndBlend

```
abstract void finishProcessingAndBlend(
    GlTextureInfo outputFrame,
    long presentationTimeUs,
    T result
)
```

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

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

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

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

### getScaledRegion

```
abstract GlRect getScaledRegion(long presentationTimeUs)
```

Selects a region of the input texture that will be scaled to fill the image that is given to `https://developer.android.com/reference/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/androidx/media3/effect/ByteBufferGlEffect.Processor#configure(int,int)`.

| Parameters |
|---|---|
| `long presentationTimeUs` | The presentation time in microseconds. |

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

### processImage

```
abstract ListenableFuture<T> processImage(ByteBufferGlEffect.Image image, long presentationTimeUs)
```

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 |
|---|---|
| `https://developer.android.com/reference/androidx/media3/effect/ByteBufferGlEffect.Image image` | The image data. |
| `long presentationTimeUs` | 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

```
abstract void release()
```

Releases all resources.

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