HardwareBufferFrame


@ExperimentalApi
class HardwareBufferFrame


A frame backed by a HardwareBuffer.

Frames of this type may be mappable to memory accessible by various hardware systems, such as GPU, media codecs, NPU, or other auxiliary processing units.

On API levels before 26, where HardwareBuffer is not defined, internalFrame will be set for use within this package. internalFrame is not intended for use by third party apps.

Summary

Nested types

A builder for HardwareBufferFrame instances.

A marker interface for storing arbitrary metadata associated with a HardwareBufferFrame.

A callback to be invoked when the HardwareBufferFrame is released.

Public functions

HardwareBufferFrame.Builder!

Returns a Builder initialized with the values of this instance.

Unit
release(releaseFence: SyncFenceWrapper?)

Releases the frame and its underlying resources.

synchronized HardwareBufferFrame!

Creates a new reference to this frame.

Public properties

SyncFenceWrapper?

An acquire SyncFenceWrapper for the HardwareBuffer.

Format!

The format of the frame.

HardwareBuffer?

Returns the HardwareBuffer which holds the frame data, or null if hardware buffers are not supported on the current API level.

Any?

An optional internal frame type that is used when hardwareBuffer is not supported.

HardwareBufferFrame.Metadata!
Long

The presentation time of the frame relative to the start of the media item it belongs to, in microseconds.

Long

The release time of the frame, in nanoseconds.

Long

The presentation time of the frame relative to the start of the entire sequence, in microseconds.

Constants

END_OF_STREAM_FRAME

const val END_OF_STREAM_FRAMEHardwareBufferFrame!

Public functions

buildUpon

fun buildUpon(): HardwareBufferFrame.Builder!

Returns a Builder initialized with the values of this instance. This method does not increase the reference count.

The returned builder creates handles that share the same underlying reference count as this instance. To create a new reference that increments the reference count, call retain instead.

release

fun release(releaseFence: SyncFenceWrapper?): Unit

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
releaseFence: SyncFenceWrapper?

A SyncFenceWrapper that must signal before the underlying resources can be fully released, or null if the resources can be released immediately.

retain

synchronized fun retain(): HardwareBufferFrame!

Creates a new reference to this frame.

For every call to this method there must be an extra release call. The underlying buffer will only be released when the reference count drops to zero.

Throws
java.lang.IllegalStateException

if called after the frame has been released.

Public properties

acquireFence

val acquireFenceSyncFenceWrapper?

An acquire SyncFenceWrapper for the HardwareBuffer.

Callers should ensure that the acquire fence has signaled before accessing HardwareBuffer.

If the acquire fence is null, it's safe to access HardwareBuffer.

format

val formatFormat!

The format of the frame.

hardwareBuffer

val hardwareBufferHardwareBuffer?

Returns the HardwareBuffer which holds the frame data, or null if hardware buffers are not supported on the current API level.

internalFrame

val internalFrameAny?

An optional internal frame type that is used when hardwareBuffer is not supported.

presentationTimeUs

val presentationTimeUsLong

The presentation time of the frame relative to the start of the media item it belongs to, in microseconds.

releaseTimeNs

val releaseTimeNsLong

The release time of the frame, in nanoseconds.

sequencePresentationTimeUs

val sequencePresentationTimeUsLong

The presentation time of the frame relative to the start of the entire sequence, in microseconds. This time is monotonically increasing across all media items in the sequence.