EnhancementSessionDecorator


@ExperimentalApi
@RequiresApi(value = 33)
public final class EnhancementSessionDecorator implements FrameProcessor


A FrameProcessor decorator that routes video frames through Google Play services EnhancementSession.

Timestamp handling across the surface bridge:

  1. FrameToSurfaceFrameWriter receives an upstream Frame with presentationTimeUs, stamps the android.media.Image with a synthetic strictly increasing nanosecond timestamp from MonotonicTimestampGenerator (required because the underlying MediaPipe graph rejects non-increasing timestamps on seeks), and notifies onFrameQueued with the original presentationTimeUs.
  2. EnhancementSessionDecorator forwards presentationTimeUs from onFrameQueued to onInputFrameQueued.
  3. SurfaceToFrameWriterAdapter stores presentationTimeUs in a FIFO queue and restores it onto the output Frame when the processed image arrives on the output Surface. A 1:1 FIFO queue is guaranteed to match because FrameToSurfaceFrameWriter enforces at most one frame in flight ( MAX_IN_FLIGHT_FRAMES = 1), waiting for onFrameReleased before queuing the next frame.

Summary

Nested types

Builder for EnhancementSessionDecorator factories.

Factory for EnhancementSessionDecorator.

Public methods

void

Blocks until all resources are released.

boolean

Attempts to queue a List of frames for processing.

void

Notifies this processor that the current stream has ended.

Inherited methods

From java.lang.AutoCloseable
abstract void

Public methods

close

public void close()

Blocks until all resources are released.

May be called from any thread.

queue

public boolean queue(List<AsyncFrame> frames)

Attempts to queue a List of frames for processing.

All frames provided in a single invocation of this method represent the exact same point in time.

If this consumer is at capacity, this method returns false and the onWakeup will be invoked when capacity becomes available.

If this method returns true, onFrameProcessed must be called once with every input frame instance queued, once the FrameProcessor has finished processing the frames.

Parameters
List<AsyncFrame> frames

The frames to queue.

Returns
boolean

true if the frames were queued, false if the consumer is at capacity.

signalEndOfStream

public void signalEndOfStream()

Notifies this processor that the current stream has ended.

More frames may be queued after calling this method, if the current stream changes.