@UnstableApi
interface SampleConsumer


Consumer of encoded media samples, raw audio or raw video frames.

Summary

Nested types

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
annotation SampleConsumer.InputResult

Specifies the result of an input operation.

Constants

const Int

The operation of queueing input successful and end of input has been automatically signalled.

const Int

The operation of queueing input was successful.

const Int

The operation of queueing/registering input was unsuccessful.

Public functions

ColorInfo!

Returns the expected input ColorInfo.

DecoderInputBuffer?

Returns a DecoderInputBuffer, if available.

Surface!

Returns the input Surface, where the consumer reads input frames from.

Int

Returns the number of input video frames pending in the consumer.

Int
@SampleConsumer.InputResult
queueInputBitmap(
    inputBitmap: Bitmap!,
    timestampIterator: TimestampIterator!
)

Attempts to provide an input Bitmap to the consumer.

Boolean

Attempts to queue new input to the consumer.

Int
@SampleConsumer.InputResult
queueInputTexture(texId: Int, presentationTimeUs: Long)

Attempts to provide an input texture to the consumer.

Boolean
registerVideoFrame(presentationTimeUs: Long)

Attempts to register a video frame to the consumer.

Unit

Provides a OnInputFrameProcessedListener to the consumer.

Unit

Informs the consumer that no further input frames will be rendered.

Constants

INPUT_RESULT_END_OF_STREAM

const val INPUT_RESULT_END_OF_STREAM = 3: Int

The operation of queueing input successful and end of input has been automatically signalled.

The caller should not signal end of input as this has already been done internally.

INPUT_RESULT_SUCCESS

const val INPUT_RESULT_SUCCESS = 1: Int

The operation of queueing input was successful.

The caller can queue more input or signal signal end of input.

INPUT_RESULT_TRY_AGAIN_LATER

const val INPUT_RESULT_TRY_AGAIN_LATER = 2: Int

The operation of queueing/registering input was unsuccessful.

The caller should queue try again later.

Public functions

getExpectedInputColorInfo

fun getExpectedInputColorInfo(): ColorInfo!

Returns the expected input ColorInfo.

Should only be used for raw video data.

getInputBuffer

fun getInputBuffer(): DecoderInputBuffer?

Returns a DecoderInputBuffer, if available.

This buffer should be filled with new input data and queued to the consumer.

If this method returns a non-null buffer:

  • The buffer's data is non-null.
  • The same buffer instance is returned if this method is called multiple times before queuing input.

Should only be used for compressed data and raw audio data.

getInputSurface

fun getInputSurface(): Surface!

Returns the input Surface, where the consumer reads input frames from.

Should only be used for raw video data.

getPendingVideoFrameCount

fun getPendingVideoFrameCount(): Int

Returns the number of input video frames pending in the consumer. Pending input frames are frames that have been registered but not processed off the input surface yet.

Should only be used for raw video data.

queueInputBitmap

@SampleConsumer.InputResult
fun queueInputBitmap(
    inputBitmap: Bitmap!,
    timestampIterator: TimestampIterator!
): Int

Attempts to provide an input Bitmap to the consumer.

Should only be used for image data.

Parameters
inputBitmap: Bitmap!

The Bitmap to queue to the consumer.

timestampIterator: TimestampIterator!

A TimestampIterator generating the exact timestamps that the bitmap should be shown at.

Returns
Int

The InputResult describing the result of the operation.

queueInputBuffer

fun queueInputBuffer(): Boolean

Attempts to queue new input to the consumer.

The input buffer from getInputBuffer should be filled with the new input before calling this method.

An input buffer should not be used anymore after it has been successfully queued.

Should only be used for compressed data and raw audio data.

Returns
Boolean

Whether the input was successfully queued. If false, the caller should try again later.

queueInputTexture

@SampleConsumer.InputResult
fun queueInputTexture(texId: Int, presentationTimeUs: Long): Int

Attempts to provide an input texture to the consumer.

Should only be used for raw video data.

Parameters
texId: Int

The ID of the texture to queue to the consumer.

presentationTimeUs: Long

The presentation time for the texture, in microseconds.

Returns
Int

The InputResult describing the result of the operation.

registerVideoFrame

fun registerVideoFrame(presentationTimeUs: Long): Boolean

Attempts to register a video frame to the consumer.

Each frame to consume should be registered using this method. After a frame is successfully registered, it should be rendered to the input surface.

Should only be used for raw video data.

Parameters
presentationTimeUs: Long

The presentation time of the frame to register, in microseconds.

Returns
Boolean

Whether the frame was successfully registered. If false, the caller should try again later.

setOnInputFrameProcessedListener

fun setOnInputFrameProcessedListener(
    listener: OnInputFrameProcessedListener!
): Unit

Provides a OnInputFrameProcessedListener to the consumer.

Should only be used for raw video data when input is provided by texture ID.

signalEndOfVideoInput

fun signalEndOfVideoInput(): Unit

Informs the consumer that no further input frames will be rendered.

Should only be used for raw video data.