OutputConfiguration  |  API reference  |  Android Developers


public final class OutputConfiguration
extends Object implements Parcelable



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.

See also:

Summary

Constants

int MIRROR_MODE_AUTO

Automatic mirroring based on camera facing

This is the default mirroring mode for the camera device.

int MIRROR_MODE_H

Camera output is mirrored horizontally

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

int MIRROR_MODE_NONE

No mirror transform is applied

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

int MIRROR_MODE_V

Camera output is mirrored vertically

int SURFACE_GROUP_ID_NONE

Invalid surface group ID.

int TIMESTAMP_BASE_CHOREOGRAPHER_SYNCED

Timestamp is synchronized to choreographer.

int TIMESTAMP_BASE_DEFAULT

Default timestamp base.

int TIMESTAMP_BASE_MONOTONIC

Timestamp base roughly the same as SystemClock.uptimeMillis().

int TIMESTAMP_BASE_REALTIME

Timestamp base roughly the same as SystemClock.elapsedRealtime().

int TIMESTAMP_BASE_SENSOR

Timestamp base of CameraCharacteristics.SENSOR_INFO_TIMESTAMP_SOURCE.

Inherited constants

From interface android.os.Parcelable

int CONTENTS_FILE_DESCRIPTOR

Descriptor bit used with describeContents(): indicates that the Parcelable object's flattened representation includes a file descriptor.

int PARCELABLE_WRITE_RETURN_VALUE

Flag for use with writeToParcel(Parcel, int): the object being written is a return value, that is the result of a function such as "Parcelable someFunction()", "void someFunction(out Parcelable)", or "void someFunction(inout Parcelable)".

Fields

public static final Creator<OutputConfiguration> CREATOR

Public constructors

OutputConfiguration(Size surfaceSize, Class<T> klass)

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

OutputConfiguration(Surface surface)

Create a new OutputConfiguration instance with a Surface.

OutputConfiguration(int format, Size surfaceSize)

Create a new OutputConfiguration instance for an ImageReader for a given format and size.

OutputConfiguration(int format, Size surfaceSize, long usage)

Create a new OutputConfiguration instance for an ImageReader for a given format, size, and usage flags.

OutputConfiguration(int surfaceGroupId, Surface surface)

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

OutputConfiguration(int surfaceGroupId, int format, Size surfaceSize)

Create a new OutputConfiguration instance for an ImageReader for a given surfaceGroupId, format, and size.

OutputConfiguration(int surfaceGroupId, int format, Size surfaceSize, long usage)

Create a new OutputConfiguration instance for an ImageReader for a given surface group id, format, size, and usage flags.

Public methods

void addSensorPixelModeUsed(int sensorPixelModeUsed)

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

void addSurface(Surface surface)

Add a surface to this OutputConfiguration.

static List<OutputConfiguration> createInstancesForMultiResolutionOutput(Collection<MultiResolutionStreamInfo> streams, int format)

Create a list of OutputConfiguration instances for a MultiResolutionImageReader.

static Collection<OutputConfiguration> createInstancesForMultiResolutionOutput(MultiResolutionImageReader multiResolutionImageReader)

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

int describeContents()

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

void enableSurfaceSharing()

Enable multiple surfaces sharing the same OutputConfiguration

For advanced use cases, a camera application may require more streams than the combination guaranteed by CameraDevice.createCaptureSession.

boolean equals(Object obj)

Check if this OutputConfiguration is equal to another OutputConfiguration.

int getConfiguredFormat()

Get the configured format associated with this OutputConfiguration.

Size getConfiguredSize()

Get the latest configured size associated with this OutputConfiguration.

long getDynamicRangeProfile()

Return current dynamic range profile.

int getMaxSharedSurfaceCount()

Get the maximum supported shared Surface count.

int getMirrorMode()

Get the current mirroring mode

If no setMirrorMode(Surface, int) is called first, this function returns MIRROR_MODE_AUTO.

int getMirrorMode(Surface surface)

Get the current mirroring mode for an output surface

If no setMirrorMode(Surface, int) is called first, this function returns MIRROR_MODE_AUTO.

long getStreamUseCase()

Get the current stream use case

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

Surface getSurface()

Get the Surface associated with this OutputConfiguration.

int getSurfaceGroupId()

Get the surface group ID associated with this OutputConfiguration.

List<Surface> getSurfaces()

Get the immutable list of surfaces associated with this OutputConfiguration.

int getTimestampBase()

Get the current timestamp base

If no setTimestampBase(int) is called first, this function returns TIMESTAMP_BASE_DEFAULT.

int hashCode()

Returns a hash code value for the object.

boolean isReadoutTimestampEnabled()

Whether readout timestamp is used for this OutputConfiguration.

OutputConfiguration makeDeferredAndRemoveSurfaces()

Clear any valid output surfaces and mark the configuration as deferred.

void removeSensorPixelModeUsed(int sensorPixelModeUsed)

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

void removeSurface(Surface surface)

Remove a surface from this OutputConfiguration.

void setDynamicRangeProfile(long profile)

Set a specific device supported dynamic range profile.

void setMirrorMode(int mirrorMode)

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.

void setMirrorMode(Surface surface, int mirrorMode)

Set the mirroring mode for a surface belonging to this OutputConfiguration

This function is identical to setMirrorMode(int) if surface is the only surface belonging to this OutputConfiguration.

void setPhysicalCameraId(String physicalCameraId)

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.

void setReadoutTimestampEnabled(boolean on)

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

void setStreamUseCase(long streamUseCase)

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.

static void setSurfacesForMultiResolutionOutput(Collection<OutputConfiguration> outputConfigurations, MultiResolutionImageReader multiResolutionImageReader)

Set the OutputConfiguration surfaces corresponding to the MultiResolutionImageReader.

void setTimestampBase(int timestampBase)

Set timestamp base for this output target

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

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

From interface android.os.Parcelable

abstract int describeContents()

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

abstract void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Constants

MIRROR_MODE_AUTO

public static final int MIRROR_MODE_AUTO

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.

Constant Value: 0 (0x00000000)

MIRROR_MODE_H

public static final int MIRROR_MODE_H

Camera output is mirrored horizontally

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

Constant Value: 2 (0x00000002)

MIRROR_MODE_NONE

public static final int MIRROR_MODE_NONE

No mirror transform is applied

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

Constant Value: 1 (0x00000001)

MIRROR_MODE_V

public static final int MIRROR_MODE_V

Camera output is mirrored vertically

Constant Value: 3 (0x00000003)

SURFACE_GROUP_ID_NONE

public static final int SURFACE_GROUP_ID_NONE

Invalid surface group ID.

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

Constant Value: -1 (0xffffffff)

TIMESTAMP_BASE_CHOREOGRAPHER_SYNCED

public static final int TIMESTAMP_BASE_CHOREOGRAPHER_SYNCED

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, CameraCaptureSession.CaptureCallback.onReadoutStarted, or the sensor timestamps in CaptureResult. This timestamp base shouldn't be used if the timestamp needs to be used for audio-video synchronization.

Constant Value: 4 (0x00000004)

TIMESTAMP_BASE_DEFAULT

public static final int TIMESTAMP_BASE_DEFAULT

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 SystemClock.uptimeMillis().
  • For an output surface of MediaRecorder, MediaCodec, or ImageReader with HardwareBuffer.USAGE_VIDEO_ENCODE usage flag, the timestamp base is TIMESTAMP_BASE_MONOTONIC, which is roughly the same time base as 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.

    Constant Value: 0 (0x00000000)

    Fields

    Public constructors

    OutputConfiguration

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

    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.

    Starting from Android V, the deferred Surface can be obtained: (1) from SurfaceView by calling SurfaceHolder.getSurface(), (2) from SurfaceTexture via Surface.Surface(android.graphics.SurfaceTexture), (3) from MediaRecorder via MediaRecorder.getSurface() or MediaCodec.createPersistentInputSurface(), or (4) from MediaCodec via MediaCodec.createInputSurface() or MediaCodec.createPersistentInputSurface().

    Starting from Android C, the ImageReader deferred Surface can be obtained from ImageReader.getSurface(). Do note that you should use OutputConfiguration.OutputConfiguration(int,int,Size,long) to instantiate a deferred ImageReader output configuration or by calling makeDeferredAndRemoveSurfaces() on an output configuration that has a non-deferred ImageReader surface.

    Before Android V, only SurfaceView and SurfaceTexture are supported. Both kind of outputs can be deferred until after CameraDevice.createCaptureSessionByOutputConfigurations.

    An OutputConfiguration object created by this constructor can be used for CameraDevice.CameraDeviceSetup.isSessionConfigurationSupported(SessionConfiguration) and CameraDevice.CameraDeviceSetup.getSessionCharacteristics(SessionConfiguration) without having called addSurface(Surface).

    Parameters
    surfaceSize Size: Size for the deferred surface.
    This value cannot be null.
    klass Class: a non-null Class object reference that indicates the source of this surface. Only SurfaceHolder.class, SurfaceTexture.class, MediaRecorder.class, and MediaCodec.class are supported. Before Android V, only SurfaceHolder.class and SurfaceTexture.class are supported.
    Throws
    IllegalArgumentException if the Surface source class is not supported, or Surface size is zero.

    OutputConfiguration

    public 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 .SURFACE_GROUP_ID_NONE.

    .
    This value cannot be null.

    OutputConfiguration

    public OutputConfiguration (int surfaceGroupId, 
                    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 .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.

    Public methods

    addSensorPixelModeUsed

    public void addSensorPixelModeUsed (int sensorPixelModeUsed)

    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 CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP configurations and CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP_MAXIMUM_RESOLUTION, configurations, the camera sub-system will assume that this OutputConfiguration will be used only with CaptureRequests which has CaptureRequest.SENSOR_PIXEL_MODE set to CameraMetadata.SENSOR_PIXEL_MODE_DEFAULT. In such cases, if clients intend to use the OutputConfiguration(s) in a CaptureRequest with other sensor pixel modes, they must specify which 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 CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP_MAXIMUM_RESOLUTION, configurations, this output target must only be used with CaptureRequests which has CaptureRequest.SENSOR_PIXEL_MODE set to CameraMetadata.SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION and that is what the camera sub-system will assume. If clients add 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 CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP, configurations, this output target must only be used with CaptureRequests which has CaptureRequest.SENSOR_PIXEL_MODE set to CameraMetadata.SENSOR_PIXEL_MODE_DEFAULT and that is what the camera sub-system will assume. If clients add 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 one of the following:

    addSurface

    public void addSurface (Surface surface)

    Add a surface to this OutputConfiguration.

    This function can be called before or after 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 this function is called before session creation, CameraCaptureSession.finalizeOutputConfigurations doesn't need to be called.

    If the OutputConfiguration was constructed by OutputConfiguration.OutputConfiguration(Size,Class), the added surface must be obtained:

    If the OutputConfiguration was constructed by OutputConfiguration(int,Size) or its variants, the added surface must be obtained from ImageReader by calling ImageReader.getSurface().

    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.
    Throws
    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.
    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.

    describeContents

    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(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

    enableSurfaceSharing

    public void enableSurfaceSharing ()

    Enable multiple surfaces sharing the same OutputConfiguration

    For advanced use cases, a camera application may require more streams than the combination guaranteed by 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 CameraCaptureSession.StateCallback.onConfigureFailed.

    To enable surface sharing, this function must be called before CameraDevice.createCaptureSessionByOutputConfigurations or 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(MultiResolutionImageReader).

    Throws
    IllegalStateException If this OutputConfiguration is created via createInstancesForMultiResolutionOutput(MultiResolutionImageReader) to back a MultiResolutionImageReader.
  • equals

    public boolean equals (Object obj)

    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 Object: This value may be null.
    Returns
    boolean true if the objects were equal, false otherwise

    getMaxSharedSurfaceCount

    public int getMaxSharedSurfaceCount ()

    Get the maximum supported shared Surface count.

    Returns
    int the maximum number of surfaces that can be added per each OutputConfiguration.

    getStreamUseCase

    public long getStreamUseCase ()

    Get the current stream use case

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

    Returns
    long the currently set stream use case

    hashCode

    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.

    isReadoutTimestampEnabled

    public boolean isReadoutTimestampEnabled ()

    Whether readout timestamp is used for this OutputConfiguration.

    Returns
    boolean

    removeSurface

    public void removeSurface (Surface surface)

    Remove a surface from this OutputConfiguration.

    Surfaces added via calls to addSurface(Surface) 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 case of OutputConfiguration.OutputConfiguration(Size,Class), OutputConfiguration.OutputConfiguration(int,Size), OutputConfiguration.OutputConfiguration(int,Size,long), OutputConfiguration.OutputConfiguration(int,int,Size), OutputConfiguration.OutputConfiguration(int,int,Size,long).

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

    setMirrorMode

    public void setMirrorMode (int mirrorMode)

    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 SurfaceTexture.getTransformMatrix(float). 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.

    Starting from Android 16, this function sets the mirror modes for all of the output surfaces contained within this OutputConfiguration. To set the mirror mode for a particular output surface, the application can call setMirrorMode(Surface,int). Prior to Android 16, this function is only applicable if surface sharing is not enabled.

    Parameters
    mirrorMode int: Value is one of the following:

    setMirrorMode

    public void setMirrorMode (Surface surface, 
                    int mirrorMode)

    Set the mirroring mode for a surface belonging to this OutputConfiguration

    This function is identical to setMirrorMode(int) if surface is the only surface belonging to this OutputConfiguration.

    If this OutputConfiguration contains a deferred surface, the application can either call setMirrorMode(int), or call this function after calling addSurface(Surface).

    If this OutputConfiguration contains shared surfaces, the application can set different mirroring modes for different surfaces.

    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 SurfaceTexture.getTransformMatrix(float). 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
    surface Surface: This value cannot be null.
    mirrorMode int: Value is one of the following:
    Throws
    IllegalArgumentException If the surface doesn't belong to this OutputConfiguration, or the mirrorMode value is not valid.

    setReadoutTimestampEnabled

    public void setReadoutTimestampEnabled (boolean on)

    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 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

    public void setStreamUseCase (long streamUseCase)

    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 CameraCharacteristics.SCALER_AVAILABLE_STREAM_USE_CASES.

    The mandatory stream combinations involving stream use cases can be found at CameraDevice.createCaptureSession(SessionConfiguration), as well as queried via 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 CameraDevice.createCaptureSession or CameraDevice.createCaptureSessionByOutputConfigurations. Calling this function after CameraDevice.createCaptureSession or CameraDevice.createCaptureSessionByOutputConfigurations has no effect to the camera session.

    Parameters
    streamUseCase long: The stream use case to be set.
    Value is one of the following:
    Throws
    IllegalArgumentException If the streamUseCase isn't within the range of valid values.