BitmapToHardwareBufferProcessor


@RequiresApi(value = 26)
@ExperimentalApi
class BitmapToHardwareBufferProcessor : AutoCloseable


A HardwareBufferFrameProcessor that converts Bitmap-backed HardwareBufferFrame instances into android.hardware.HardwareBuffer-backed ones.

This processor caches the underlying android.hardware.HardwareBuffer as long as the input Bitmap remains the same (verified via getGenerationId). It uses JNI to copy pixels from the bitmap to the hardware buffer.

The processor manages the lifecycle of the hardware buffer using reference counting, ensuring it is only closed once all consumer frames and the processor itself have released their references.

Summary

Public constructors

BitmapToHardwareBufferProcessor(
    hardwareBufferJniWrapper: HardwareBufferJniWrapper!,
    internalExecutor: ExecutorService!,
    errorExecutor: Executor!,
    errorCallback: Consumer<VideoFrameProcessingException!>!
)

Creates an instance.

Public functions

Unit
HardwareBufferFrame!

Converts the inputFrame to a new HardwareBufferFrame.

Public constructors

BitmapToHardwareBufferProcessor

BitmapToHardwareBufferProcessor(
    hardwareBufferJniWrapper: HardwareBufferJniWrapper!,
    internalExecutor: ExecutorService!,
    errorExecutor: Executor!,
    errorCallback: Consumer<VideoFrameProcessingException!>!
)

Creates an instance.

Parameters
hardwareBufferJniWrapper: HardwareBufferJniWrapper!

The HardwareBufferJniWrapper that supplies the native helpers needed by this class.

internalExecutor: ExecutorService!

The ExecutorService that waits for the release fence to signal before closing created HardwareBuffers. Will be shutdown when this class is closed.

errorExecutor: Executor!

The Executor on which the errorCallback will be called.

errorCallback: Consumer<VideoFrameProcessingException!>!

The Consumer called when waiting or closing the created HardwareBuffers fails.

Public functions

close

fun close(): Unit

process

fun process(inputFrame: HardwareBufferFrame!): HardwareBufferFrame!

Converts the inputFrame to a new HardwareBufferFrame.

The implementation may return the inputFrame itself if no conversion is needed, or a new frame backed by a android.hardware.HardwareBuffer.

Parameters
inputFrame: HardwareBufferFrame!

The input HardwareBufferFrame.

Returns
HardwareBufferFrame!

The processed HardwareBufferFrame.