InputBuffer

@RequiresApi(value = 21) interface InputBuffer


InputBuffer is provided by the Encoder and used to feed data into the Encoder.

Once InputBuffer is complete or no longer needed, submit or cancel must be called to return the request to the encoder, otherwise, it will cause leakage or failure.

Summary

Public methods

abstract @NonNull boolean

Returns the request to encoder without taking any effect.

abstract @NonNull ByteBuffer

Gets the ByteBuffer of the input buffer.

abstract @NonNull ListenableFuture<@NonNull Void>

The ListenableFuture that is complete when submit or cancel is called.

abstract @NonNull void
setEndOfStream(@NonNull boolean isEndOfStream)

Denotes the input buffer is the end of the data stream.

abstract @NonNull void
setPresentationTimeUs(@NonNull long presentationTimeUs)

Sets the timestamp of the input buffer in microseconds.

abstract @NonNull boolean

Submits the input buffer.

Public methods

cancel

@NonNull
abstract boolean cancel()

Returns the request to encoder without taking any effect.

Returns
boolean

true if cancel successfully; false if already submitted, failed or has been canceled.

getByteBuffer

@NonNull
abstract ByteBuffer getByteBuffer()

Gets the ByteBuffer of the input buffer.

Before submitting the InputBuffer, the internal position of the ByteBuffer must be set to prepare it for reading, e.g. the position is the beginning of the data, usually 0; the limit is the end of the data. Usually flip is used after writing data.

Getting ByteBuffer multiple times won't reset its internal position and data.

Throws
{@link IllegalStateException}

if InputBuffer is submitted or canceled.

getTerminationFuture

@NonNull
abstract ListenableFuture<@NonNull VoidgetTerminationFuture()

The ListenableFuture that is complete when submit or cancel is called.

setEndOfStream

@NonNull
abstract void setEndOfStream(@NonNull boolean isEndOfStream)

Denotes the input buffer is the end of the data stream.

Throws
{@link IllegalStateException}

if InputBuffer is submitted or canceled.

setPresentationTimeUs

@NonNull
abstract void setPresentationTimeUs(@NonNull long presentationTimeUs)

Sets the timestamp of the input buffer in microseconds.

Throws
{@link IllegalStateException}

if InputBuffer is submitted or canceled.

submit

@NonNull
abstract boolean submit()

Submits the input buffer.

The data will be written to encoder only when submit is called.

Returns
boolean

true if submit successfully; false if already submitted, failed or has been canceled.