public interface

SynchronizedCaptureSession.Opener

 androidx.camera.camera2.internal.SynchronizedCaptureSession.Opener

Overview

Opener interface to open the SynchronizedCaptureSession.

The SynchronizedCaptureSession.Opener.openCaptureSession(CameraDevice, SessionConfigurationCompat, List) method can be used to open a new SynchronizedCaptureSession, and the SessionConfigurationCompat object is needed by the SynchronizedCaptureSession.Opener.openCaptureSession(CameraDevice, SessionConfigurationCompat, List) should be created via the SynchronizedCaptureSession.Opener.createSessionConfigurationCompat(int, List, SynchronizedCaptureSession.StateCallback). It will send the ready-to-use SynchronizedCaptureSession to the provided listener's SynchronizedCaptureSession.StateCallback.onConfigured(SynchronizedCaptureSession) callback.

An Opener should only be used to open one SynchronizedCaptureSession. The Opener cannot be reused to open the second SynchronizedCaptureSession. The SynchronizedCaptureSession.Opener.openCaptureSession(CameraDevice, SessionConfigurationCompat, List) can't be called more than once in the same Opener.

Summary

Methods
public SessionConfigurationCompatcreateSessionConfigurationCompat(int sessionType, java.util.List<OutputConfigurationCompat> outputsCompat, SynchronizedCaptureSession.StateCallback stateCallback)

Create the SessionConfigurationCompat for SynchronizedCaptureSession.Opener.openCaptureSession(CameraDevice, SessionConfigurationCompat, List) used.

public java.util.concurrent.ExecutorgetExecutor()

public <any>openCaptureSession(CameraDevice cameraDevice, SessionConfigurationCompat sessionConfigurationCompat, java.util.List<DeferrableSurface> deferrableSurfaces)

Opens the SynchronizedCaptureSession.

public <any>startWithDeferrableSurface(java.util.List<DeferrableSurface> deferrableSurfaces, long timeout)

Get the surface from the DeferrableSurfaces.

public booleanstop()

Disable the startWithDeferrableSurface() and openCaptureSession() ability, and stop the startWithDeferrableSurface() and openCaptureSession() if CameraDevice#createCaptureSession() hasn't been invoked.

Methods

public <any> openCaptureSession(CameraDevice cameraDevice, SessionConfigurationCompat sessionConfigurationCompat, java.util.List<DeferrableSurface> deferrableSurfaces)

Opens the SynchronizedCaptureSession.

The behavior of this method similar to the CameraDevice. It will use the input cameraDevice to create the SynchronizedCaptureSession.

The SessionConfigurationCompat object that is needed in this method should be created via the SynchronizedCaptureSession.Opener.createSessionConfigurationCompat(int, List, SynchronizedCaptureSession.StateCallback).

The use count of the input DeferrableSurfaces will be increased. It will be automatically decreased when the surface is not used by the camera. For instance, when the opened SynchronizedCaptureSession is closed completely or when the configuration of the session is failed.

Cancellation of the returned future is a no-op. The opening task can only be cancelled by the SynchronizedCaptureSession.Opener.stop(). The SynchronizedCaptureSession.Opener.stop() only effective when the CameraDevice#createCaptureSession() hasn't been invoked. If the SynchronizedCaptureSession.Opener.stop() is called before the CameraDevice#createCaptureSession(), it will stop the SynchronizedCaptureSession creation. Otherwise, the SynchronizedCaptureSession will be created and the SynchronizedCaptureSession.StateCallback.onConfigured(SynchronizedCaptureSession) or SynchronizedCaptureSession.StateCallback.onConfigureFailed(SynchronizedCaptureSession) callback will be invoked.

Parameters:

cameraDevice: the camera with which to generate the SynchronizedCaptureSession
sessionConfigurationCompat: A SessionConfigurationCompat that is created via the SynchronizedCaptureSession.Opener.createSessionConfigurationCompat(int, List, SynchronizedCaptureSession.StateCallback).
deferrableSurfaces: the list of the DeferrableSurface that be used to configure the session.

Returns:

a ListenableFuture object which completes when the SynchronizedCaptureSession is configured.

See also: SynchronizedCaptureSession.Opener.createSessionConfigurationCompat(int, List, SynchronizedCaptureSession.StateCallback), SynchronizedCaptureSession.Opener.stop()

public SessionConfigurationCompat createSessionConfigurationCompat(int sessionType, java.util.List<OutputConfigurationCompat> outputsCompat, SynchronizedCaptureSession.StateCallback stateCallback)

Create the SessionConfigurationCompat for SynchronizedCaptureSession.Opener.openCaptureSession(CameraDevice, SessionConfigurationCompat, List) used. This method will add necessary information into the created SessionConfigurationCompat instance for SynchronizedCaptureSession.

Parameters:

sessionType: The session type.
outputsCompat: A list of output configurations for the SynchronizedCaptureSession.
stateCallback: A state callback interface implementation.

public <any> startWithDeferrableSurface(java.util.List<DeferrableSurface> deferrableSurfaces, long timeout)

Get the surface from the DeferrableSurfaces.

The SynchronizedCaptureSession.Opener.startWithDeferrableSurface(List, long) method will return a Surface list that is held in the List. The Opener helps in maintaining the timing to close the returned DeferrableSurface list. Most use case should attempt to use the SynchronizedCaptureSession.Opener.startWithDeferrableSurface(List, long) method to get the Surface for creating the SynchronizedCaptureSession.

Parameters:

deferrableSurfaces: The deferrable surfaces to open.
timeout: the timeout to get surfaces from the deferrable surface list.

Returns:

the Future which will contain the surface list, Cancellation of this future is a no-op. The returned Surface list can be used to create the SynchronizedCaptureSession.

See also: SynchronizedCaptureSession.Opener.openCaptureSession(CameraDevice, SessionConfigurationCompat, List), SynchronizedCaptureSession.Opener.stop()

public java.util.concurrent.Executor getExecutor()

public boolean stop()

Disable the startWithDeferrableSurface() and openCaptureSession() ability, and stop the startWithDeferrableSurface() and openCaptureSession() if CameraDevice#createCaptureSession() hasn't been invoked. Once the CameraDevice#createCaptureSession() already been invoked, the task of openCaptureSession() will keep going.

Returns:

true if the CameraCaptureSession creation has not been started yet. Otherwise return false.