HardwareBufferFrame


@ExperimentalApi
public class HardwareBufferFrame


A Frame implementation 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

public final class HardwareBufferFrame.Builder

A builder for HardwareBufferFrame instances.

Constants

static final HardwareBufferFrame

Public fields

final @Nullable SyncFence

An acquire SyncFence for the HardwareBuffer.

final Format

The format of the frame.

final @Nullable HardwareBuffer

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

final @Nullable Object

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

final Frame.Metadata
final long

The presentation time of the frame, in microseconds.

final long

The release time of the frame, in nanoseconds.

Public methods

HardwareBufferFrame.Builder

Returns a Builder initialized with the values of this instance.

Frame.Metadata

Returns the Metadata associated with this frame.

void

Releases the frame and its underlying resources.

Constants

END_OF_STREAM_FRAME

public static final HardwareBufferFrame END_OF_STREAM_FRAME

Public fields

acquireFence

public final @Nullable SyncFence acquireFence

An acquire SyncFence 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

public final Format format

The format of the frame.

hardwareBuffer

public final @Nullable HardwareBuffer hardwareBuffer

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

internalFrame

public final @Nullable Object internalFrame

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

metadata

public final Frame.Metadata metadata

presentationTimeUs

public final long presentationTimeUs

The presentation time of the frame, in microseconds.

releaseTimeNs

public final long releaseTimeNs

The release time of the frame, in nanoseconds.

Public methods

buildUpon

public HardwareBufferFrame.Builder buildUpon()

Returns a Builder initialized with the values of this instance.

getMetadata

public Frame.Metadata getMetadata()

Returns the Metadata associated with this frame.

release

public void release()

Releases the frame and its underlying resources.