# DefaultVideoCompositor

# DefaultVideoCompositor

Artifact:[androidx.media3:media3-effect](https://developer.android.com/jetpack/androidx/releases/media3)  
[View Source](https://cs.android.com/search?q=file:androidx/media3/effect/DefaultVideoCompositor.java+class:androidx.media3.effect.DefaultVideoCompositor)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/effect/DefaultVideoCompositor "View this page in Java")

<br />

```
@UnstableApi
class DefaultVideoCompositor : VideoCompositor
```

<br />

*** ** * ** ***

A basic[VideoCompositor](https://developer.android.com/reference/kotlin/androidx/media3/effect/VideoCompositor)implementation that takes in frames from input sources' streams and combines them into one output stream.

The first[registered source](https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultVideoCompositor#registerInputSource(int))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](https://developer.android.com/reference/kotlin/androidx/media3/effect/VideoCompositor#queueInputTexture(int,androidx.media3.effect.GlTextureProducer,androidx.media3.common.GlTextureInfo,androidx.media3.common.ColorInfo,long))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](https://developer.android.com/reference/kotlin/androidx/media3/common/OverlaySettings)output by[VideoCompositorSettings](https://developer.android.com/reference/kotlin/androidx/media3/common/VideoCompositorSettings).

Only SDR input with the same[ColorInfo](https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo)are supported.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ### Public constructors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DefaultVideoCompositor](https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultVideoCompositor#DefaultVideoCompositor(android.content.Context,androidx.media3.common.GlObjectsProvider,java.util.concurrent.ExecutorService,androidx.media3.effect.VideoCompositor.Listener,androidx.media3.effect.GlTextureProducer.Listener,int))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!,` ` glObjectsProvider: `[GlObjectsProvider](https://developer.android.com/reference/kotlin/androidx/media3/common/GlObjectsProvider)`!,` ` executorService: `[ExecutorService](https://developer.android.com/reference/java/util/concurrent/ExecutorService.html)`!,` ` listener: `[VideoCompositor.Listener](https://developer.android.com/reference/kotlin/androidx/media3/effect/VideoCompositor.Listener)`!,` ` textureOutputListener: `[GlTextureProducer.Listener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlTextureProducer.Listener)`!,` ` textureOutputCapacity: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Creates an instance. |

|                                     ### Public functions                                     |
|----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `synchronized `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [queueInputTexture](https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultVideoCompositor#queueInputTexture(int,androidx.media3.effect.GlTextureProducer,androidx.media3.common.GlTextureInfo,androidx.media3.common.ColorInfo,long))`(` ` inputIndex: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` textureProducer: `[GlTextureProducer](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlTextureProducer)`!,` ` inputTexture: `[GlTextureInfo](https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo)`!,` ` colorInfo: `[ColorInfo](https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo)`!,` ` presentationTimeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) `)` Queues an input texture to be composited. |
| `synchronized `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [registerInputSource](https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultVideoCompositor#registerInputSource(int))`(inputIndex: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Registers a new input source.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `synchronized `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [release](https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultVideoCompositor#release())`()` Releases all resources.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                | [releaseOutputTexture](https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultVideoCompositor#releaseOutputTexture(long))`(presentationTimeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Releases the output texture at the given`presentationTimeUs`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                | [setVideoCompositorSettings](https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultVideoCompositor#setVideoCompositorSettings(androidx.media3.common.VideoCompositorSettings))`(` ` videoCompositorSettings: `[VideoCompositorSettings](https://developer.android.com/reference/kotlin/androidx/media3/common/VideoCompositorSettings)`!` `)` Sets the[VideoCompositorSettings](https://developer.android.com/reference/kotlin/androidx/media3/common/VideoCompositorSettings)to apply to inputs.                                                                                                                                                                                                                                                                                                                                                                       |
| `synchronized `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [signalEndOfInputSource](https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultVideoCompositor#signalEndOfInputSource(int))`(inputIndex: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Signals that no more frames will come from the upstream[GlTextureProducer.Listener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlTextureProducer.Listener).                                                                                                                                                                                                                                                                                                                                                                                                                                                         |

## Public constructors

### DefaultVideoCompositor

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

Creates an instance.

It's the caller's responsibility to[release](https://developer.android.com/reference/kotlin/androidx/media3/common/GlObjectsProvider#release(android.opengl.EGLDisplay))the[GlObjectsProvider](https://developer.android.com/reference/kotlin/androidx/media3/common/GlObjectsProvider)on the[ExecutorService](https://developer.android.com/reference/java/util/concurrent/ExecutorService.html)'s thread, and to[shut down](https://developer.android.com/reference/java/util/concurrent/ExecutorService.html#shutdown())the[ExecutorService](https://developer.android.com/reference/java/util/concurrent/ExecutorService.html).  

## Public functions

### queueInputTexture

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

Queues an input texture to be composited.  

|                                                             Parameters                                                             |
|------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `inputIndex: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                          | The index of the input source, the same index used when[registering the input source](https://developer.android.com/reference/kotlin/androidx/media3/effect/VideoCompositor#registerInputSource(int)). |
| `textureProducer: `[GlTextureProducer](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlTextureProducer)`!` | The source from where the`inputTexture`is produced.                                                                                                                                                    |
| `inputTexture: `[GlTextureInfo](https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo)`!`            | The[GlTextureInfo](https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo)to composite.                                                                                   |
| `colorInfo: `[ColorInfo](https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo)`!`                       | The[ColorInfo](https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo)of`inputTexture`.                                                                                       |
| `presentationTimeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                | The presentation time of`inputTexture`, in microseconds.                                                                                                                                               |

### registerInputSource

```
synchronized fun registerInputSource(inputIndex: Int): Unit
```

Registers a new input source.

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

### release

```
synchronized fun release(): Unit
```

Releases all resources.

This[VideoCompositor](https://developer.android.com/reference/kotlin/androidx/media3/effect/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`.  

### setVideoCompositorSettings

```
fun setVideoCompositorSettings(
    videoCompositorSettings: VideoCompositorSettings!
): Unit
```

Sets the[VideoCompositorSettings](https://developer.android.com/reference/kotlin/androidx/media3/common/VideoCompositorSettings)to apply to inputs.  

### signalEndOfInputSource

```
synchronized fun signalEndOfInputSource(inputIndex: Int): Unit
```

Signals that no more frames will come from the upstream[GlTextureProducer.Listener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlTextureProducer.Listener).  

|                                        Parameters                                         |
|-------------------------------------------------------------------------------------------|--------------------------------|
| `inputIndex: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The index of the input source. |