ExtensionsManager

public final class ExtensionsManager
extends Object

java.lang.Object
   ↳ androidx.camera.extensions.ExtensionsManager


Provides interfaces for third party app developers to get capabilities info of extension functions.

Summary

Nested classes

enum ExtensionsManager.EffectMode

This enum is deprecated. Use ExtensionMode to call the new ExtensionsManager.isExtensionAvailable(CameraProvider, CameraSelector, int) and ExtensionsManager.getExtensionEnabledCameraSelector(CameraProvider, CameraSelector, int) APIs.  

enum ExtensionsManager.ExtensionsAvailability

 

Public methods

Range<Long> getEstimatedCaptureLatencyRange(CameraProvider cameraProvider, CameraSelector cameraSelector, int mode, Size surfaceResolution)

Returns the estimated capture latency range in milliseconds for the target capture resolution.

CameraSelector getExtensionEnabledCameraSelector(CameraProvider cameraProvider, CameraSelector baseCameraSelector, int mode)

Returns a modified CameraSelector that will enable the specified extension mode.

static ListenableFuture<ExtensionsManager> getInstance(Context context)

Retrieves the ExtensionsManager associated with the current process.

static ListenableFuture<ExtensionsManager.ExtensionsAvailability> init(Context context)

This method is deprecated. Use getInstance(Context) to obtain an ExtensionsManager instance to access the extensions functions.

static boolean isExtensionAvailable(Class<?> klass, ExtensionsManager.EffectMode effectMode, int lensFacing)

This method is deprecated. Use isExtensionAvailable(CameraProvider, CameraSelector, int) to check whether extension function can support with the given CameraSelector.

boolean isExtensionAvailable(CameraProvider cameraProvider, CameraSelector baseCameraSelector, int mode)

Returns true if the particular extension mode is available for the specified CameraSelector.

static boolean isExtensionAvailable(ExtensionsManager.EffectMode effectMode, int lensFacing)

This method is deprecated. Use isExtensionAvailable(CameraProvider, CameraSelector, int) to check whether extension function can support with the given CameraSelector.

static void setExtensionsErrorListener(ExtensionsErrorListener listener)

This method is deprecated. Currently, this is only used to monitor whether a Preview or ImageCapture is lacking when enabling extension modes. CameraX will automatically add an extra Preview or ImageCapture to make the extension functions work well. After that, no error will be reported via this interface.

Inherited methods

Public methods

getEstimatedCaptureLatencyRange

public Range<Long> getEstimatedCaptureLatencyRange (CameraProvider cameraProvider, 
                CameraSelector cameraSelector, 
                int mode, 
                Size surfaceResolution)

Returns the estimated capture latency range in milliseconds for the target capture resolution.

This includes the time spent processing the multi-frame capture request along with any additional time for encoding of the processed buffer in the framework if necessary.

Parameters
cameraProvider CameraProvider: A CameraProvider which will be used to bind use cases. The CameraProvider can be the ProcessCameraProvider which is obtained by ProcessCameraProvider.getInstance(Context).

cameraSelector CameraSelector: The CameraSelector to find a camera which supports the specified extension mode.

mode int: The extension mode to check.

surfaceResolution Size: the surface resolution of the ImageCapture which will be used to take a picture. If the input value of this parameter is null or it is not included in the supported output sizes, the maximum capture output size is used to get the estimated range information.

Returns
Range<Long> the range of estimated minimal and maximal capture latency in milliseconds. Returns null if no capture latency info can be provided.

Throws
IllegalArgumentException If this device doesn't support extensions function, or no camera can be found to support the specified extension mode.

getExtensionEnabledCameraSelector

public CameraSelector getExtensionEnabledCameraSelector (CameraProvider cameraProvider, 
                CameraSelector baseCameraSelector, 
                int mode)

Returns a modified CameraSelector that will enable the specified extension mode.

The returned extension CameraSelector can be used to bind use cases to a desired LifecycleOwner and then the specified extension mode will be enabled on the camera.

Parameters
cameraProvider CameraProvider: A CameraProvider which will be used to bind use cases. The CameraProvider can be the ProcessCameraProvider which is obtained by ProcessCameraProvider.getInstance(Context).

baseCameraSelector CameraSelector: The base CameraSelector on top of which the extension config is applied. isExtensionAvailable(CameraProvider, CameraSelector, int) can be used to check whether any camera can support the specified extension mode for the base camera selector.

mode int: The target extension mode.

Returns
CameraSelector a CameraSelector for the specified Extensions mode.

Throws
IllegalArgumentException If this device doesn't support extensions function, no camera can be found to support the specified extension mode, or the base CameraSelector has contained extension related configuration in it.

getInstance

public static ListenableFuture<ExtensionsManager> getInstance (Context context)

Retrieves the ExtensionsManager associated with the current process.

An application must wait until the ListenableFuture completes to get an ExtensionsManager instance. The ExtensionsManager instance can be used to access the extensions related functions.

Parameters
context Context

Returns
ListenableFuture<ExtensionsManager>

init

public static ListenableFuture<ExtensionsManager.ExtensionsAvailability> init (Context context)

This method is deprecated.
Use getInstance(Context) to obtain an ExtensionsManager instance to access the extensions functions.

Initialize the extensions asynchronously.

This should be the first call to the extensions module. An application must wait until the ListenableFuture completes before making any other calls to the extensions module.

Parameters
context Context

Returns
ListenableFuture<ExtensionsManager.ExtensionsAvailability>

isExtensionAvailable

public static boolean isExtensionAvailable (Class<?> klass, 
                ExtensionsManager.EffectMode effectMode, 
                int lensFacing)

This method is deprecated.
Use isExtensionAvailable(CameraProvider, CameraSelector, int) to check whether extension function can support with the given CameraSelector.

Indicates whether the camera device with the lensFacing can support the specific extension function for specific use case.

Parameters
klass Class: The ImageCapture or Preview class to be checked.

effectMode ExtensionsManager.EffectMode: The extension function to be checked.

lensFacing int: The lensFacing of the camera device to be checked.

Returns
boolean True if the specific extension function is supported for the camera device.

isExtensionAvailable

public boolean isExtensionAvailable (CameraProvider cameraProvider, 
                CameraSelector baseCameraSelector, 
                int mode)

Returns true if the particular extension mode is available for the specified CameraSelector.

Parameters
cameraProvider CameraProvider: A CameraProvider which will be used to bind use cases. The CameraProvider can be the ProcessCameraProvider which is obtained by ProcessCameraProvider.getInstance(Context).

baseCameraSelector CameraSelector: The base CameraSelector to find a camera to use.

mode int: The target extension mode to support.

Returns
boolean

isExtensionAvailable

public static boolean isExtensionAvailable (ExtensionsManager.EffectMode effectMode, 
                int lensFacing)

This method is deprecated.
Use isExtensionAvailable(CameraProvider, CameraSelector, int) to check whether extension function can support with the given CameraSelector.

Indicates whether the camera device with the lensFacing can support the specific extension function.

Parameters
effectMode ExtensionsManager.EffectMode: The extension function to be checked.

lensFacing int: The lensFacing of the camera device to be checked.

Returns
boolean True if the specific extension function is supported for the camera device.

setExtensionsErrorListener

public static void setExtensionsErrorListener (ExtensionsErrorListener listener)

This method is deprecated.
Currently, this is only used to monitor whether a Preview or ImageCapture is lacking when enabling extension modes. CameraX will automatically add an extra Preview or ImageCapture to make the extension functions work well. After that, no error will be reported via this interface.

Sets an ExtensionsErrorListener which will get called any time an extensions error is encountered.

Parameters
listener ExtensionsErrorListener: The ExtensionsErrorListener listener that will be run.