class Media3Effect : CameraEffect, AutoCloseable


A CameraEffect that applies media3 Effect to the CameraX pipeline

This class is an adapter between the CameraX CameraEffect API and the media3 Effect API. It allows the media3 Effect to be applied to the CameraX pipeline on the fly without restarting the camera.

Code sample:

media3Effect = Media3Effect(requireContext(), PREVIEW or VIDEO_CAPTURE, executor) {
Log.e(TAG, "Error in Media3Effect: $it")
}

media3Effect.setEffects(listOf(Brightness(1.5f)))
cameraController.setEffects(setOf(media3Effect))

Summary

Public constructors

Media3Effect(
    context: Context,
    targets: Int,
    executor: Executor,
    errorListener: Consumer<Throwable>
)

Public functions

open Unit

Closes the Media3Effect and releases all the resources.

Unit
setEffects(effects: List<Effect>)

Applies a list of media3 effects to the camera output.

Inherited functions

From androidx.camera.core.CameraEffect
open Consumer<Throwable>

Gets the Error listener associated with this effect.

open Executor

Gets the Executor associated with this effect.

open SurfaceProcessor?

Gets the SurfaceProcessor associated with this effect.

open Int

Ges the target UseCases of this effect.

Public constructors

Media3Effect

Added in 1.0.0-alpha01
Media3Effect(
    context: Context,
    targets: Int,
    executor: Executor,
    errorListener: Consumer<Throwable>
)
Parameters
context: Context

the Android context

targets: Int

the target UseCase to which this effect should be applied. For details, see CameraEffect.

executor: Executor

the Executor on which the errorListener will be invoked.

errorListener: Consumer<Throwable>

invoked if the effect runs into unrecoverable errors. The Throwable will be the error thrown by this Media3Effect. This is invoked on the provided executor.

Public functions

close

Added in 1.0.0-alpha01
open fun close(): Unit

Closes the Media3Effect and releases all the resources.

The caller should only close when the effect when it's no longer in use. Once closed, the effect should not be used again.

setEffects

fun setEffects(effects: List<Effect>): Unit

Applies a list of media3 effects to the camera output.

Once set, the effects will be effective immediately. To clear the effect, call this method again with a empty list.