Added in API level 24

OutputConfiguration

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

A class for describing camera output, which contains a Surface and its specific configuration for creating capture session.

There are several ways to instantiate, modify and use OutputConfigurations. The most common and recommended usage patterns are summarized in the following list:

As of Android P, all formats except ImageFormat#JPEG and ImageFormat#RAW_PRIVATE can be used for sharing, subject to device support. On prior API levels, only ImageFormat#PRIVATE format may be used.

Summary

Constants
static Int

Automatic mirroring based on camera facing

static Int

Camera output is mirrored horizontally

static Int

No mirror transform is applied

static Int

Camera output is mirrored vertically

static Int

Invalid surface group ID.

static Int

Timestamp is synchronized to choreographer.

static Int

Default timestamp base.

static Int

Timestamp base roughly the same as android.os.SystemClock#uptimeMillis.

static Int

Timestamp base roughly the same as android.os.SystemClock#elapsedRealtime.

static Int

Timestamp base of CameraCharacteristics#SENSOR_INFO_TIMESTAMP_SOURCE.

Inherited constants
Public constructors

Create a new OutputConfiguration instance with a Surface.

OutputConfiguration(surfaceGroupId: Int, surface: Surface)

Create a new OutputConfiguration instance with a Surface, with a surface group ID.

OutputConfiguration(surfaceSize: Size, klass: Class<T>)

Create a new OutputConfiguration instance, with desired Surface size and Surface source class.

Public methods
Unit
addSensorPixelModeUsed(sensorPixelModeUsed: Int)

Add a sensor pixel mode that this OutputConfiguration will be used in.

Unit
addSurface(surface: Surface)

Add a surface to this OutputConfiguration.

static MutableCollection<OutputConfiguration!>

Create a list of OutputConfiguration instances for the outputs used by a android.hardware.camera2.MultiResolutionImageReader.

Int

Unit

Enable multiple surfaces sharing the same OutputConfiguration

Boolean
equals(other: Any?)

Check if this OutputConfiguration is equal to another OutputConfiguration.

Long

Return current dynamic range profile.

Int

Get the maximum supported shared Surface count.

Int

Get the current mirroring mode

Long

Get the current stream use case

Surface?

Get the Surface associated with this OutputConfiguration.

Int

Get the surface group ID associated with this OutputConfiguration.

MutableList<Surface!>

Get the immutable list of surfaces associated with this OutputConfiguration.

Int

Get the current timestamp base

Int

Returns a hash code value for the object.

Boolean

Whether readout timestamp is used for this OutputConfiguration.

Unit
removeSensorPixelModeUsed(sensorPixelModeUsed: Int)

Remove a sensor pixel mode, previously added through addSensorPixelModeUsed, from this OutputConfiguration.

Unit

Remove a surface from this OutputConfiguration.

Unit

Set a specific device supported dynamic range profile.

Unit
setMirrorMode(mirrorMode: Int)

Set the mirroring mode for this output target

Unit
setPhysicalCameraId(physicalCameraId: String?)

Set the id of the physical camera for this OutputConfiguration

Unit

Use the camera sensor's readout time for the image timestamp.

Unit
setStreamUseCase(streamUseCase: Long)

Set stream use case for this OutputConfiguration

Unit
setTimestampBase(timestampBase: Int)

Set timestamp base for this output target

Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<OutputConfiguration!>

Constants

MIRROR_MODE_AUTO

Added in API level 33
static val MIRROR_MODE_AUTO: Int

Automatic mirroring based on camera facing

This is the default mirroring mode for the camera device. With this mode, the camera output is mirrored horizontally for front-facing cameras. There is no mirroring for rear-facing and external cameras.

Value: 0

MIRROR_MODE_H

Added in API level 33
static val MIRROR_MODE_H: Int

Camera output is mirrored horizontally

The camera output is mirrored horizontally, the same behavior as in AUTO mode for front facing camera.

Value: 2

MIRROR_MODE_NONE

Added in API level 33
static val MIRROR_MODE_NONE: Int

No mirror transform is applied

No mirroring is applied to the camera output regardless of the camera facing.

Value: 1

MIRROR_MODE_V

Added in API level 33
static val MIRROR_MODE_V: Int

Camera output is mirrored vertically

Value: 3

SURFACE_GROUP_ID_NONE

Added in API level 24
static val SURFACE_GROUP_ID_NONE: Int

Invalid surface group ID.

An OutputConfiguration with this value indicates that the included surface doesn't belong to any surface group.

Value: -1

TIMESTAMP_BASE_CHOREOGRAPHER_SYNCED

Added in API level 33
static val TIMESTAMP_BASE_CHOREOGRAPHER_SYNCED: Int

Timestamp is synchronized to choreographer.

The timestamp of the output images are overridden with choreographer pulses from the display subsystem for smoother display of camera frames. An output target of SurfaceView uses this time base by default. Note that the timestamp override is done for fixed camera frame rate only.

This timestamp base isn't applicable to SurfaceTexture targets. SurfaceTexture's updateTexImage function always uses the latest image from the camera stream. In the case of a TextureView, the image is displayed right away.

Timestamps with this time base cannot directly match the timestamps in CameraCaptureSession.CaptureCallback#onCaptureStarted, android.hardware.camera2.CameraCaptureSession.CaptureCallback#onReadoutStarted, or the sensor timestamps in android.hardware.camera2.CaptureResult. This timestamp base shouldn't be used if the timestamp needs to be used for audio-video synchronization.

Value: 4

TIMESTAMP_BASE_DEFAULT

Added in API level 33
static val TIMESTAMP_BASE_DEFAULT: Int

Default timestamp base.

The camera device decides the timestamp based on the properties of the output surface.

  • For a SurfaceView output surface, the timestamp base is TIMESTAMP_BASE_CHOREOGRAPHER_SYNCED. The timestamp is overridden with choreographer pulses from the display subsystem for smoother display of camera frames when the camera device runs in fixed frame rate. The timestamp is roughly in the same time base as android.os.SystemClock#uptimeMillis.
  • For an output surface of MediaRecorder, MediaCodec, or ImageReader with android.hardware.HardwareBuffer#USAGE_VIDEO_ENCODE usage flag, the timestamp base is TIMESTAMP_BASE_MONOTONIC, which is roughly the same time base as android.os.SystemClock#uptimeMillis.
  • For all other cases, the timestamp base is TIMESTAMP_BASE_SENSOR, the same as what's specified by CameraCharacteristics#SENSOR_INFO_TIMESTAMP_SOURCE.
    • For a SurfaceTexture output surface, the camera system re-spaces the delivery of output frames based on image readout intervals, reducing viewfinder jitter. The timestamps of images remain to be TIMESTAMP_BASE_SENSOR.
  • Note that the reduction of frame jitter for SurfaceView and SurfaceTexture comes with slight increase in photon-to-photon latency, which is the time from when photons hit the scene to when the corresponding pixels show up on the screen. If the photon-to-photon latency is more important than the smoothness of viewfinder, TIMESTAMP_BASE_SENSOR should be used instead.

    Value: 0

    TIMESTAMP_BASE_MONOTONIC

    Added in API level 33
    static val TIMESTAMP_BASE_MONOTONIC: Int

    Timestamp base roughly the same as android.os.SystemClock#uptimeMillis.

    The timestamps of the output images are monotonically increasing, and are roughly in the same time base as android.os.SystemClock#uptimeMillis. The timestamps with this time base can be directly used for audio-video sync in video recording.

    If the camera device's CameraCharacteristics#SENSOR_INFO_TIMESTAMP_SOURCE is REALTIME, timestamps with this time base cannot directly match the timestamps in CameraCaptureSession.CaptureCallback#onCaptureStarted, android.hardware.camera2.CameraCaptureSession.CaptureCallback#onReadoutStarted, or the sensor timestamps in android.hardware.camera2.CaptureResult.

    Value: 2

    TIMESTAMP_BASE_REALTIME

    Added in API level 33
    static val TIMESTAMP_BASE_REALTIME: Int

    Timestamp base roughly the same as android.os.SystemClock#elapsedRealtime.

    The timestamps of the output images are roughly in the same time base as android.os.SystemClock#elapsedRealtime. The timestamps with this time base cannot be directly used for audio-video sync in video recording.

    If the camera device's CameraCharacteristics#SENSOR_INFO_TIMESTAMP_SOURCE is UNKNOWN, timestamps with this time base cannot directly match the timestamps in CameraCaptureSession.CaptureCallback#onCaptureStarted, android.hardware.camera2.CameraCaptureSession.CaptureCallback#onReadoutStarted, or the sensor timestamps in android.hardware.camera2.CaptureResult.

    If using a REALTIME timestamp base on a device that supports only TIMESTAMP_SOURCE_UNKNOWN, the accuracy of timestamps is only what is guaranteed in the documentation for UNKNOWN. In particular, they have no guarantees about being accurate enough to use in fusing image data with the output of inertial sensors, for features such as image stabilization or augmented reality.

    Value: 3

    TIMESTAMP_BASE_SENSOR

    Added in API level 33
    static val TIMESTAMP_BASE_SENSOR: Int

    Timestamp base of CameraCharacteristics#SENSOR_INFO_TIMESTAMP_SOURCE.

    The timestamps of the output images are in the time base as specified by android.hardware.camera2.CameraCharacteristics#SENSOR_INFO_TIMESTAMP_SOURCE. The application can look up the corresponding result metadata by matching the timestamp with a android.hardware.camera2.CameraCaptureSession.CaptureCallback#onCaptureStarted, or with a android.hardware.camera2.CameraCaptureSession.CaptureCallback#onReadoutStarted if readout timestamp is used.

    Value: 1

    Public constructors

    OutputConfiguration

    Added in API level 24
    OutputConfiguration(surface: Surface)

    Create a new OutputConfiguration instance with a Surface.

    Parameters
    surface Surface: A Surface for camera to output to.

    This constructor creates a default configuration, with a surface group ID of {@value #SURFACE_GROUP_ID_NONE}.

    This value cannot be null.

    OutputConfiguration

    Added in API level 24
    OutputConfiguration(
        surfaceGroupId: Int,
        surface: Surface)

    Create a new OutputConfiguration instance with a Surface, with a surface group ID.

    A surface group ID is used to identify which surface group this output surface belongs to. A surface group is a group of output surfaces that are not intended to receive camera output buffer streams simultaneously. The CameraDevice may be able to share the buffers used by all the surfaces from the same surface group, therefore may reduce the overall memory footprint. The application should only set the same set ID for the streams that are not simultaneously streaming. A negative ID indicates that this surface doesn't belong to any surface group. The default value is {@value #SURFACE_GROUP_ID_NONE}.

    For example, a video chat application that has an adaptive output resolution feature would need two (or more) output resolutions, to switch resolutions without any output glitches. However, at any given time, only one output is active to minimize outgoing network bandwidth and encoding overhead. To save memory, the application should set the video outputs to have the same non-negative group ID, so that the camera device can share the same memory region for the alternating outputs.

    It is not an error to include output streams with the same group ID in the same capture request, but the resulting memory consumption may be higher than if the two streams were not in the same surface group to begin with, especially if the outputs have substantially different dimensions.

    Parameters
    surfaceGroupId Int: A group ID for this output, used for sharing memory between multiple outputs.
    surface Surface: A Surface for camera to output to. This value cannot be null.

    OutputConfiguration

    Added in API level 24
    OutputConfiguration(
        surfaceSize: Size,
        klass: Class<T>)

    Create a new OutputConfiguration instance, with desired Surface size and Surface source class.

    This constructor takes an argument for desired Surface size and the Surface source class without providing the actual output Surface. This is used to setup an output configuration with a deferred Surface. The application can use this output configuration to create a session.

    However, the actual output Surface must be set via addSurface and the deferred Surface configuration must be finalized via android.hardware.camera2.CameraCaptureSession#finalizeOutputConfigurations before submitting a request with this Surface target. The deferred Surface can only be obtained either from by calling android.view.SurfaceHolder#getSurface, or from android.graphics.SurfaceTexture via android.view.Surface#Surface(android.graphics.SurfaceTexture)).

    Parameters
    surfaceSize Size: Size for the deferred surface. This value cannot be null.
    klass Class<T>: a non-null Class object reference that indicates the source of this surface. Only SurfaceHolder.class and SurfaceTexture.class are supported.
    Exceptions
    java.lang.IllegalArgumentException if the Surface source class is not supported, or Surface size is zero.

    Public methods

    addSensorPixelModeUsed

    Added in API level 31
    fun addSensorPixelModeUsed(sensorPixelModeUsed: Int): Unit

    Add a sensor pixel mode that this OutputConfiguration will be used in.

    In the case that this output stream configuration (format, width, height) is available through android.hardware.camera2.CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP configurations and android.hardware.camera2.CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP_MAXIMUM_RESOLUTION, configurations, the camera sub-system will assume that this OutputConfiguration will be used only with android.hardware.camera2.CaptureRequests which has android.hardware.camera2.CaptureRequest#SENSOR_PIXEL_MODE set to android.hardware.camera2.CameraMetadata#SENSOR_PIXEL_MODE_DEFAULT. In such cases, if clients intend to use the OutputConfiguration(s) in a android.hardware.camera2.CaptureRequest with other sensor pixel modes, they must specify which android.hardware.camera2.CaptureRequest#SENSOR_PIXEL_MODE(s) they will use this OutputConfiguration with, by calling this method. In case this output stream configuration (format, width, height) is only in android.hardware.camera2.CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP_MAXIMUM_RESOLUTION, configurations, this output target must only be used with android.hardware.camera2.CaptureRequests which has android.hardware.camera2.CaptureRequest#SENSOR_PIXEL_MODE set to android.hardware.camera2.CameraMetadata#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION and that is what the camera sub-system will assume. If clients add android.hardware.camera2.CameraMetadata#SENSOR_PIXEL_MODE_DEFAULT in this case, session configuration will fail, if this OutputConfiguration is included. In case this output stream configuration (format, width, height) is only in android.hardware.camera2.CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP, configurations, this output target must only be used with android.hardware.camera2.CaptureRequests which has android.hardware.camera2.CaptureRequest#SENSOR_PIXEL_MODE set to android.hardware.camera2.CameraMetadata#SENSOR_PIXEL_MODE_DEFAULT and that is what the camera sub-system will assume. If clients add android.hardware.camera2.CameraMetadata#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION in this case, session configuration will fail, if this OutputConfiguration is included.

    Parameters
    sensorPixelModeUsed Int: The sensor pixel mode this OutputConfiguration will be used with

    Value is android.hardware.camera2.CameraMetadata#SENSOR_PIXEL_MODE_DEFAULT, or android.hardware.camera2.CameraMetadata#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION

    addSurface

    Added in API level 26
    fun addSurface(surface: Surface): Unit

    Add a surface to this OutputConfiguration.

    This function can be called before or after android.hardware.camera2.CameraDevice#createCaptureSessionByOutputConfigurations. If it's called after, the application must finalize the capture session with CameraCaptureSession#finalizeOutputConfigurations. It is possible to call this method after the output configurations have been finalized only in cases of enabled surface sharing see enableSurfaceSharing. The modified output configuration must be updated with CameraCaptureSession#updateOutputConfiguration.

    If the OutputConfiguration was constructed with a deferred surface by android.hardware.camera2.params.OutputConfiguration#OutputConfiguration(android.util.Size,java.lang.Class), the added surface must be obtained from android.view.SurfaceView by calling android.view.SurfaceHolder#getSurface, or from android.graphics.SurfaceTexture via android.view.Surface#Surface(android.graphics.SurfaceTexture)).

    If the OutputConfiguration was constructed by other constructors, the added surface must be compatible with the existing surface. See enableSurfaceSharing for details of compatible surfaces.

    If the OutputConfiguration already contains a Surface, enableSurfaceSharing must be called before calling this function to add a new Surface.

    Parameters
    surface Surface: The surface to be added. This value cannot be null.
    Exceptions
    java.lang.IllegalArgumentException if the Surface is invalid, the Surface's dataspace/format doesn't match, or adding the Surface would exceed number of shared surfaces supported.
    java.lang.IllegalStateException if the Surface was already added to this OutputConfiguration, or if the OutputConfiguration is not shared and it already has a surface associated with it.

    createInstancesForMultiResolutionOutput

    Added in API level 31
    static fun createInstancesForMultiResolutionOutput(multiResolutionImageReader: MultiResolutionImageReader): MutableCollection<OutputConfiguration!>

    Create a list of OutputConfiguration instances for the outputs used by a android.hardware.camera2.MultiResolutionImageReader.

    This constructor takes an argument for a android.hardware.camera2.MultiResolutionImageReader.

    Parameters
    multiResolutionImageReader MultiResolutionImageReader: The multi-resolution image reader object. This value cannot be null.
    Return
    MutableCollection<OutputConfiguration!> This value cannot be null.

    describeContents

    Added in API level 24
    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

    enableSurfaceSharing

    Added in API level 26
    fun enableSurfaceSharing(): Unit

    Enable multiple surfaces sharing the same OutputConfiguration

    For advanced use cases, a camera application may require more streams than the combination guaranteed by android.hardware.camera2.CameraDevice#createCaptureSession. In this case, more than one compatible surface can be attached to an OutputConfiguration so that they map to one camera stream, and the outputs share memory buffers when possible. Due to buffer sharing clients should be careful when adding surface outputs that modify their input data. If such case exists, camera clients should have an additional mechanism to synchronize read and write access between individual consumers.

    Two surfaces are compatible in the below cases:

  • Surfaces with the same size, format, dataSpace, and Surface source class. In this case, CameraDevice#createCaptureSessionByOutputConfigurations is guaranteed to succeed.
  • Surfaces with the same size, format, and dataSpace, but different Surface source classes that are generally not compatible. However, on some devices, the underlying camera device is able to use the same buffer layout for both surfaces. The only way to discover if this is the case is to create a capture session with that output configuration. For example, if the camera device uses the same private buffer format between a SurfaceView/SurfaceTexture and a MediaRecorder/MediaCodec, CameraDevice#createCaptureSessionByOutputConfigurations will succeed. Otherwise, it fails with android.hardware.camera2.CameraCaptureSession.StateCallback#onConfigureFailed.

    To enable surface sharing, this function must be called before android.hardware.camera2.CameraDevice#createCaptureSessionByOutputConfigurations or android.hardware.camera2.CameraDevice#createReprocessableCaptureSessionByConfigurations. Calling this function after CameraDevice#createCaptureSessionByOutputConfigurations has no effect.

    Up to getMaxSharedSurfaceCount surfaces can be shared for an OutputConfiguration. The supported surfaces for sharing must be of type SurfaceTexture, SurfaceView, MediaRecorder, MediaCodec, or implementation defined ImageReader.

    This function must not be called from OutputConfigurations created by createInstancesForMultiResolutionOutput.

  • Exceptions
    java.lang.IllegalStateException If this OutputConfiguration is created via createInstancesForMultiResolutionOutput to back a MultiResolutionImageReader.

    equals

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

    Check if this OutputConfiguration is equal to another OutputConfiguration.

    Two output configurations are only equal if and only if the underlying surfaces, surface properties (width, height, format, dataspace) when the output configurations are created, and all other configuration parameters are equal.

    Parameters
    obj This value may be null.
    Return
    Boolean true if the objects were equal, false otherwise

    getMaxSharedSurfaceCount

    Added in API level 28
    fun getMaxSharedSurfaceCount(): Int

    Get the maximum supported shared Surface count.

    Return
    Int the maximum number of surfaces that can be added per each OutputConfiguration.

    getStreamUseCase

    Added in API level 33
    fun getStreamUseCase(): Long

    Get the current stream use case

    If no setStreamUseCase is called first, this function returns DEFAULT.

    Return
    Long the currently set stream use case

    getSurface

    Added in API level 24
    fun getSurface(): Surface?

    Get the Surface associated with this OutputConfiguration. If more than one surface is associated with this OutputConfiguration, return the first one as specified in the constructor or OutputConfiguration#addSurface.

    Return
    Surface? This value may be null.

    getSurfaceGroupId

    Added in API level 24
    fun getSurfaceGroupId(): Int

    Get the surface group ID associated with this OutputConfiguration.

    Return
    Int the surface group ID associated with this OutputConfiguration. The default value is {@value #SURFACE_GROUP_ID_NONE}.

    getSurfaces

    Added in API level 26
    fun getSurfaces(): MutableList<Surface!>

    Get the immutable list of surfaces associated with this OutputConfiguration.

    Return
    MutableList<Surface!> the list of surfaces associated with this OutputConfiguration as specified in the constructor and OutputConfiguration#addSurface. The list should not be modified. This value cannot be null.

    hashCode

    Added in API level 24
    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.

    isReadoutTimestampEnabled

    Added in API level 34
    fun isReadoutTimestampEnabled(): Boolean

    Whether readout timestamp is used for this OutputConfiguration.

    removeSensorPixelModeUsed

    Added in API level 31
    fun removeSensorPixelModeUsed(sensorPixelModeUsed: Int): Unit

    Remove a sensor pixel mode, previously added through addSensorPixelModeUsed, from this OutputConfiguration.

    Sensor pixel modes added via calls to addSensorPixelModeUsed can also be removed from the OutputConfiguration.

    Parameters
    sensorPixelModeUsed Int: The sensor pixel mode to be removed. Value is android.hardware.camera2.CameraMetadata#SENSOR_PIXEL_MODE_DEFAULT, or android.hardware.camera2.CameraMetadata#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION
    Exceptions
    java.lang.IllegalArgumentException If the sensor pixel mode wasn't previously added through addSensorPixelModeUsed.

    removeSurface

    Added in API level 28
    fun removeSurface(surface: Surface): Unit

    Remove a surface from this OutputConfiguration.

    Surfaces added via calls to addSurface can also be removed from the OutputConfiguration. The only notable exception is the surface associated with the OutputConfiguration see getSurface which was passed as part of the constructor or was added first in the deferred case OutputConfiguration#OutputConfiguration(Size, Class).

    Parameters
    surface Surface: The surface to be removed. This value cannot be null.
    Exceptions
    java.lang.IllegalArgumentException If the surface is associated with this OutputConfiguration (see getSurface) or the surface didn't get added with addSurface.

    setDynamicRangeProfile

    Added in API level 33
    fun setDynamicRangeProfile(profile: Long): Unit

    Set a specific device supported dynamic range profile.

    Clients can choose from any profile advertised as supported in CameraCharacteristics.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES queried using DynamicRangeProfiles#getSupportedProfiles(). If this is not explicitly set, then the default profile will be DynamicRangeProfiles#STANDARD.

    Do note that invalid combinations between the registered output surface pixel format and the configured dynamic range profile will cause capture session initialization failure. Invalid combinations include any 10-bit dynamic range profile advertised in DynamicRangeProfiles#getSupportedProfiles() combined with an output Surface pixel format different from ImageFormat#PRIVATE (the default for Surfaces initialized by android.view.SurfaceView, android.view.TextureView, android.media.MediaRecorder, android.media.MediaCodec etc.) or ImageFormat#YCBCR_P010.

    Parameters
    profile Long: Value is android.hardware.camera2.params.DynamicRangeProfiles#STANDARD, android.hardware.camera2.params.DynamicRangeProfiles#HLG10, android.hardware.camera2.params.DynamicRangeProfiles#HDR10, android.hardware.camera2.params.DynamicRangeProfiles#HDR10_PLUS, android.hardware.camera2.params.DynamicRangeProfiles#DOLBY_VISION_10B_HDR_REF, android.hardware.camera2.params.DynamicRangeProfiles#DOLBY_VISION_10B_HDR_REF_PO, android.hardware.camera2.params.DynamicRangeProfiles#DOLBY_VISION_10B_HDR_OEM, android.hardware.camera2.params.DynamicRangeProfiles#DOLBY_VISION_10B_HDR_OEM_PO, android.hardware.camera2.params.DynamicRangeProfiles#DOLBY_VISION_8B_HDR_REF, android.hardware.camera2.params.DynamicRangeProfiles#DOLBY_VISION_8B_HDR_REF_PO, android.hardware.camera2.params.DynamicRangeProfiles#DOLBY_VISION_8B_HDR_OEM, or android.hardware.camera2.params.DynamicRangeProfiles#DOLBY_VISION_8B_HDR_OEM_PO

    setMirrorMode

    Added in API level 33
    fun setMirrorMode(mirrorMode: Int): Unit

    Set the mirroring mode for this output target

    If this function is not called, the mirroring mode for this output is MIRROR_MODE_AUTO, with which the camera API will mirror the output images horizontally for front facing camera.

    For efficiency, the mirror effect is applied as a transform flag, so it is only effective in some outputs. It works automatically for SurfaceView and TextureView outputs. For manual use of SurfaceTexture, it is reflected in the value of android.graphics.SurfaceTexture#getTransformMatrix. For other end points, such as ImageReader, MediaRecorder, or MediaCodec, the mirror mode has no effect. If mirroring is needed for such outputs, the application needs to mirror the image buffers itself before passing them onward.

    Parameters
    mirrorMode Int: Value is android.hardware.camera2.params.OutputConfiguration#MIRROR_MODE_AUTO, android.hardware.camera2.params.OutputConfiguration#MIRROR_MODE_NONE, android.hardware.camera2.params.OutputConfiguration#MIRROR_MODE_H, or android.hardware.camera2.params.OutputConfiguration#MIRROR_MODE_V

    setPhysicalCameraId

    Added in API level 28
    fun setPhysicalCameraId(physicalCameraId: String?): Unit

    Set the id of the physical camera for this OutputConfiguration

    In the case one logical camera is made up of multiple physical cameras, it could be desirable for the camera application to request streams from individual physical cameras. This call achieves it by mapping the OutputConfiguration to the physical camera id.

    The valid physical camera ids can be queried by android.hardware.camera2.CameraCharacteristics#getPhysicalCameraIds.

    Passing in a null physicalCameraId means that the OutputConfiguration is for a logical stream.

    This function must be called before android.hardware.camera2.CameraDevice#createCaptureSessionByOutputConfigurations or android.hardware.camera2.CameraDevice#createReprocessableCaptureSessionByConfigurations. Calling this function after CameraDevice#createCaptureSessionByOutputConfigurations or android.hardware.camera2.CameraDevice#createReprocessableCaptureSessionByConfigurations has no effect.

    As of Android 12, an image buffer from a physical camera stream can be used for reprocessing to logical camera streams and streams from the same physical camera if the camera device supports multi-resolution input and output streams. See CameraCharacteristics#SCALER_MULTI_RESOLUTION_STREAM_CONFIGURATION_MAP for details. The behaviors of reprocessing from a non-physical camera stream to a physical camera stream, and from a physical camera stream to a physical camera stream of different physical camera, are device-specific and not guaranteed to be supported.

    On prior API levels, the surface belonging to a physical camera OutputConfiguration must not be used as input or output of a reprocessing request.

    Parameters
    physicalCameraId String?: This value may be null.

    setReadoutTimestampEnabled

    Added in API level 34
    fun setReadoutTimestampEnabled(on: Boolean): Unit

    Use the camera sensor's readout time for the image timestamp.

    The start of the camera sensor readout after exposure. For a rolling shutter camera sensor, the timestamp is typically equal to (the start of exposure time) + (exposure time) + (certain fixed offset). The fixed offset can vary per session, depending on the underlying sensor configuration. The benefit of using readout time is that when camera runs in a fixed frame rate, the timestamp intervals between frames are constant.

    Readout timestamp is supported only if android.hardware.camera2.CameraCharacteristics#SENSOR_READOUT_TIMESTAMP is CameraMetadata#SENSOR_READOUT_TIMESTAMP_HARDWARE.

    As long as readout timestamp is supported, if the timestamp base is TIMESTAMP_BASE_CHOREOGRAPHER_SYNCED, or if the timestamp base is DEFAULT for a SurfaceView output, the image timestamps for the output are always readout time regardless of whether this function is called.

    Parameters
    on Boolean: The output image timestamp is the start of exposure time if false, and the start of readout time if true.

    setStreamUseCase

    Added in API level 33
    fun setStreamUseCase(streamUseCase: Long): Unit

    Set stream use case for this OutputConfiguration

    Stream use case is used to describe the purpose of the stream, whether it's for live preview, still image capture, video recording, or their combinations. This flag is useful for scenarios where the immediate consumer target isn't sufficient to indicate the stream's usage.

    The main difference between stream use case and capture intent is that the former enables the camera device to optimize camera hardware and software pipelines based on user scenarios for each stream, whereas the latter is mainly a hint to camera to decide optimal 3A strategy that's applicable to the whole session. The camera device carries out configurations such as selecting tuning parameters, choosing camera sensor mode, and constructing image processing pipeline based on the streams's use cases. Capture intents are then used to fine tune 3A behaviors such as adjusting AE/AF convergence speed, and capture intents may change during the lifetime of a session. For example, for a session with a PREVIEW_VIDEO_STILL use case stream and a STILL_CAPTURE use case stream, the capture intents may be PREVIEW with fast 3A convergence speed and flash metering with automatic control for live preview, STILL_CAPTURE with best 3A parameters for still photo capture, or VIDEO_RECORD with slower 3A convergence speed for better video playback experience.

    The supported stream use cases supported by a camera device can be queried by android.hardware.camera2.CameraCharacteristics#SCALER_AVAILABLE_STREAM_USE_CASES.

    The mandatory stream combinations involving stream use cases can be found at android.hardware.camera2.CameraDevice#createCaptureSession, as well as queried via android.hardware.camera2.params.MandatoryStreamCombination. The application is strongly recommended to select one of the guaranteed stream combinations where all streams' use cases are set to non-DEFAULT values. If the application chooses a stream combination not in the mandatory list, the camera device may ignore some use case flags due to hardware constraints or implementation details.

    This function must be called before android.hardware.camera2.CameraDevice#createCaptureSession or android.hardware.camera2.CameraDevice#createCaptureSessionByOutputConfigurations. Calling this function after android.hardware.camera2.CameraDevice#createCaptureSession or CameraDevice#createCaptureSessionByOutputConfigurations has no effect to the camera session.

    Parameters
    streamUseCase Long: The stream use case to be set. Value is android.hardware.camera2.CameraMetadata#SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT, android.hardware.camera2.CameraMetadata#SCALER_AVAILABLE_STREAM_USE_CASES_PREVIEW, android.hardware.camera2.CameraMetadata#SCALER_AVAILABLE_STREAM_USE_CASES_STILL_CAPTURE, android.hardware.camera2.CameraMetadata#SCALER_AVAILABLE_STREAM_USE_CASES_VIDEO_RECORD, android.hardware.camera2.CameraMetadata#SCALER_AVAILABLE_STREAM_USE_CASES_PREVIEW_VIDEO_STILL, android.hardware.camera2.CameraMetadata#SCALER_AVAILABLE_STREAM_USE_CASES_VIDEO_CALL, or android.hardware.camera2.CameraMetadata#SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW
    Exceptions
    java.lang.IllegalArgumentException If the streamUseCase isn't within the range of valid values.

    setTimestampBase

    Added in API level 33
    fun setTimestampBase(timestampBase: Int): Unit

    Set timestamp base for this output target

    Timestamp base describes the time domain of images from this camera output and its relationship with android.hardware.camera2.CameraCharacteristics#SENSOR_INFO_TIMESTAMP_SOURCE.

    If this function is not called, the timestamp base for this output is TIMESTAMP_BASE_DEFAULT, with which the camera device adjusts timestamps based on the output target.

    See TIMESTAMP_BASE_DEFAULT, TIMESTAMP_BASE_SENSOR, and TIMESTAMP_BASE_CHOREOGRAPHER_SYNCED for details of each timestamp base.

    Parameters
    timestampBase Int: The timestamp base to be set. Value is android.hardware.camera2.params.OutputConfiguration#TIMESTAMP_BASE_DEFAULT, android.hardware.camera2.params.OutputConfiguration#TIMESTAMP_BASE_SENSOR, android.hardware.camera2.params.OutputConfiguration#TIMESTAMP_BASE_MONOTONIC, android.hardware.camera2.params.OutputConfiguration#TIMESTAMP_BASE_REALTIME, android.hardware.camera2.params.OutputConfiguration#TIMESTAMP_BASE_CHOREOGRAPHER_SYNCED, or android.hardware.camera2.params.OutputConfiguration.TIMESTAMP_BASE_READOUT_SENSOR
    Exceptions
    java.lang.IllegalArgumentException If the timestamp base isn't within the range of valid values.

    writeToParcel

    Added in API level 24
    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 24
    static val CREATOR: Parcelable.Creator<OutputConfiguration!>