# EGLSurfaceTexture

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

*** ** * ** ***


```
@UnstableApi
public final class EGLSurfaceTexture implements SurfaceTexture.OnFrameAvailableListener, Runnable
```

<br />

*** ** * ** ***

Generates a `https://developer.android.com/reference/android/graphics/SurfaceTexture.html` using EGL/GLES functions.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/androidx/annotation/IntDef(value = ) public annotation https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture.SecureMode` Secure mode to be used by the EGL surface and context. |
| `public interface https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture.TextureImageListener` Listener to be called when the texture image on `https://developer.android.com/reference/android/graphics/SurfaceTexture.html` has been updated. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture#SECURE_MODE_NONE() = 0` No secure EGL surface and context required. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture#SECURE_MODE_PROTECTED_PBUFFER() = 2` Creating a secure surface backed by a pixel buffer. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture#SECURE_MODE_SURFACELESS_CONTEXT() = 1` Creating a surfaceless, secured EGL context. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture#EGLSurfaceTexture(android.os.Handler)(https://developer.android.com/reference/android/os/Handler.html handler)` |
| `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture#EGLSurfaceTexture(android.os.Handler,androidx.media3.common.util.EGLSurfaceTexture.TextureImageListener)( https://developer.android.com/reference/android/os/Handler.html handler, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture.TextureImageListener callback )` |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/android/graphics/SurfaceTexture.html` | `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture#getSurfaceTexture()()` Returns the wrapped `https://developer.android.com/reference/android/graphics/SurfaceTexture.html`. |
| `void` | `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture#init(int)(@https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture.SecureMode int secureMode)` Initializes required EGL parameters and creates the `https://developer.android.com/reference/android/graphics/SurfaceTexture.html`. |
| `void` | `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture#onFrameAvailable(android.graphics.SurfaceTexture)(https://developer.android.com/reference/android/graphics/SurfaceTexture.html surfaceTexture)` |
| `void` | `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture#release()()` Releases all allocated resources. |
| `void` | `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture#run()()` |

## Constants

### SECURE_MODE_NONE

```
public static final int SECURE_MODE_NONE = 0
```

No secure EGL surface and context required.

### SECURE_MODE_PROTECTED_PBUFFER

```
public static final int SECURE_MODE_PROTECTED_PBUFFER = 2
```

Creating a secure surface backed by a pixel buffer.

### SECURE_MODE_SURFACELESS_CONTEXT

```
public static final int SECURE_MODE_SURFACELESS_CONTEXT = 1
```

Creating a surfaceless, secured EGL context.

## Public constructors

### EGLSurfaceTexture

```
public EGLSurfaceTexture(Handler handler)
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/os/Handler.html handler` | The `https://developer.android.com/reference/android/os/Handler.html` that will be used to call `https://developer.android.com/reference/android/graphics/SurfaceTexture.html#updateTexImage()` to update images on the `https://developer.android.com/reference/android/graphics/SurfaceTexture.html`. Note that `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture#init(int)` has to be called on the same looper thread as the `https://developer.android.com/reference/android/os/Handler.html`'s looper. |

### EGLSurfaceTexture

```
public EGLSurfaceTexture(
    Handler handler,
    @Nullable EGLSurfaceTexture.TextureImageListener callback
)
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/os/Handler.html handler` | The `https://developer.android.com/reference/android/os/Handler.html` that will be used to call `https://developer.android.com/reference/android/graphics/SurfaceTexture.html#updateTexImage()` to update images on the `https://developer.android.com/reference/android/graphics/SurfaceTexture.html`. Note that `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture#init(int)` has to be called on the same looper thread as the looper of the `https://developer.android.com/reference/android/os/Handler.html`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture.TextureImageListener callback` | The `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture.TextureImageListener` to be called when the texture image on `https://developer.android.com/reference/android/graphics/SurfaceTexture.html` has been updated. This callback will be called on the same handler thread as the `handler`. |

## Public methods

### getSurfaceTexture

```
public SurfaceTexture getSurfaceTexture()
```

Returns the wrapped `https://developer.android.com/reference/android/graphics/SurfaceTexture.html`. This can only be called after `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture#init(int)`.

### init

```
public void init(@EGLSurfaceTexture.SecureMode int secureMode)
```

Initializes required EGL parameters and creates the `https://developer.android.com/reference/android/graphics/SurfaceTexture.html`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture.SecureMode int secureMode` | The `https://developer.android.com/reference/androidx/media3/common/util/EGLSurfaceTexture.SecureMode` to be used for EGL surface. |

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

### onFrameAvailable

```
public void onFrameAvailable(SurfaceTexture surfaceTexture)
```

### release

```
public void release()
```

Releases all allocated resources.

### run

```
public void run()
```