SessionConfiguration


public final class SessionConfiguration
extends Object implements Parcelable

java.lang.Object
   ↳ android.hardware.camera2.params.SessionConfiguration


A helper class that aggregates all supported arguments for capture session initialization.

Summary

Constants

int SESSION_HIGH_SPEED

A high speed session type that can only contain instances of OutputConfiguration.

int SESSION_REGULAR

A regular session type containing instances of OutputConfiguration running at regular non high speed FPS ranges and optionally InputConfiguration for reprocessable sessions.

Inherited constants

Fields

public static final Creator<SessionConfiguration> CREATOR

Public constructors

SessionConfiguration(int sessionType, List<OutputConfiguration> outputs)

Create a new SessionConfiguration with sessionType and output configurations.

SessionConfiguration(int sessionType, List<OutputConfiguration> outputs, Executor executor, CameraCaptureSession.StateCallback cb)

Create a new SessionConfiguration.

Public methods

void clearColorSpace()

Clear the color space, such that the default color space will be used.

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

boolean equals(Object obj)

Check if this SessionConfiguration is equal to another SessionConfiguration.

ColorSpace getColorSpace()

Return the current color space.

Executor getExecutor()

Retrieve the Executor for the capture session.

InputConfiguration getInputConfiguration()

Retrieve the InputConfiguration.

List<OutputConfiguration> getOutputConfigurations()

Retrieve the OutputConfiguration list for the capture session.

CaptureRequest getSessionParameters()

Retrieve the session wide camera parameters (see CaptureRequest).

int getSessionType()

Retrieve the type of the capture session.

CameraCaptureSession.StateCallback getStateCallback()

Retrieve the CameraCaptureSession.StateCallback for the capture session.

int hashCode()

Returns a hash code value for the object.

void setColorSpace(ColorSpace.Named colorSpace)

Set a specific device-supported color space.

void setInputConfiguration(InputConfiguration input)

Sets the InputConfiguration for a reprocessable session.

void setSessionParameters(CaptureRequest params)

Sets the session wide camera parameters (see CaptureRequest).

void setStateCallback(Executor executor, CameraCaptureSession.StateCallback cb)

Set the state callback and executor.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

SESSION_HIGH_SPEED

Added in API level 28
public static final int SESSION_HIGH_SPEED

A high speed session type that can only contain instances of OutputConfiguration. The outputs can run using high speed FPS ranges. Calls to setInputConfiguration(InputConfiguration) are not supported.

When using this type, the CameraCaptureSession returned by CameraCaptureSession.StateCallback can be cast to a CameraConstrainedHighSpeedCaptureSession to access the extra methods for constrained high speed recording.

Constant Value: 1 (0x00000001)

SESSION_REGULAR

Added in API level 28
public static final int SESSION_REGULAR

A regular session type containing instances of OutputConfiguration running at regular non high speed FPS ranges and optionally InputConfiguration for reprocessable sessions.

Constant Value: 0 (0x00000000)

Fields

CREATOR

Added in API level 29
public static final Creator<SessionConfiguration> CREATOR

Public constructors

SessionConfiguration

Added in API level 35
public SessionConfiguration (int sessionType, 
                List<OutputConfiguration> outputs)

Create a new SessionConfiguration with sessionType and output configurations.

The SessionConfiguration objects created by this constructor can be used by CameraDeviceSetup.isSessionConfigurationSupported and CameraDevice.CameraDeviceSetup.getSessionCharacteristics(SessionConfiguration) to query a camera device's feature combination support and session specific characteristics. For the SessionConfiguration object to be used to create a capture session, setStateCallback(Executor, StateCallback) must be called to specify the state callback function, and any incomplete OutputConfigurations must be completed via OutputConfiguration.addSurface or OutputConfiguration.setSurfacesForMultiResolutionOutput as appropriate.

Parameters
sessionType int: The session type. Value is SESSION_REGULAR, or SESSION_HIGH_SPEED

outputs List: A list of output configurations for the capture session. This value cannot be null.

SessionConfiguration

Added in API level 28
public SessionConfiguration (int sessionType, 
                List<OutputConfiguration> outputs, 
                Executor executor, 
                CameraCaptureSession.StateCallback cb)

Create a new SessionConfiguration.

Parameters
sessionType int: The session type. Value is SESSION_REGULAR, or SESSION_HIGH_SPEED

outputs List: A list of output configurations for the capture session. This value cannot be null.

executor Executor: The executor which should be used to invoke the callback. In general it is recommended that camera operations are not done on the main (UI) thread. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

cb CameraCaptureSession.StateCallback: A state callback interface implementation. This value cannot be null.

Public methods

clearColorSpace

Added in API level 34
public void clearColorSpace ()

Clear the color space, such that the default color space will be used.

describeContents

Added in API level 29
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 28
public boolean equals (Object obj)

Check if this SessionConfiguration is equal to another SessionConfiguration.

Two output session configurations are only equal if and only if the underlying input configuration, output configurations, and session type are equal.

Parameters
obj Object: This value may be null.

Returns
boolean true if the objects were equal, false otherwise

getColorSpace

Added in API level 34
public ColorSpace getColorSpace ()

Return the current color space.

Returns
ColorSpace the currently set color space This value may be null.

getExecutor

Added in API level 28
public Executor getExecutor ()

Retrieve the Executor for the capture session.

Returns
Executor The Executor on which the callback will be invoked.

getInputConfiguration

Added in API level 28
public InputConfiguration getInputConfiguration ()

Retrieve the InputConfiguration.

Returns
InputConfiguration The capture session input configuration.

getOutputConfigurations

Added in API level 28
public List<OutputConfiguration> getOutputConfigurations ()

Retrieve the OutputConfiguration list for the capture session.

Returns
List<OutputConfiguration> A list of output configurations for the capture session.

getSessionParameters

Added in API level 28
public CaptureRequest getSessionParameters ()

Retrieve the session wide camera parameters (see CaptureRequest).

Returns
CaptureRequest A capture request that includes the initial values for any available session wide capture keys.

getSessionType

Added in API level 28
public int getSessionType ()

Retrieve the type of the capture session.

Returns
int The capture session type. Value is SESSION_REGULAR, or SESSION_HIGH_SPEED

getStateCallback

Added in API level 28
public CameraCaptureSession.StateCallback getStateCallback ()

Retrieve the CameraCaptureSession.StateCallback for the capture session.

Returns
CameraCaptureSession.StateCallback A state callback interface implementation.

hashCode

Added in API level 28
public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

Returns
int a hash code value for this object.

setColorSpace

Added in API level 34
public void setColorSpace (ColorSpace.Named colorSpace)

Set a specific device-supported color space.

Clients can choose from any profile advertised as supported in CameraCharacteristics.REQUEST_AVAILABLE_COLOR_SPACE_PROFILES queried using ColorSpaceProfiles.getSupportedColorSpaces. When set, the colorSpace will override the default color spaces of the output targets, or the color space implied by the dataSpace passed into an ImageReader's constructor.

Parameters
colorSpace ColorSpace.Named: This value cannot be null.

setInputConfiguration

Added in API level 28
public void setInputConfiguration (InputConfiguration input)

Sets the InputConfiguration for a reprocessable session. Input configuration are not supported for SESSION_HIGH_SPEED.

Parameters
input InputConfiguration: Input configuration. This value cannot be null.

Throws
UnsupportedOperationException In case it is called for SESSION_HIGH_SPEED type session configuration.

setSessionParameters

Added in API level 28
public void setSessionParameters (CaptureRequest params)

Sets the session wide camera parameters (see CaptureRequest). This argument can be set for every supported session type and will be passed to the camera device as part of the capture session initialization. Session parameters are a subset of the available capture request parameters (see CameraCharacteristics.getAvailableSessionKeys) and their application can introduce internal camera delays. To improve camera performance it is suggested to change them sparingly within the lifetime of the capture session and to pass their initial values as part of this method.

Parameters
params CaptureRequest: A capture request that includes the initial values for any available session wide capture keys. Tags (see CaptureRequest.Builder.setTag) and output targets (see CaptureRequest.Builder.addTarget) are ignored if set. Parameter values not part of CameraCharacteristics.getAvailableSessionKeys will also be ignored. It is recommended to build the session parameters using the same template type as the initial capture request, so that the session and initial request parameters match as much as possible.

setStateCallback

Added in API level 35
public void setStateCallback (Executor executor, 
                CameraCaptureSession.StateCallback cb)

Set the state callback and executor.

This function must be called for the SessionConfiguration object created via SessionConfiguration(int, List<OutputConfiguration>) before it's used to create a capture session.

Parameters
executor Executor: The executor which should be used to invoke the callback. In general it is recommended that camera operations are not done on the main (UI) thread. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

cb CameraCaptureSession.StateCallback: A state callback interface implementation. This value cannot be null.

writeToParcel

Added in API level 29
public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES