# FrameProcessorUtils

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/FrameProcessorUtils.java+class:androidx.media3.effect.FrameProcessorUtils)

*** ** * ** ***


```
@ExperimentalApi
class FrameProcessorUtils
```

<br />

*** ** * ** ***

Utility methods for FrameProcessor implementations.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils.EglImageTextureWrapper` Data class holding handles to `EglImage`, texture ID and frame buffer object ID. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#OPEN_GL_VERSION_2() = 2` OpenGL ES 2.0 context created. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#OPEN_GL_VERSION_3() = 3` 10-bit HDR-capable OpenGL ES 3.0 context created. |

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils.EglImageTextureWrapper!` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#createAndBindEglImage(android.opengl.EGLDisplay,android.hardware.HardwareBuffer,androidx.media3.effect.HardwareBufferJniWrapper,int,boolean)( eglDisplay: https://developer.android.com/reference/android/opengl/EGLDisplay.html!, buffer: https://developer.android.com/reference/android/hardware/HardwareBuffer.html!, jniWrapper: https://developer.android.com/reference/kotlin/androidx/media3/effect/HardwareBufferJniWrapper!, target: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, writesToBoundImage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Creates an EGL image from a `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` and binds it to a newly generated texture. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#releaseEglImageTexture(androidx.media3.effect.FrameProcessorUtils.EglImageTextureWrapper,androidx.media3.effect.HardwareBufferJniWrapper)( eglImageTextureWrapper: https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils.EglImageTextureWrapper!, jniWrapper: https://developer.android.com/reference/kotlin/androidx/media3/effect/HardwareBufferJniWrapper! )` Releases the EGL image, focused frame buffer object, and texture. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#releaseOpenGl(androidx.media3.common.GlObjectsProvider)(glObjectsProvider: https://developer.android.com/reference/kotlin/androidx/media3/common/GlObjectsProvider!)` Releases the OpenGL resources. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#runAllAndAccumulateExceptions(androidx.media3.common.util.ThrowingRunnable<?>...)(actions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/common/util/ThrowingRunnable<*>!>!)` Executes multiple throwing actions sequentially, ensuring all are run even if some fail. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#runAllAndAccumulateExceptions(java.util.function.Consumer<androidx.media3.common.VideoFrameProcessingException>,androidx.media3.common.util.ThrowingRunnable<?>...)( errorConsumer: https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/media3/common/VideoFrameProcessingException!>!, actions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/common/util/ThrowingRunnable<*>!>! )` Executes multiple throwing actions sequentially, ensuring all are run even if some fail. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#setupOpenGl(androidx.media3.common.GlObjectsProvider)(glObjectsProvider: https://developer.android.com/reference/kotlin/androidx/media3/common/GlObjectsProvider!)` Sets up the OpenGL context on the current thread. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#shutdownGlExecutorService(java.util.concurrent.ExecutorService)(glExecutorService: https://developer.android.com/reference/java/util/concurrent/ExecutorService.html!)` Shuts down the passed in `https://developer.android.com/reference/java/util/concurrent/ExecutorService.html` with a timeout. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#submitToGlExecutor(java.util.concurrent.Callable<java.lang.Void>,com.google.common.util.concurrent.ListeningExecutorService,java.util.function.Consumer<androidx.media3.common.VideoFrameProcessingException>)( operation: https://developer.android.com/reference/java/util/concurrent/Callable.html<https://developer.android.com/reference/java/lang/Void.html!>!, glExecutorService: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListeningExecutorService.html!, errorConsumer: https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/media3/common/VideoFrameProcessingException!>! )` Submits an `https://developer.android.com/reference/java/util/concurrent/Callable.html` to the passed in `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListeningExecutorService.html`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#useHighPrecisionColorComponents(androidx.media3.common.ColorInfo)(colorInfo: https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo?)` Returns whether the color space requires high precision (16-bit floating-point) color components. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#waitAndCloseFence(androidx.media3.common.video.AsyncFrame)(asyncFrame: https://developer.android.com/reference/kotlin/androidx/media3/common/video/AsyncFrame!)` Awaits the acquire fence on the `https://developer.android.com/reference/kotlin/androidx/media3/common/video/AsyncFrame`. |

## Constants

### OPEN_GL_VERSION_2

```
const val OPEN_GL_VERSION_2 = 2: Int
```

OpenGL ES 2.0 context created.

### OPEN_GL_VERSION_3

```
const val OPEN_GL_VERSION_3 = 3: Int
```

10-bit HDR-capable OpenGL ES 3.0 context created.

## Public functions

### createAndBindEglImage

```
@RequiresApi(value = 26)
java-static fun createAndBindEglImage(
    eglDisplay: EGLDisplay!,
    buffer: HardwareBuffer!,
    jniWrapper: HardwareBufferJniWrapper!,
    target: Int,
    writesToBoundImage: Boolean
): FrameProcessorUtils.EglImageTextureWrapper!
```

Creates an EGL image from a `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` and binds it to a newly generated texture.

This method should only be called on the thread that owns the OpenGL context.

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

### releaseEglImageTexture

```
@RequiresApi(value = 26)
java-static fun releaseEglImageTexture(
    eglImageTextureWrapper: FrameProcessorUtils.EglImageTextureWrapper!,
    jniWrapper: HardwareBufferJniWrapper!
): Unit
```

Releases the EGL image, focused frame buffer object, and texture.

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

### releaseOpenGl

```
java-static fun releaseOpenGl(glObjectsProvider: GlObjectsProvider!): Unit
```

Releases the OpenGL resources.

This method must run on the thread that owns the OpenGL context.

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

### runAllAndAccumulateExceptions

```
java-static fun runAllAndAccumulateExceptions(actions: Array<ThrowingRunnable<*>!>!): Unit
```

Executes multiple throwing actions sequentially, ensuring all are run even if some fail.

If multiple exceptions are thrown, they are accumulated using `https://developer.android.com/reference/java/lang/Throwable.html#addSuppressed(java.lang.Throwable)`.

| Parameters |
|---|---|
| `actions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/common/util/ThrowingRunnable<*>!>!` | The throwing actions to execute. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/VideoFrameProcessingException` | If any of the actions fail. |

### runAllAndAccumulateExceptions

```
java-static fun runAllAndAccumulateExceptions(
    errorConsumer: Consumer<VideoFrameProcessingException!>!,
    actions: Array<ThrowingRunnable<*>!>!
): Unit
```

Executes multiple throwing actions sequentially, ensuring all are run even if some fail.

If multiple exceptions are thrown, they are accumulated using `https://developer.android.com/reference/java/lang/Throwable.html#addSuppressed(java.lang.Throwable)`.

| Parameters |
|---|---|
| `errorConsumer: https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/media3/common/VideoFrameProcessingException!>!` | The `https://developer.android.com/reference/java/util/function/Consumer.html` to which the accumulated `https://developer.android.com/reference/kotlin/androidx/media3/common/VideoFrameProcessingException` is routed. |
| `actions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/common/util/ThrowingRunnable<*>!>!` | The throwing actions to execute. |

### setupOpenGl

```
java-static fun setupOpenGl(glObjectsProvider: GlObjectsProvider!): Int
```

Sets up the OpenGL context on the current thread.

Attempts to create an OpenGL ES 3.0 context with 10-bit HDR configuration (`https://developer.android.com/reference/kotlin/androidx/media3/common/util/GlUtil#EGL_CONFIG_ATTRIBUTES_RGBA_1010102()`) if surfaceless contexts are supported. This allows the pipeline to handle SDR and HDR contents without recreating the context.

Falls back to OpenGL ES 2.0 with `https://developer.android.com/reference/kotlin/androidx/media3/common/util/GlUtil#EGL_CONFIG_ATTRIBUTES_RGBA_8888()` if surfaceless contexts are unsupported (e.g., on emulators) or if ES 3.0 context creation fails.

| Parameters |
|---|---|
| `glObjectsProvider: https://developer.android.com/reference/kotlin/androidx/media3/common/GlObjectsProvider!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/GlObjectsProvider`. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The created OpenGL version (`https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#OPEN_GL_VERSION_3()` or `https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameProcessorUtils#OPEN_GL_VERSION_2()`). |

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

### shutdownGlExecutorService

```
java-static fun shutdownGlExecutorService(glExecutorService: ExecutorService!): Unit
```

Shuts down the passed in `https://developer.android.com/reference/java/util/concurrent/ExecutorService.html` with a timeout.

### submitToGlExecutor

```
java-static fun submitToGlExecutor(
    operation: Callable<Void!>!,
    glExecutorService: ListeningExecutorService!,
    errorConsumer: Consumer<VideoFrameProcessingException!>!
): Unit
```

Submits an `https://developer.android.com/reference/java/util/concurrent/Callable.html` to the passed in `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListeningExecutorService.html`.

The passed in `https://developer.android.com/reference/java/util/function/Consumer.html` will be invoked if the `operation` fails.

### useHighPrecisionColorComponents

```
java-static fun useHighPrecisionColorComponents(colorInfo: ColorInfo?): Boolean
```

Returns whether the color space requires high precision (16-bit floating-point) color components.

### waitAndCloseFence

```
java-static fun waitAndCloseFence(asyncFrame: AsyncFrame!): Boolean
```

Awaits the acquire fence on the `https://developer.android.com/reference/kotlin/androidx/media3/common/video/AsyncFrame`. Returns `true` if the fence was signaled before the timeout, `false` otherwise.