Added in API level 28

SessionConfiguration


class SessionConfiguration : Parcelable
kotlin.Any
   ↳ android.hardware.camera2.params.SessionConfiguration

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

Summary

Constants
static Int

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

static Int

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

Inherited constants
Public constructors

Create a new SessionConfiguration.

Create a new SessionConfiguration with sessionType and output configurations.

Public methods
Unit

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

Int

Boolean
equals(other: Any?)

Check if this SessionConfiguration is equal to another SessionConfiguration.

ColorSpace?

Return the current color space.

Executor!

Retrieve the java.util.concurrent.Executor for the capture session.

InputConfiguration!

Retrieve the InputConfiguration.

MutableList<OutputConfiguration!>!

Retrieve the OutputConfiguration list for the capture session.

CaptureRequest!

Retrieve the session wide camera parameters (see CaptureRequest).

Int

Retrieve the type of the capture session.

CameraCaptureSession.StateCallback!

Retrieve the CameraCaptureSession.StateCallback for the capture session.

Int

Returns a hash code value for the object.

Unit

Set a specific device-supported color space.

Unit

Sets the InputConfiguration for a reprocessable session.

Unit

Sets the session wide camera parameters (see CaptureRequest).

Unit

Set the state callback and executor.

Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<SessionConfiguration!>

Constants

SESSION_HIGH_SPEED

Added in API level 28
static val SESSION_HIGH_SPEED: Int

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

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

Value: 1

SESSION_REGULAR

Added in API level 28
static val SESSION_REGULAR: Int

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

Value: 0

Public constructors

SessionConfiguration

Added in API level 28
SessionConfiguration(
    sessionType: Int,
    outputs: MutableList<OutputConfiguration!>,
    executor: Executor,
    cb: CameraCaptureSession.StateCallback)

Create a new SessionConfiguration.

Parameters
sessionType Int: The session type. Value is android.hardware.camera2.params.SessionConfiguration#SESSION_REGULAR, or android.hardware.camera2.params.SessionConfiguration#SESSION_HIGH_SPEED
outputs MutableList<OutputConfiguration!>: 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.

SessionConfiguration

Added in API level 35
SessionConfiguration(
    sessionType: Int,
    outputs: MutableList<OutputConfiguration!>)

Create a new SessionConfiguration with sessionType and output configurations.

The SessionConfiguration objects created by this constructor can be used by CameraDeviceSetup#isSessionConfigurationSupported and android.hardware.camera2.CameraDevice.CameraDeviceSetup#getSessionCharacteristics 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 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 android.hardware.camera2.params.SessionConfiguration#SESSION_REGULAR, or android.hardware.camera2.params.SessionConfiguration#SESSION_HIGH_SPEED
outputs MutableList<OutputConfiguration!>: A list of output configurations for the capture session. This value cannot be null.

Public methods

clearColorSpace

Added in API level 34
fun clearColorSpace(): Unit

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

describeContents

Added in API level 29
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 28
fun equals(other: Any?): Boolean

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 This value may be null.
Return
Boolean true if the objects were equal, false otherwise

getColorSpace

Added in API level 34
fun getColorSpace(): ColorSpace?

Return the current color space.

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

getExecutor

Added in API level 28
fun getExecutor(): Executor!

Retrieve the java.util.concurrent.Executor for the capture session.

Return
Executor! The Executor on which the callback will be invoked.

getInputConfiguration

Added in API level 28
fun getInputConfiguration(): InputConfiguration!

Retrieve the InputConfiguration.

Return
InputConfiguration! The capture session input configuration.

getOutputConfigurations

Added in API level 28
fun getOutputConfigurations(): MutableList<OutputConfiguration!>!

Retrieve the OutputConfiguration list for the capture session.

Return
MutableList<OutputConfiguration!>! A list of output configurations for the capture session.

getSessionParameters

Added in API level 28
fun getSessionParameters(): CaptureRequest!

Retrieve the session wide camera parameters (see CaptureRequest).

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

getSessionType

Added in API level 28
fun getSessionType(): Int

Retrieve the type of the capture session.

Return
Int The capture session type. Value is android.hardware.camera2.params.SessionConfiguration#SESSION_REGULAR, or android.hardware.camera2.params.SessionConfiguration#SESSION_HIGH_SPEED

getStateCallback

Added in API level 28
fun getStateCallback(): CameraCaptureSession.StateCallback!

Retrieve the CameraCaptureSession.StateCallback for the capture session.

Return
CameraCaptureSession.StateCallback! A state callback interface implementation.

hashCode

Added in API level 28
fun hashCode(): Int

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.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.
Return
Int a hash code value for this object.

setColorSpace

Added in API level 34
fun setColorSpace(colorSpace: ColorSpace.Named): Unit

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
fun setInputConfiguration(input: InputConfiguration): Unit

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.
Exceptions
java.lang.UnsupportedOperationException In case it is called for SESSION_HIGH_SPEED type session configuration.

setSessionParameters

Added in API level 28
fun setSessionParameters(params: CaptureRequest!): Unit

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
fun setStateCallback(
    executor: Executor,
    cb: CameraCaptureSession.StateCallback
): Unit

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
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
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_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 29
static val CREATOR: Parcelable.Creator<SessionConfiguration!>