@UnstableApi
public interface VideoSink


A sink that consumes decoded video frames.

Summary

Nested types

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

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

public interface VideoSink.Listener

Listener for VideoSink events.

public final class VideoSink.VideoSinkException extends Exception

Thrown by VideoSink implementations.

Constants

default static final int

Input frames come from a Bitmap.

default static final int

Input frames come from a surface.

Public methods

abstract void

Flushes the video sink.

abstract Surface

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

abstract boolean

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

abstract boolean

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

abstract boolean

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

abstract boolean
queueBitmap(Bitmap inputBitmap, TimestampIterator timestampIterator)

Provides an input Bitmap to the video sink.

abstract long
registerInputFrame(long framePresentationTimeUs, boolean isLastFrame)

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

abstract void

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

abstract void
render(long positionUs, long elapsedRealtimeUs)

Incrementally renders processed video frames.

abstract void
setListener(VideoSink.Listener listener, Executor executor)

Sets a Listener on this sink.

abstract void
setPlaybackSpeed(@FloatRange(from = 0, fromInclusive = false) float speed)

Sets the playback speed.

Constants

INPUT_TYPE_BITMAP

default static final int INPUT_TYPE_BITMAP = 2

Input frames come from a Bitmap.

INPUT_TYPE_SURFACE

default static final int INPUT_TYPE_SURFACE = 1

Input frames come from a surface.

Public methods

flush

abstract void flush()

Flushes the video sink.

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

getInputSurface

abstract Surface getInputSurface()

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

isEnded

abstract boolean isEnded()

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

isFrameDropAllowedOnInput

abstract boolean isFrameDropAllowedOnInput()

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

isReady

abstract boolean isReady()

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

queueBitmap

abstract boolean queueBitmap(Bitmap inputBitmap, TimestampIterator timestampIterator)

Provides an input Bitmap to the video sink.

Parameters
Bitmap inputBitmap

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

abstract long registerInputFrame(long framePresentationTimeUs, boolean isLastFrame)

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

Parameters
long framePresentationTimeUs

The frame's presentation time, in microseconds.

boolean isLastFrame

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

abstract void registerInputStream(@VideoSink.InputType int inputType, Format format)

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

Parameters
@VideoSink.InputType int inputType

The InputType of the stream.

Format format

The Format of the stream.

render

abstract void render(long positionUs, long elapsedRealtimeUs)

Incrementally renders processed video frames.

Parameters
long positionUs

The current playback position, in microseconds.

long elapsedRealtimeUs

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

abstract void setListener(VideoSink.Listener listener, Executor executor)

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

Parameters
VideoSink.Listener listener

The Listener.

Executor executor

The Executor to dispatch the callbacks.

setPlaybackSpeed

abstract void setPlaybackSpeed(@FloatRange(from = 0, fromInclusive = false) float speed)

Sets the playback speed.