# 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)

*** ** * ** ***


```
@UnstableApi
public final class DefaultVideoCompositor implements VideoCompositor
```

<br />

*** ** * ** ***

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

The first `https://developer.android.com/reference/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 `https://developer.android.com/reference/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 `https://developer.android.com/reference/androidx/media3/common/OverlaySettings` output by `https://developer.android.com/reference/androidx/media3/common/VideoCompositorSettings`.

Only SDR input with the same `https://developer.android.com/reference/androidx/media3/common/ColorInfo` are supported.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/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)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/androidx/media3/common/GlObjectsProvider glObjectsProvider, https://developer.android.com/reference/java/util/concurrent/ExecutorService.html executorService, https://developer.android.com/reference/androidx/media3/effect/VideoCompositor.Listener listener, https://developer.android.com/reference/androidx/media3/effect/GlTextureProducer.Listener textureOutputListener, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int textureOutputCapacity )` Creates an instance. |

| ### Public methods |
|---|---|
| `synchronized void` | `https://developer.android.com/reference/androidx/media3/effect/DefaultVideoCompositor#queueInputTexture(int,androidx.media3.effect.GlTextureProducer,androidx.media3.common.GlTextureInfo,androidx.media3.common.ColorInfo,long)( int inputIndex, https://developer.android.com/reference/androidx/media3/effect/GlTextureProducer textureProducer, https://developer.android.com/reference/androidx/media3/common/GlTextureInfo inputTexture, https://developer.android.com/reference/androidx/media3/common/ColorInfo colorInfo, long presentationTimeUs )` Queues an input texture to be composited. |
| `synchronized void` | `https://developer.android.com/reference/androidx/media3/effect/DefaultVideoCompositor#registerInputSource(int)(int inputIndex)` Registers a new input source. |
| `synchronized void` | `https://developer.android.com/reference/androidx/media3/effect/DefaultVideoCompositor#release()()` Releases all resources. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/DefaultVideoCompositor#releaseOutputTexture(long)(long presentationTimeUs)` Releases the output texture at the given `presentationTimeUs`. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/DefaultVideoCompositor#setVideoCompositorSettings(androidx.media3.common.VideoCompositorSettings)( https://developer.android.com/reference/androidx/media3/common/VideoCompositorSettings videoCompositorSettings )` Sets the `https://developer.android.com/reference/androidx/media3/common/VideoCompositorSettings` to apply to inputs. |
| `synchronized void` | `https://developer.android.com/reference/androidx/media3/effect/DefaultVideoCompositor#signalEndOfInputSource(int)(int inputIndex)` Signals that no more frames will come from the upstream `https://developer.android.com/reference/androidx/media3/effect/GlTextureProducer.Listener`. |

## Public constructors

### DefaultVideoCompositor

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

Creates an instance.

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

## 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 `https://developer.android.com/reference/androidx/media3/effect/VideoCompositor#registerInputSource(int)`. |
| `https://developer.android.com/reference/androidx/media3/effect/GlTextureProducer textureProducer` | The source from where the `inputTexture` is produced. |
| `https://developer.android.com/reference/androidx/media3/common/GlTextureInfo inputTexture` | The `https://developer.android.com/reference/androidx/media3/common/GlTextureInfo` to composite. |
| `https://developer.android.com/reference/androidx/media3/common/ColorInfo colorInfo` | The `https://developer.android.com/reference/androidx/media3/common/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 `https://developer.android.com/reference/androidx/media3/effect/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`.

### setVideoCompositorSettings

```
public void setVideoCompositorSettings(
    VideoCompositorSettings videoCompositorSettings
)
```

Sets the `https://developer.android.com/reference/androidx/media3/common/VideoCompositorSettings` to apply to inputs.

### signalEndOfInputSource

```
synchronized public void signalEndOfInputSource(int inputIndex)
```

Signals that no more frames will come from the upstream `https://developer.android.com/reference/androidx/media3/effect/GlTextureProducer.Listener`.

| Parameters |
|---|---|
| `int inputIndex` | The index of the input source. |