# GlTextureFrame

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

*** ** * ** ***


```
@ExperimentalApi
public class GlTextureFrame
```

<br />

*** ** * ** ***

A frame that wraps a `https://developer.android.com/reference/androidx/media3/common/GlTextureInfo`.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame.Builder` A builder for `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame` instances. |

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame` | `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#END_OF_STREAM_FRAME()` |

| ### Public fields |
|---|---|
| `final long` | `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#fenceSync()` The OpenGL fence sync object (a `https://developer.android.com/reference/androidx/media3/common/util/GlUtil#createGlSyncFence()` handle) associated with this frame. |
| `final https://developer.android.com/reference/androidx/media3/common/Format` | `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#format()` The format of the frame. |
| `final https://developer.android.com/reference/androidx/media3/common/GlTextureInfo` | `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#glTextureInfo()` The `https://developer.android.com/reference/androidx/media3/common/GlTextureInfo`. |
| `final https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableMap.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/Object.html>` | `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#metadata()` |
| `final long` | `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#presentationTimeUs()` The presentation time of the frame, in microseconds. |
| `final https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/androidx/media3/common/GlTextureInfo>` | `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#releaseTextureCallback()` The `https://developer.android.com/reference/java/util/function/Consumer.html` to call to release the texture. |
| `final https://developer.android.com/reference/java/util/concurrent/Executor.html` | `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#releaseTextureExecutor()` The `https://developer.android.com/reference/java/util/concurrent/Executor.html` on which the `releaseTextureCallback` is called. |
| `final long` | `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#releaseTimeNs()` The release time of the frame, in nanoseconds. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame.Builder` | `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#buildUpon()()` Returns a `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame.Builder` initialized with the values of this instance. |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableMap.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/Object.html>` | `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#getMetadata()()` |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#release(androidx.media3.common.video.SyncFenceWrapper)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/video/SyncFenceWrapper releaseFence)` Releases the frame and its underlying resources. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#retain()()` Increases the reference count of this frame. |

## Constants

### END_OF_STREAM_FRAME

```
public static final GlTextureFrame END_OF_STREAM_FRAME
```

## Public fields

### fenceSync

```
public final long fenceSync
```

The OpenGL fence sync object (a `https://developer.android.com/reference/androidx/media3/common/util/GlUtil#createGlSyncFence()` handle) associated with this frame. See [](https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glFenceSync.xhtml)

If this texture is read in an OpenGL context different to the one it was written to, call `https://developer.android.com/reference/androidx/media3/common/util/GlUtil#awaitSyncObject(long)` on this fence before reading the `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#glTextureInfo()`, to ensure the contents have been fully written to.

Callers must \*not\* `https://developer.android.com/reference/androidx/media3/common/util/GlUtil#deleteSyncObject(long)` this fence, as it may be reused up until this frame is `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#release(androidx.media3.common.video.SyncFenceWrapper)`.

The value is `https://developer.android.com/reference/androidx/media3/common/util/GlUtil#GL_FENCE_SYNC_UNSET()` if no fence has been created for this texture, as it is only expected to be produced and consumed within the same GL command stream.

### format

```
public final Format format
```

The format of the frame.

### glTextureInfo

```
public final GlTextureInfo glTextureInfo
```

The `https://developer.android.com/reference/androidx/media3/common/GlTextureInfo`.

### metadata

```
public final ImmutableMap<String, Object> metadata
```

### presentationTimeUs

```
public final long presentationTimeUs
```

The presentation time of the frame, in microseconds.

### releaseTextureCallback

```
public final Consumer<GlTextureInfo> releaseTextureCallback
```

The `https://developer.android.com/reference/java/util/function/Consumer.html` to call to release the texture.

### releaseTextureExecutor

```
public final Executor releaseTextureExecutor
```

The `https://developer.android.com/reference/java/util/concurrent/Executor.html` on which the `releaseTextureCallback` is called.

### releaseTimeNs

```
public final long releaseTimeNs
```

The release time of the frame, in nanoseconds.

## Public methods

### buildUpon

```
public GlTextureFrame.Builder buildUpon()
```

Returns a `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame.Builder` initialized with the values of this instance.

### getMetadata

```
public ImmutableMap<String, Object> getMetadata()
```

### release

```
public void release(@Nullable SyncFenceWrapper releaseFence)
```

Releases the frame and its underlying resources.

This implementation is idempotent if called after the frame has already been released. It will strictly release the underlying resources only when the count transitions from 1 to 0.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/video/SyncFenceWrapper releaseFence` | A `https://developer.android.com/reference/androidx/media3/common/video/SyncFenceWrapper` that must signal before the underlying resources can be fully released, or `null` if the resources can be released immediately. |

### retain

```
public void retain()
```

Increases the reference count of this frame. For every call to this method there must be an extra `https://developer.android.com/reference/androidx/media3/effect/GlTextureFrame#release(androidx.media3.common.video.SyncFenceWrapper)` call before this frame is released.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if called after the frame has been released. |