DefaultVideoCompositor


@UnstableApi
class DefaultVideoCompositor : 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!,
    settings: VideoCompositorSettings!,
    executorService: ExecutorService?,
    listener: VideoCompositor.Listener!,
    textureOutputListener: GlTextureProducer.Listener!,
    textureOutputCapacity: @IntRange(from = 1) Int
)

Creates an instance.

Public functions

synchronized Unit
queueInputTexture(
    inputId: Int,
    textureProducer: GlTextureProducer!,
    inputTexture: GlTextureInfo!,
    colorInfo: ColorInfo!,
    presentationTimeUs: Long
)

Queues an input texture to be composited.

synchronized Int

Registers a new input source, and returns a unique inputId corresponding to this source, to be used in queueInputTexture.

synchronized Unit

Releases all resources.

Unit
releaseOutputTexture(presentationTimeUs: Long)

Releases the output texture at the given presentationTimeUs.

synchronized Unit

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

Public constructors

DefaultVideoCompositor

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

Creates an instance.

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

Public functions

queueInputTexture

synchronized fun queueInputTexture(
    inputId: Int,
    textureProducer: GlTextureProducer!,
    inputTexture: GlTextureInfo!,
    colorInfo: ColorInfo!,
    presentationTimeUs: Long
): Unit

Queues an input texture to be composited.

Parameters
inputId: Int

The identifier for an input source, returned from registerInputSource.

textureProducer: GlTextureProducer!

The source from where the inputTexture is produced.

inputTexture: GlTextureInfo!

The GlTextureInfo to composite.

colorInfo: ColorInfo!

The ColorInfo of inputTexture.

presentationTimeUs: Long

The presentation time of inputTexture, in microseconds.

registerInputSource

synchronized fun registerInputSource(): Int

Registers a new input source, and returns a unique inputId corresponding to this source, to be used in queueInputTexture.

release

synchronized fun release(): Unit

Releases all resources.

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

releaseOutputTexture

fun releaseOutputTexture(presentationTimeUs: Long): Unit

Releases the output texture at the given presentationTimeUs.

signalEndOfInputSource

synchronized fun signalEndOfInputSource(inputId: Int): Unit

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

Parameters
inputId: Int

The identifier for an input source, returned from registerInputSource.