@UnstableApi
interface VideoSink


A sink that consumes decoded video frames.

Summary

Nested types

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
annotation VideoSink.InputType

Specifies how the input frames are made available to the video sink.

Listener for VideoSink events.

Thrown by VideoSink implementations.

Constants

const Int

Input frames come from a Bitmap.

const Int

Input frames come from a surface.

Public functions

Unit

Flushes the video sink.

Surface!

Returns the input Surface where the video sink consumes input frames from.

Boolean

Whether all queued video frames have been rendered, including the frame marked as last buffer.

Boolean

Whether frames could be dropped from the sink's input surface.

Boolean

Whether the video sink is able to immediately render media from the current position.

Boolean
queueBitmap(inputBitmap: Bitmap!, timestampIterator: TimestampIterator!)

Provides an input Bitmap to the video sink.

Long
registerInputFrame(framePresentationTimeUs: Long, isLastFrame: Boolean)

Informs the video sink that a frame will be queued to its input surface.

Unit

Informs the video sink that a new input stream will be queued.

Unit
render(positionUs: Long, elapsedRealtimeUs: Long)

Incrementally renders processed video frames.

Unit
setListener(listener: VideoSink.Listener!, executor: Executor!)

Sets a Listener on this sink.

Unit
setPlaybackSpeed(speed: @FloatRange(from = 0, fromInclusive = false) Float)

Sets the playback speed.

Constants

INPUT_TYPE_BITMAP

const val INPUT_TYPE_BITMAP = 2: Int

Input frames come from a Bitmap.

INPUT_TYPE_SURFACE

const val INPUT_TYPE_SURFACE = 1: Int

Input frames come from a surface.

Public functions

flush

fun flush(): Unit

Flushes the video sink.

After calling this method, any frames stored inside the video sink are discarded.

getInputSurface

fun getInputSurface(): Surface!

Returns the input Surface where the video sink consumes input frames from.

isEnded

fun isEnded(): Boolean

Whether all queued video frames have been rendered, including the frame marked as last buffer.

isFrameDropAllowedOnInput

fun isFrameDropAllowedOnInput(): Boolean

Whether frames could be dropped from the sink's input surface.

isReady

fun isReady(): Boolean

Whether the video sink is able to immediately render media from the current position.

queueBitmap

fun queueBitmap(inputBitmap: Bitmap!, timestampIterator: TimestampIterator!): Boolean

Provides an input Bitmap to the video sink.

Parameters
inputBitmap: Bitmap!

The Bitmap queued to the video sink.

timestampIterator: TimestampIterator!

The times within the current stream that the bitmap should be shown at. The timestamps should be monotonically increasing.

Returns
Boolean

Whether the bitmap was queued successfully. A false value indicates the caller must try again later.

registerInputFrame

fun registerInputFrame(framePresentationTimeUs: Long, isLastFrame: Boolean): Long

Informs the video sink that a frame will be queued to its input surface.

Parameters
framePresentationTimeUs: Long

The frame's presentation time, in microseconds.

isLastFrame: Boolean

Whether this is the last frame of the video stream.

Returns
Long

a release timestamp, in nanoseconds, that should be associated when releasing this frame, or TIME_UNSET if the sink was not able to register the frame and the caller must try again later.

registerInputStream

fun registerInputStream(@VideoSink.InputType inputType: Int, format: Format!): Unit

Informs the video sink that a new input stream will be queued.

Parameters
@VideoSink.InputType inputType: Int

The InputType of the stream.

format: Format!

The Format of the stream.

render

fun render(positionUs: Long, elapsedRealtimeUs: Long): Unit

Incrementally renders processed video frames.

Parameters
positionUs: Long

The current playback position, in microseconds.

elapsedRealtimeUs: Long

elapsedRealtime in microseconds, taken approximately at the time the playback position was positionUs.

Throws
androidx.media3.exoplayer.video.VideoSink.VideoSinkException

If an error occurs during rendering.

setListener

fun setListener(listener: VideoSink.Listener!, executor: Executor!): Unit

Sets a Listener on this sink. Callbacks are triggered on the supplied Executor.

Parameters
listener: VideoSink.Listener!

The Listener.

executor: Executor!

The Executor to dispatch the callbacks.

setPlaybackSpeed

fun setPlaybackSpeed(speed: @FloatRange(from = 0, fromInclusive = false) Float): Unit

Sets the playback speed.