SampleConsumer
@UnstableApi
public interface SampleConsumer
Consumer of encoded media samples, raw audio or raw video frames.
Summary
Nested types |
|---|
@DocumentedSpecifies the result of an input operation. |
Constants |
|
|---|---|
default static final int |
The operation of queueing input successful and end of input has been automatically signalled. |
default static final int |
The operation of queueing input was successful. |
default static final int |
The operation of queueing/registering input was unsuccessful. |
Public methods |
|
|---|---|
default @Nullable DecoderInputBuffer |
Returns a |
default Surface |
Returns the input |
default int |
Returns the number of input video frames pending in the consumer. |
default int |
@SampleConsumer.InputResultAttempts to provide an input |
default boolean |
Attempts to queue new input to the consumer. |
default int |
@SampleConsumer.InputResultAttempts to provide an input texture to the consumer. |
default boolean |
registerVideoFrame(long presentationTimeUs)Attempts to register a video frame to the consumer. |
default void |
Provides a |
default void |
setOnInputSurfaceReadyListener(Runnable runnable)Sets a listener that's called when the |
default void |
Informs the consumer that no further input frames will be rendered. |
Constants
INPUT_RESULT_END_OF_STREAM
default static final int INPUT_RESULT_END_OF_STREAM = 3
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
default static final int INPUT_RESULT_SUCCESS = 1
The operation of queueing input was successful.
The caller can queue more input or signal signal end of input.
INPUT_RESULT_TRY_AGAIN_LATER
default static final int INPUT_RESULT_TRY_AGAIN_LATER = 2
The operation of queueing/registering input was unsuccessful.
The caller should queue try again later.
Public methods
getInputBuffer
default @Nullable DecoderInputBuffer getInputBuffer()
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
datais non-null. - The same buffer instance is returned if this method is called multiple times before
queuinginput.
Should only be used for compressed data and raw audio data.
getInputSurface
default Surface getInputSurface()
Returns the input Surface, where the consumer reads input frames from.
Should only be used for raw video data.
getPendingVideoFrameCount
default int getPendingVideoFrameCount()
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
default int queueInputBitmap(
Bitmap inputBitmap,
TimestampIterator timestampIterator
)
Attempts to provide an input Bitmap to the consumer.
Should only be used for image data.
| Parameters | |
|---|---|
Bitmap inputBitmap |
The |
TimestampIterator timestampIterator |
A |
| Returns | |
|---|---|
int |
The |
queueInputBuffer
default boolean queueInputBuffer()
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 |
queueInputTexture
@SampleConsumer.InputResult
default int queueInputTexture(int texId, long presentationTimeUs)
Attempts to provide an input texture to the consumer.
Should only be used for raw video data.
| Parameters | |
|---|---|
int texId |
The ID of the texture to queue to the consumer. |
long presentationTimeUs |
The presentation time for the texture, in microseconds. |
| Returns | |
|---|---|
int |
The |
registerVideoFrame
default boolean registerVideoFrame(long presentationTimeUs)
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 | |
|---|---|
long presentationTimeUs |
The presentation time of the frame to register, in microseconds. |
| Returns | |
|---|---|
boolean |
Whether the frame was successfully registered. If |
setOnInputFrameProcessedListener
default void setOnInputFrameProcessedListener(
OnInputFrameProcessedListener listener
)
Provides a OnInputFrameProcessedListener to the consumer.
Should only be used for raw video data when input is provided by texture ID.
| Parameters | |
|---|---|
OnInputFrameProcessedListener listener |
setOnInputSurfaceReadyListener
default void setOnInputSurfaceReadyListener(Runnable runnable)
Sets a listener that's called when the input surface has been configured with a default input size, if applicable.
Should only be used for raw video data when input is provided by the app to a surface.
| Parameters | |
|---|---|
Runnable runnable |
Listener that's called when the input surface is ready. |
signalEndOfVideoInput
default void signalEndOfVideoInput()
Informs the consumer that no further input frames will be rendered.
Should only be used for raw video data.