DefaultVideoCompositor


@UnstableApi
public final class DefaultVideoCompositor implements VideoCompositor


A basic VideoCompositor implementation that takes in frames from input sources' streams and combines them into one output stream.

The first registered source will be the primary stream, which is used to determine the output textures' timestamps and dimensions.

The input source must be able to have at least two queued textures in its output buffer.

When composited, textures are overlaid over one another in the reverse order of their registration order, so that the first registered source is on the very top. The way the textures are overlaid can be customized using the OverlaySettings output by .

Only SDR input with the same ColorInfo are supported.

Summary

Public constructors

DefaultVideoCompositor(
    Context context,
    GlObjectsProvider glObjectsProvider,
    VideoCompositorSettings settings,
    @Nullable ExecutorService executorService,
    VideoCompositor.Listener listener,
    GlTextureProducer.Listener textureOutputListener,
    @IntRange(from = 1) int textureOutputCapacity
)

Creates an instance.

Public methods

synchronized void
queueInputTexture(
    int inputIndex,
    GlTextureProducer textureProducer,
    GlTextureInfo inputTexture,
    ColorInfo colorInfo,
    long presentationTimeUs
)

Queues an input texture to be composited.

synchronized void
registerInputSource(int inputIndex)

Registers a new input source.

synchronized void

Releases all resources.

void
releaseOutputTexture(long presentationTimeUs)

Releases the output texture at the given presentationTimeUs.

synchronized void
signalEndOfInputSource(int inputIndex)

Signals that no more frames will come from the upstream GlTextureProducer.Listener.

Public constructors

DefaultVideoCompositor

public DefaultVideoCompositor(
    Context context,
    GlObjectsProvider glObjectsProvider,
    VideoCompositorSettings settings,
    @Nullable ExecutorService executorService,
    VideoCompositor.Listener listener,
    GlTextureProducer.Listener textureOutputListener,
    @IntRange(from = 1) int textureOutputCapacity
)

Creates an instance.

If a non-null executorService is set, the ExecutorService must be shut down by the caller.

Public methods

queueInputTexture

synchronized public void queueInputTexture(
    int inputIndex,
    GlTextureProducer textureProducer,
    GlTextureInfo inputTexture,
    ColorInfo colorInfo,
    long presentationTimeUs
)

Queues an input texture to be composited.

Parameters
int inputIndex

The index of the input source, the same index used when registering the input source.

GlTextureProducer textureProducer

The source from where the inputTexture is produced.

GlTextureInfo inputTexture

The GlTextureInfo to composite.

ColorInfo colorInfo

The ColorInfo of inputTexture.

long presentationTimeUs

The presentation time of inputTexture, in microseconds.

registerInputSource

synchronized public void registerInputSource(int inputIndex)

Registers a new input source.

The first registered input will be designated as the primary input.

release

synchronized public void release()

Releases all resources.

This VideoCompositor instance must not be used after this method is called.

releaseOutputTexture

public void releaseOutputTexture(long presentationTimeUs)

Releases the output texture at the given presentationTimeUs.

signalEndOfInputSource

synchronized public void signalEndOfInputSource(int inputIndex)

Signals that no more frames will come from the upstream GlTextureProducer.Listener.

Parameters
int inputIndex

The index of the input source.