SurfaceHolderHardwareBufferFrameQueue


@RequiresApi(value = 33)
@ExperimentalApi
class SurfaceHolderHardwareBufferFrameQueue : HardwareBufferFrameQueue, SurfaceHolder.Callback


A HardwareBufferFrameQueue that outputs frames to a SurfaceHolder.

Summary

Public constructors

SurfaceHolderHardwareBufferFrameQueue(
    surfaceHolder: SurfaceHolder!,
    surfaceHolderExecutor: Executor!,
    listener: SurfaceHolderHardwareBufferFrameQueue.Listener!,
    listenerExecutor: Executor!
)

Creates a new instance.

Public functions

HardwareBufferFrame?
dequeue(
    format: HardwareBufferFrameQueue.FrameFormat!,
    wakeupListener: Runnable!
)

Attempts to dequeue a HardwareBufferFrame matching the specified format.

Unit

Queues a HardwareBufferFrame for consumption by the downstream component.

Unit

Releases the queue.

Unit

Signals that no more frames will be queued.

Unit
surfaceChanged(holder: SurfaceHolder!, format: Int, width: Int, height: Int)
Unit
Unit

Public constructors

SurfaceHolderHardwareBufferFrameQueue

SurfaceHolderHardwareBufferFrameQueue(
    surfaceHolder: SurfaceHolder!,
    surfaceHolderExecutor: Executor!,
    listener: SurfaceHolderHardwareBufferFrameQueue.Listener!,
    listenerExecutor: Executor!
)

Creates a new instance.

Parameters
surfaceHolder: SurfaceHolder!

The SurfaceHolder to which frames will be written.

surfaceHolderExecutor: Executor!

The Executor on which the surface holder methods will be called.

listener: SurfaceHolderHardwareBufferFrameQueue.Listener!

The Listener.

listenerExecutor: Executor!

The Executor on which the listener methods will be called.

Public functions

dequeue

fun dequeue(
    format: HardwareBufferFrameQueue.FrameFormat!,
    wakeupListener: Runnable!
): HardwareBufferFrame?

Attempts to dequeue a HardwareBufferFrame matching the specified format.

If the queue has reached its capacity and no buffers are available for reuse, this method returns null. In this case, the wakeupListener will be invoked when a buffer is eventually returned to the pool.

If this method is called multiple times without returning a frame, only the most recent wakeupListener is guaranteed to be invoked.

Parameters
format: HardwareBufferFrameQueue.FrameFormat!

The required format for the dequeued buffer.

wakeupListener: Runnable!

A callback to notify the caller when a buffer becomes available.

Returns
HardwareBufferFrame?

A HardwareBufferFrame, or null if the queue is currently full.

queue

fun queue(frame: HardwareBufferFrame!): Unit

Queues a HardwareBufferFrame for consumption by the downstream component.

Implementations may override release of the queued frame.

The implementation is responsible for ensuring the buffer is correctly reused or released once the downstream component has finished processing it.

Parameters
frame: HardwareBufferFrame!

The frame to be processed.

release

fun release(): Unit

Releases the queue.

This method should be called when the queue is no longer needed to unregister callbacks and release resources.

signalEndOfStream

fun signalEndOfStream(): Unit

Signals that no more frames will be queued.

This propagates an end-of-stream signal to the downstream consumer.

surfaceChanged

fun surfaceChanged(holder: SurfaceHolder!, format: Int, width: Int, height: Int): Unit

surfaceCreated

fun surfaceCreated(holder: SurfaceHolder!): Unit

surfaceDestroyed

fun surfaceDestroyed(holder: SurfaceHolder!): Unit