EncoderFrameWriter


@RequiresApi(value = 33)
@ExperimentalApi
class EncoderFrameWriter : FrameWriter


An implementation of FrameWriter that uses an ImageWriter to forward frames to a encoder via Surface. Sets the USAGE_VIDEO_ENCODE flag on the buffers.

Summary

Nested types

Listener for EncoderFrameWriter events.

Public constructors

EncoderFrameWriter(
    encoderFactory: Codec.EncoderFactory!,
    listener: EncoderFrameWriter.Listener!,
    listenerExecutor: Executor!,
    imageReleaseHandler: Handler!,
    logSessionId: LogSessionId?
)

Public functions

Unit

Blocks until all resources are released.

Unit
configure(format: Format!, @Frame.Usage usage: Long)

Format and usage support can be checked on the Info before configuring.

synchronized AsyncFrame?
dequeueInputFrame(wakeupExecutor: Executor!, wakeupListener: Runnable!)

Dequeues an AsyncFrame storing a Frame of the configured format and usage, and a SyncFenceWrapper that must be waited on before filling the frame.

FrameWriter.Info!

Returns the Info for this FrameWriter.

Unit
queueInputFrame(frame: Frame!, writeCompleteFence: SyncFenceWrapper?)

Queues a filled frame for further processing.

Unit

Notifies this FrameWriter that the current stream has ended.

Inherited functions

From java.lang.AutoCloseable
abstract Unit

Public constructors

EncoderFrameWriter

EncoderFrameWriter(
    encoderFactory: Codec.EncoderFactory!,
    listener: EncoderFrameWriter.Listener!,
    listenerExecutor: Executor!,
    imageReleaseHandler: Handler!,
    logSessionId: LogSessionId?
)

Public functions

close

fun close(): Unit

Blocks until all resources are released.

configure

fun configure(format: Format!, @Frame.Usage usage: Long): Unit

Format and usage support can be checked on the Info before configuring.

Must be called before dequeueInputFrame.

Parameters
format: Format!

The format to configure.

@Frame.Usage usage: Long

The @FrameUsage flags describing how the frame will be used.

Throws
java.lang.IllegalStateException

if any frames are dequeued at the point this method is called.

java.lang.IllegalArgumentException

if the format or usage is unsupported.

dequeueInputFrame

synchronized fun dequeueInputFrame(wakeupExecutor: Executor!, wakeupListener: Runnable!): AsyncFrame?

Dequeues an AsyncFrame storing a Frame of the configured format and usage, and a SyncFenceWrapper that must be waited on before filling the frame.

The returned frame must be filled and queued back for processing.

If the FrameWriter is at capacity, this method returns null and will notify the listener when capacity is available, and it can be called again.

Only the most recent wakeupListener will be notified when capacity is available.

Parameters
wakeupExecutor: Executor!

The Executor on which the wakeupListener is invoked.

wakeupListener: Runnable!

A Runnable to be invoked when capacity becomes available.

Returns
AsyncFrame?

The dequeued frame, or null if the writer is at capacity.

Throws
java.lang.IllegalStateException

if configure has not been called.

getInfo

fun getInfo(): FrameWriter.Info!

Returns the Info for this FrameWriter.

queueInputFrame

fun queueInputFrame(frame: Frame!, writeCompleteFence: SyncFenceWrapper?): Unit

Queues a filled frame for further processing.

The queued frame must have been previously dequeued from this writer.

Parameters
frame: Frame!

The filled frame to queue.

writeCompleteFence: SyncFenceWrapper?

A SyncFenceWrapper that will signal when the caller has finished writing to the frame, or null if the write was synchronous.

signalEndOfStream

fun signalEndOfStream(): Unit

Notifies this FrameWriter that the current stream has ended.

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