Home | History | Annotate | Download | only in camera2
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.hardware.camera2;
     18 
     19 import android.annotation.NonNull;
     20 import android.annotation.Nullable;
     21 import android.annotation.IntDef;
     22 import android.annotation.SystemApi;
     23 import android.annotation.TestApi;
     24 import static android.hardware.camera2.ICameraDeviceUser.NORMAL_MODE;
     25 import static android.hardware.camera2.ICameraDeviceUser.CONSTRAINED_HIGH_SPEED_MODE;
     26 import android.hardware.camera2.params.InputConfiguration;
     27 import android.hardware.camera2.params.StreamConfigurationMap;
     28 import android.hardware.camera2.params.OutputConfiguration;
     29 import android.os.Handler;
     30 import android.view.Surface;
     31 
     32 import java.util.List;
     33 import java.lang.annotation.Retention;
     34 import java.lang.annotation.RetentionPolicy;
     35 
     36 /**
     37  * <p>The CameraDevice class is a representation of a single camera connected to an
     38  * Android device, allowing for fine-grain control of image capture and
     39  * post-processing at high frame rates.</p>
     40  *
     41  * <p>Your application must declare the
     42  * {@link android.Manifest.permission#CAMERA Camera} permission in its manifest
     43  * in order to access camera devices.</p>
     44  *
     45  * <p>A given camera device may provide support at one of two levels: limited or
     46  * full. If a device only supports the limited level, then Camera2 exposes a
     47  * feature set that is roughly equivalent to the older
     48  * {@link android.hardware.Camera Camera} API, although with a cleaner and more
     49  * efficient interface.  Devices that implement the full level of support
     50  * provide substantially improved capabilities over the older camera
     51  * API. Applications that target the limited level devices will run unchanged on
     52  * the full-level devices; if your application requires a full-level device for
     53  * proper operation, declare the "android.hardware.camera.level.full" feature in your
     54  * manifest.</p>
     55  *
     56  * @see CameraManager#openCamera
     57  * @see android.Manifest.permission#CAMERA
     58  */
     59 public abstract class CameraDevice implements AutoCloseable {
     60 
     61     /**
     62      * Create a request suitable for a camera preview window. Specifically, this
     63      * means that high frame rate is given priority over the highest-quality
     64      * post-processing. These requests would normally be used with the
     65      * {@link CameraCaptureSession#setRepeatingRequest} method.
     66      * This template is guaranteed to be supported on all camera devices.
     67      *
     68      * @see #createCaptureRequest
     69      */
     70     public static final int TEMPLATE_PREVIEW = 1;
     71 
     72     /**
     73      * Create a request suitable for still image capture. Specifically, this
     74      * means prioritizing image quality over frame rate. These requests would
     75      * commonly be used with the {@link CameraCaptureSession#capture} method.
     76      * This template is guaranteed to be supported on all camera devices except
     77      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT DEPTH_OUTPUT} devices
     78      * that are not {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE
     79      * BACKWARD_COMPATIBLE}.
     80      * @see #createCaptureRequest
     81      */
     82     public static final int TEMPLATE_STILL_CAPTURE = 2;
     83 
     84     /**
     85      * Create a request suitable for video recording. Specifically, this means
     86      * that a stable frame rate is used, and post-processing is set for
     87      * recording quality. These requests would commonly be used with the
     88      * {@link CameraCaptureSession#setRepeatingRequest} method.
     89      * This template is guaranteed to be supported on all camera devices except
     90      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT DEPTH_OUTPUT} devices
     91      * that are not {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE
     92      * BACKWARD_COMPATIBLE}.
     93      *
     94      * @see #createCaptureRequest
     95      */
     96     public static final int TEMPLATE_RECORD  = 3;
     97 
     98     /**
     99      * Create a request suitable for still image capture while recording
    100      * video. Specifically, this means maximizing image quality without
    101      * disrupting the ongoing recording. These requests would commonly be used
    102      * with the {@link CameraCaptureSession#capture} method while a request based on
    103      * {@link #TEMPLATE_RECORD} is is in use with {@link CameraCaptureSession#setRepeatingRequest}.
    104      * This template is guaranteed to be supported on all camera devices except
    105      * legacy devices ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
    106      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY}) and
    107      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT DEPTH_OUTPUT} devices
    108      * that are not {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE
    109      * BACKWARD_COMPATIBLE}.
    110      *
    111      * @see #createCaptureRequest
    112      */
    113     public static final int TEMPLATE_VIDEO_SNAPSHOT = 4;
    114 
    115     /**
    116      * Create a request suitable for zero shutter lag still capture. This means
    117      * means maximizing image quality without compromising preview frame rate.
    118      * AE/AWB/AF should be on auto mode. This is intended for application-operated ZSL. For
    119      * device-operated ZSL, use {@link CaptureRequest#CONTROL_ENABLE_ZSL} if available.
    120      * This template is guaranteed to be supported on camera devices that support the
    121      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING PRIVATE_REPROCESSING}
    122      * capability or the
    123      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING YUV_REPROCESSING}
    124      * capability.
    125      *
    126      * @see #createCaptureRequest
    127      * @see CaptureRequest#CONTROL_ENABLE_ZSL
    128      */
    129     public static final int TEMPLATE_ZERO_SHUTTER_LAG = 5;
    130 
    131     /**
    132      * A basic template for direct application control of capture
    133      * parameters. All automatic control is disabled (auto-exposure, auto-white
    134      * balance, auto-focus), and post-processing parameters are set to preview
    135      * quality. The manual capture parameters (exposure, sensitivity, and so on)
    136      * are set to reasonable defaults, but should be overriden by the
    137      * application depending on the intended use case.
    138      * This template is guaranteed to be supported on camera devices that support the
    139      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR MANUAL_SENSOR}
    140      * capability.
    141      *
    142      * @see #createCaptureRequest
    143      */
    144     public static final int TEMPLATE_MANUAL = 6;
    145 
    146      /** @hide */
    147      @Retention(RetentionPolicy.SOURCE)
    148      @IntDef(prefix = {"TEMPLATE_"}, value =
    149          {TEMPLATE_PREVIEW,
    150           TEMPLATE_STILL_CAPTURE,
    151           TEMPLATE_RECORD,
    152           TEMPLATE_VIDEO_SNAPSHOT,
    153           TEMPLATE_ZERO_SHUTTER_LAG,
    154           TEMPLATE_MANUAL })
    155      public @interface RequestTemplate {};
    156 
    157     /**
    158      * Get the ID of this camera device.
    159      *
    160      * <p>This matches the ID given to {@link CameraManager#openCamera} to instantiate this
    161      * this camera device.</p>
    162      *
    163      * <p>This ID can be used to query the camera device's {@link
    164      * CameraCharacteristics fixed properties} with {@link
    165      * CameraManager#getCameraCharacteristics}.</p>
    166      *
    167      * <p>This method can be called even if the device has been closed or has encountered
    168      * a serious error.</p>
    169      *
    170      * @return the ID for this camera device
    171      *
    172      * @see CameraManager#getCameraCharacteristics
    173      * @see CameraManager#getCameraIdList
    174      */
    175     @NonNull
    176     public abstract String getId();
    177 
    178     /**
    179      * <p>Create a new camera capture session by providing the target output set of Surfaces to the
    180      * camera device.</p>
    181      *
    182      * <p>The active capture session determines the set of potential output Surfaces for
    183      * the camera device for each capture request. A given request may use all
    184      * or only some of the outputs. Once the CameraCaptureSession is created, requests can be
    185      * submitted with {@link CameraCaptureSession#capture capture},
    186      * {@link CameraCaptureSession#captureBurst captureBurst},
    187      * {@link CameraCaptureSession#setRepeatingRequest setRepeatingRequest}, or
    188      * {@link CameraCaptureSession#setRepeatingBurst setRepeatingBurst}.</p>
    189      *
    190      * <p>Surfaces suitable for inclusion as a camera output can be created for
    191      * various use cases and targets:</p>
    192      *
    193      * <ul>
    194      *
    195      * <li>For drawing to a {@link android.view.SurfaceView SurfaceView}: Once the SurfaceView's
    196      *   Surface is {@link android.view.SurfaceHolder.Callback#surfaceCreated created}, set the size
    197      *   of the Surface with {@link android.view.SurfaceHolder#setFixedSize} to be one of the sizes
    198      *   returned by {@link StreamConfigurationMap#getOutputSizes(Class)
    199      *   getOutputSizes(SurfaceHolder.class)} and then obtain the Surface by calling {@link
    200      *   android.view.SurfaceHolder#getSurface}. If the size is not set by the application, it will
    201      *   be rounded to the nearest supported size less than 1080p, by the camera device.</li>
    202      *
    203      * <li>For accessing through an OpenGL texture via a {@link android.graphics.SurfaceTexture
    204      *   SurfaceTexture}: Set the size of the SurfaceTexture with {@link
    205      *   android.graphics.SurfaceTexture#setDefaultBufferSize} to be one of the sizes returned by
    206      *   {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(SurfaceTexture.class)}
    207      *   before creating a Surface from the SurfaceTexture with {@link Surface#Surface}. If the size
    208      *   is not set by the application, it will be set to be the smallest supported size less than
    209      *   1080p, by the camera device.</li>
    210      *
    211      * <li>For recording with {@link android.media.MediaCodec}: Call
    212      *   {@link android.media.MediaCodec#createInputSurface} after configuring
    213      *   the media codec to use one of the sizes returned by
    214      *   {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(MediaCodec.class)}
    215      *   </li>
    216      *
    217      * <li>For recording with {@link android.media.MediaRecorder}: Call
    218      *   {@link android.media.MediaRecorder#getSurface} after configuring the media recorder to use
    219      *   one of the sizes returned by
    220      *   {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(MediaRecorder.class)},
    221      *   or configuring it to use one of the supported
    222      *   {@link android.media.CamcorderProfile CamcorderProfiles}.</li>
    223      *
    224      * <li>For efficient YUV processing with {@link android.renderscript}:
    225      *   Create a RenderScript
    226      *   {@link android.renderscript.Allocation Allocation} with a supported YUV
    227      *   type, the IO_INPUT flag, and one of the sizes returned by
    228      *   {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(Allocation.class)},
    229      *   Then obtain the Surface with
    230      *   {@link android.renderscript.Allocation#getSurface}.</li>
    231      *
    232      * <li>For access to RAW, uncompressed YUV, or compressed JPEG data in the application: Create an
    233      *   {@link android.media.ImageReader} object with one of the supported output formats given by
    234      *   {@link StreamConfigurationMap#getOutputFormats()}, setting its size to one of the
    235      *   corresponding supported sizes by passing the chosen output format into
    236      *   {@link StreamConfigurationMap#getOutputSizes(int)}. Then obtain a
    237      *   {@link android.view.Surface} from it with {@link android.media.ImageReader#getSurface()}.
    238      *   If the ImageReader size is not set to a supported size, it will be rounded to a supported
    239      *   size less than 1080p by the camera device.
    240      *   </li>
    241      *
    242      * </ul>
    243      *
    244      * <p>The camera device will query each Surface's size and formats upon this
    245      * call, so they must be set to a valid setting at this time.</p>
    246      *
    247      * <p>It can take several hundred milliseconds for the session's configuration to complete,
    248      * since camera hardware may need to be powered on or reconfigured. Once the configuration is
    249      * complete and the session is ready to actually capture data, the provided
    250      * {@link CameraCaptureSession.StateCallback}'s
    251      * {@link CameraCaptureSession.StateCallback#onConfigured} callback will be called.</p>
    252      *
    253      * <p>If a prior CameraCaptureSession already exists when this method is called, the previous
    254      * session will no longer be able to accept new capture requests and will be closed. Any
    255      * in-progress capture requests made on the prior session will be completed before it's closed.
    256      * {@link CameraCaptureSession.StateCallback#onConfigured} for the new session may be invoked
    257      * before {@link CameraCaptureSession.StateCallback#onClosed} is invoked for the prior
    258      * session. Once the new session is {@link CameraCaptureSession.StateCallback#onConfigured
    259      * configured}, it is able to start capturing its own requests. To minimize the transition time,
    260      * the {@link CameraCaptureSession#abortCaptures} call can be used to discard the remaining
    261      * requests for the prior capture session before a new one is created. Note that once the new
    262      * session is created, the old one can no longer have its captures aborted.</p>
    263      *
    264      * <p>Using larger resolution outputs, or more outputs, can result in slower
    265      * output rate from the device.</p>
    266      *
    267      * <p>Configuring a session with an empty or null list will close the current session, if
    268      * any. This can be used to release the current session's target surfaces for another use.</p>
    269      *
    270      * <p>While any of the sizes from {@link StreamConfigurationMap#getOutputSizes} can be used when
    271      * a single output stream is configured, a given camera device may not be able to support all
    272      * combination of sizes, formats, and targets when multiple outputs are configured at once.  The
    273      * tables below list the maximum guaranteed resolutions for combinations of streams and targets,
    274      * given the capabilities of the camera device.</p>
    275      *
    276      * <p>If an application tries to create a session using a set of targets that exceed the limits
    277      * described in the below tables, one of three possibilities may occur. First, the session may
    278      * be successfully created and work normally. Second, the session may be successfully created,
    279      * but the camera device won't meet the frame rate guarantees as described in
    280      * {@link StreamConfigurationMap#getOutputMinFrameDuration}. Or third, if the output set
    281      * cannot be used at all, session creation will fail entirely, with
    282      * {@link CameraCaptureSession.StateCallback#onConfigureFailed} being invoked.</p>
    283      *
    284      * <p>For the type column, {@code PRIV} refers to any target whose available sizes are found
    285      * using {@link StreamConfigurationMap#getOutputSizes(Class)} with no direct application-visible
    286      * format, {@code YUV} refers to a target Surface using the
    287      * {@link android.graphics.ImageFormat#YUV_420_888} format, {@code JPEG} refers to the
    288      * {@link android.graphics.ImageFormat#JPEG} format, and {@code RAW} refers to the
    289      * {@link android.graphics.ImageFormat#RAW_SENSOR} format.</p>
    290      *
    291      * <p>For the maximum size column, {@code PREVIEW} refers to the best size match to the
    292      * device's screen resolution, or to 1080p ({@code 1920x1080}), whichever is
    293      * smaller. {@code RECORD} refers to the camera device's maximum supported recording resolution,
    294      * as determined by {@link android.media.CamcorderProfile}. And {@code MAXIMUM} refers to the
    295      * camera device's maximum output resolution for that format or target from
    296      * {@link StreamConfigurationMap#getOutputSizes}.</p>
    297      *
    298      * <p>To use these tables, determine the number and the formats/targets of outputs needed, and
    299      * find the row(s) of the table with those targets. The sizes indicate the maximum set of sizes
    300      * that can be used; it is guaranteed that for those targets, the listed sizes and anything
    301      * smaller from the list given by {@link StreamConfigurationMap#getOutputSizes} can be
    302      * successfully used to create a session.  For example, if a row indicates that a 8 megapixel
    303      * (MP) YUV_420_888 output can be used together with a 2 MP {@code PRIV} output, then a session
    304      * can be created with targets {@code [8 MP YUV, 2 MP PRIV]} or targets {@code [2 MP YUV, 2 MP
    305      * PRIV]}; but a session with targets {@code [8 MP YUV, 4 MP PRIV]}, targets {@code [4 MP YUV, 4
    306      * MP PRIV]}, or targets {@code [8 MP PRIV, 2 MP YUV]} would not be guaranteed to work, unless
    307      * some other row of the table lists such a combination.</p>
    308      *
    309      * <style scoped>
    310      *  #rb { border-right-width: thick; }
    311      * </style>
    312      * <p>Legacy devices ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
    313      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY}) support at
    314      * least the following stream combinations:
    315      *
    316      * <table>
    317      * <tr><th colspan="7">LEGACY-level guaranteed configurations</th></tr>
    318      * <tr> <th colspan="2" id="rb">Target 1</th> <th colspan="2" id="rb">Target 2</th>  <th colspan="2" id="rb">Target 3</th> <th rowspan="2">Sample use case(s)</th> </tr>
    319      * <tr> <th>Type</th><th id="rb">Max size</th> <th>Type</th><th id="rb">Max size</th> <th>Type</th><th id="rb">Max size</th></tr>
    320      * <tr> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td colspan="2" id="rb"></td> <td>Simple preview, GPU video processing, or no-preview video recording.</td> </tr>
    321      * <tr> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td colspan="2" id="rb"></td> <td>No-viewfinder still image capture.</td> </tr>
    322      * <tr> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td colspan="2" id="rb"></td> <td>In-application video/image processing.</td> </tr>
    323      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>Standard still imaging.</td> </tr>
    324      * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>In-app processing plus still capture.</td> </tr>
    325      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td colspan="2" id="rb"></td> <td>Standard recording.</td> </tr>
    326      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td colspan="2" id="rb"></td> <td>Preview plus in-app processing.</td> </tr>
    327      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>Still capture plus in-app processing.</td> </tr>
    328      * </table><br>
    329      * </p>
    330      *
    331      * <p>Limited-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
    332      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED}) devices
    333      * support at least the following stream combinations in addition to those for
    334      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY} devices:
    335      *
    336      * <table>
    337      * <tr><th colspan="7">LIMITED-level additional guaranteed configurations</th></tr>
    338      * <tr><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th> <th rowspan="2">Sample use case(s)</th> </tr>
    339      * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th></tr>
    340      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code RECORD }</td> <td colspan="2" id="rb"></td> <td>High-resolution video recording with preview.</td> </tr>
    341      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code RECORD }</td> <td colspan="2" id="rb"></td> <td>High-resolution in-app video processing with preview.</td> </tr>
    342      * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code RECORD }</td> <td colspan="2" id="rb"></td> <td>Two-input in-app video processing.</td> </tr>
    343      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code RECORD }</td> <td>{@code JPEG}</td><td id="rb">{@code RECORD }</td> <td>High-resolution recording with video snapshot.</td> </tr>
    344      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code RECORD }</td> <td>{@code JPEG}</td><td id="rb">{@code RECORD }</td> <td>High-resolution in-app processing with video snapshot.</td> </tr>
    345      * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>Two-input in-app processing with still capture.</td> </tr>
    346      * </table><br>
    347      * </p>
    348      *
    349      * <p>FULL-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
    350      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) devices
    351      * support at least the following stream combinations in addition to those for
    352      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
    353      *
    354      * <table>
    355      * <tr><th colspan="7">FULL-level additional guaranteed configurations</th></tr>
    356      * <tr><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th> <th rowspan="2">Sample use case(s)</th> </tr>
    357      * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th> </tr>
    358      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>Maximum-resolution GPU processing with preview.</td> </tr>
    359      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>Maximum-resolution in-app processing with preview.</td> </tr>
    360      * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>Maximum-resolution two-input in-app processsing.</td> </tr>
    361      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>Video recording with maximum-size video snapshot</td> </tr>
    362      * <tr> <td>{@code YUV }</td><td id="rb">{@code 640x480}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td>Standard video recording plus maximum-resolution in-app processing.</td> </tr>
    363      * <tr> <td>{@code YUV }</td><td id="rb">{@code 640x480}</td> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td>Preview plus two-input maximum-resolution in-app processing.</td> </tr>
    364      * </table><br>
    365      * </p>
    366      *
    367      * <p>RAW-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
    368      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}) devices additionally support
    369      * at least the following stream combinations on both
    370      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} and
    371      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
    372      *
    373      * <table>
    374      * <tr><th colspan="7">RAW-capability additional guaranteed configurations</th></tr>
    375      * <tr><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th> <th rowspan="2">Sample use case(s)</th> </tr>
    376      * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th> </tr>
    377      * <tr> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td colspan="2" id="rb"></td> <td>No-preview DNG capture.</td> </tr>
    378      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>Standard DNG capture.</td> </tr>
    379      * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>In-app processing plus DNG capture.</td> </tr>
    380      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td>Video recording with DNG capture.</td> </tr>
    381      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td>Preview with in-app processing and DNG capture.</td> </tr>
    382      * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td>Two-input in-app processing plus DNG capture.</td> </tr>
    383      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td>Still capture with simultaneous JPEG and DNG.</td> </tr>
    384      * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td>In-app processing with simultaneous JPEG and DNG.</td> </tr>
    385      * </table><br>
    386      * </p>
    387      *
    388      * <p>BURST-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
    389      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE BURST_CAPTURE}) devices
    390      * support at least the below stream combinations in addition to those for
    391      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices. Note that all
    392      * FULL-level devices support the BURST capability, and the below list is a strict subset of the
    393      * list for FULL-level devices, so this table is only relevant for LIMITED-level devices that
    394      * support the BURST_CAPTURE capability.
    395      *
    396      * <table>
    397      * <tr><th colspan="5">BURST-capability additional guaranteed configurations</th></tr>
    398      * <tr><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th rowspan="2">Sample use case(s)</th> </tr>
    399      * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th> </tr>
    400      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td>Maximum-resolution GPU processing with preview.</td> </tr>
    401      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td>Maximum-resolution in-app processing with preview.</td> </tr>
    402      * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td>Maximum-resolution two-input in-app processsing.</td> </tr>
    403      * </table><br>
    404      * </p>
    405      *
    406      * <p>LEVEL-3 ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
    407      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_3 LEVEL_3})
    408      * support at least the following stream combinations in addition to the combinations for
    409      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} and for
    410      * RAW capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
    411      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}):
    412      *
    413      * <table>
    414      * <tr><th colspan="11">LEVEL-3 additional guaranteed configurations</th></tr>
    415      * <tr><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th><th colspan="2" id="rb">Target 4</th><th rowspan="2">Sample use case(s)</th> </tr>
    416      * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th> </tr>
    417      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code 640x480}</td> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>In-app viewfinder analysis with dynamic selection of output format.</td> </tr>
    418      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code 640x480}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>In-app viewfinder analysis with dynamic selection of output format.</td> </tr>
    419      * </table><br>
    420      * </p>
    421      *
    422      * <p>Since the capabilities of camera devices vary greatly, a given camera device may support
    423      * target combinations with sizes outside of these guarantees, but this can only be tested for
    424      * by attempting to create a session with such targets.</p>
    425      *
    426      * @param outputs The new set of Surfaces that should be made available as
    427      *                targets for captured image data.
    428      * @param callback The callback to notify about the status of the new capture session.
    429      * @param handler The handler on which the callback should be invoked, or {@code null} to use
    430      *                the current thread's {@link android.os.Looper looper}.
    431      *
    432      * @throws IllegalArgumentException if the set of output Surfaces do not meet the requirements,
    433      *                                  the callback is null, or the handler is null but the current
    434      *                                  thread has no looper.
    435      * @throws CameraAccessException if the camera device is no longer connected or has
    436      *                               encountered a fatal error
    437      * @throws IllegalStateException if the camera device has been closed
    438      *
    439      * @see CameraCaptureSession
    440      * @see StreamConfigurationMap#getOutputFormats()
    441      * @see StreamConfigurationMap#getOutputSizes(int)
    442      * @see StreamConfigurationMap#getOutputSizes(Class)
    443      */
    444     public abstract void createCaptureSession(@NonNull List<Surface> outputs,
    445             @NonNull CameraCaptureSession.StateCallback callback, @Nullable Handler handler)
    446             throws CameraAccessException;
    447 
    448     /**
    449      * <p>Create a new camera capture session by providing the target output set of Surfaces and
    450      * its corresponding surface configuration to the camera device.</p>
    451      *
    452      * @see #createCaptureSession
    453      * @see OutputConfiguration
    454      */
    455     public abstract void createCaptureSessionByOutputConfigurations(
    456             List<OutputConfiguration> outputConfigurations,
    457             CameraCaptureSession.StateCallback callback, @Nullable Handler handler)
    458             throws CameraAccessException;
    459     /**
    460      * Create a new reprocessable camera capture session by providing the desired reprocessing
    461      * input Surface configuration and the target output set of Surfaces to the camera device.
    462      *
    463      * <p>If a camera device supports YUV reprocessing
    464      * ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING}) or PRIVATE
    465      * reprocessing
    466      * ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING}), besides
    467      * the capture session created via {@link #createCaptureSession createCaptureSession}, the
    468      * application can also create a reprocessable capture session to submit reprocess capture
    469      * requests in addition to regular capture requests. A reprocess capture request takes the next
    470      * available buffer from the session's input Surface, and sends it through the camera device's
    471      * processing pipeline again, to produce buffers for the request's target output Surfaces. No
    472      * new image data is captured for a reprocess request. However the input buffer provided by
    473      * the application must be captured previously by the same camera device in the same session
    474      * directly (e.g. for Zero-Shutter-Lag use case) or indirectly (e.g. combining multiple output
    475      * images).</p>
    476      *
    477      * <p>The active reprocessable capture session determines an input {@link Surface} and the set
    478      * of potential output Surfaces for the camera devices for each capture request. The application
    479      * can use {@link #createCaptureRequest createCaptureRequest} to create regular capture requests
    480      * to capture new images from the camera device, and use {@link #createReprocessCaptureRequest
    481      * createReprocessCaptureRequest} to create reprocess capture requests to process buffers from
    482      * the input {@link Surface}. Some combinations of output Surfaces in a session may not be used
    483      * in a request simultaneously. The guaranteed combinations of output Surfaces that can be used
    484      * in a request simultaneously are listed in the tables under {@link #createCaptureSession
    485      * createCaptureSession}. All the output Surfaces in one capture request will come from the
    486      * same source, either from a new capture by the camera device, or from the input Surface
    487      * depending on if the request is a reprocess capture request.</p>
    488      *
    489      * <p>Input formats and sizes supported by the camera device can be queried via
    490      * {@link StreamConfigurationMap#getInputFormats} and
    491      * {@link StreamConfigurationMap#getInputSizes}. For each supported input format, the camera
    492      * device supports a set of output formats and sizes for reprocessing that can be queried via
    493      * {@link StreamConfigurationMap#getValidOutputFormatsForInput} and
    494      * {@link StreamConfigurationMap#getOutputSizes}. While output Surfaces with formats that
    495      * aren't valid reprocess output targets for the input configuration can be part of a session,
    496      * they cannot be used as targets for a reprocessing request.</p>
    497      *
    498      * <p>Since the application cannot access {@link android.graphics.ImageFormat#PRIVATE} images
    499      * directly, an output Surface created by {@link android.media.ImageReader#newInstance} with
    500      * {@link android.graphics.ImageFormat#PRIVATE} as the format will be considered as intended to
    501      * be used for reprocessing input and thus the {@link android.media.ImageReader} size must
    502      * match one of the supported input sizes for {@link android.graphics.ImageFormat#PRIVATE}
    503      * format. Otherwise, creating a reprocessable capture session will fail.</p>
    504      *
    505      * <p>The guaranteed stream configurations listed in
    506      * {@link #createCaptureSession createCaptureSession} are also guaranteed to work for
    507      * {@link #createReprocessableCaptureSession createReprocessableCaptureSession}. In addition,
    508      * the configurations in the tables below are also guaranteed for creating a reprocessable
    509      * capture session if the camera device supports YUV reprocessing or PRIVATE reprocessing.
    510      * However, not all output targets used to create a reprocessable session may be used in a
    511      * {@link CaptureRequest} simultaneously. For devices that support only 1 output target in a
    512      * reprocess {@link CaptureRequest}, submitting a reprocess {@link CaptureRequest} with multiple
    513      * output targets will result in a {@link CaptureFailure}. For devices that support multiple
    514      * output targets in a reprocess {@link CaptureRequest}, the guaranteed output targets that can
    515      * be included in a {@link CaptureRequest} simultaneously are listed in the tables under
    516      * {@link #createCaptureSession createCaptureSession}. For example, with a FULL-capability
    517      * ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL} {@code == }
    518      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) device that supports PRIVATE
    519      * reprocessing, an application can create a reprocessable capture session with 1 input,
    520      * ({@code PRIV}, {@code MAXIMUM}), and 3 outputs, ({@code PRIV}, {@code MAXIMUM}),
    521      * ({@code PRIV}, {@code PREVIEW}), and ({@code YUV}, {@code MAXIMUM}). However, it's not
    522      * guaranteed that an application can submit a regular or reprocess capture with ({@code PRIV},
    523      * {@code MAXIMUM}) and ({@code YUV}, {@code MAXIMUM}) outputs based on the table listed under
    524      * {@link #createCaptureSession createCaptureSession}. In other words, use the tables below to
    525      * determine the guaranteed stream configurations for creating a reprocessable capture session,
    526      * and use the tables under {@link #createCaptureSession createCaptureSession} to determine the
    527      * guaranteed output targets that can be submitted in a regular or reprocess
    528      * {@link CaptureRequest} simultaneously.</p>
    529      *
    530      * <style scoped>
    531      *  #rb { border-right-width: thick; }
    532      * </style>
    533      *
    534      * <p>LIMITED-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
    535      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED}) devices
    536      * support at least the following stream combinations for creating a reprocessable capture
    537      * session in addition to those listed in {@link #createCaptureSession createCaptureSession} for
    538      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
    539      *
    540      * <table>
    541      * <tr><th colspan="11">LIMITED-level additional guaranteed configurations for creating a reprocessable capture session<br>({@code PRIV} input is guaranteed only if PRIVATE reprocessing is supported. {@code YUV} input is guaranteed only if YUV reprocessing is supported)</th></tr>
    542      * <tr><th colspan="2" id="rb">Input</th><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th><th colspan="2" id="rb">Target 4</th><th rowspan="2">Sample use case(s)</th> </tr>
    543      * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th></tr>
    544      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td></td><td id="rb"></td> <td></td><td id="rb"></td> <td>No-viewfinder still image reprocessing.</td> </tr>
    545      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td></td><td id="rb"></td> <td>ZSL(Zero-Shutter-Lag) still imaging.</td> </tr>
    546      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td></td><td id="rb"></td> <td>ZSL still and in-app processing imaging.</td> </tr>
    547      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>ZSL in-app processing with still capture.</td> </tr>
    548      * </table><br>
    549      * </p>
    550      *
    551      * <p>FULL-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
    552      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) devices
    553      * support at least the following stream combinations for creating a reprocessable capture
    554      * session in addition to those for
    555      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
    556      *
    557      * <table>
    558      * <tr><th colspan="11">FULL-level additional guaranteed configurations for creating a reprocessable capture session<br>({@code PRIV} input is guaranteed only if PRIVATE reprocessing is supported. {@code YUV} input is guaranteed only if YUV reprocessing is supported)</th></tr>
    559      * <tr><th colspan="2" id="rb">Input</th><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th><th colspan="2" id="rb">Target 4</th><th rowspan="2">Sample use case(s)</th> </tr>
    560      * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th></tr>
    561      * <tr> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td></td><td id="rb"></td> <td></td><td id="rb"></td> <td>Maximum-resolution multi-frame image fusion in-app processing with regular preview.</td> </tr>
    562      * <tr> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td></td><td id="rb"></td> <td></td><td id="rb"></td> <td>Maximum-resolution multi-frame image fusion two-input in-app processing.</td> </tr>
    563      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code RECORD}</td> <td></td><td id="rb"></td> <td>High-resolution ZSL in-app video processing with regular preview.</td> </tr>
    564      * <tr> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td></td><td id="rb"></td> <td>Maximum-resolution ZSL in-app processing with regular preview.</td> </tr>
    565      * <tr> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td></td><td id="rb"></td> <td>Maximum-resolution two-input ZSL in-app processing.</td> </tr>
    566      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>ZSL still capture and in-app processing.</td> </tr>
    567      * </table><br>
    568      * </p>
    569      *
    570      * <p>RAW-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
    571      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}) devices additionally support
    572      * at least the following stream combinations for creating a reprocessable capture session
    573      * on both {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} and
    574      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices
    575      *
    576      * <table>
    577      * <tr><th colspan="11">RAW-capability additional guaranteed configurations for creating a reprocessable capture session<br>({@code PRIV} input is guaranteed only if PRIVATE reprocessing is supported. {@code YUV} input is guaranteed only if YUV reprocessing is supported)</th></tr>
    578      * <tr><th colspan="2" id="rb">Input</th><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th><th colspan="2" id="rb">Target 4</th><th rowspan="2">Sample use case(s)</th> </tr>
    579      * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th></tr>
    580      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td></td><td id="rb"></td> <td>Mutually exclusive ZSL in-app processing and DNG capture.</td> </tr>
    581      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>Mutually exclusive ZSL in-app processing and preview with DNG capture.</td> </tr>
    582      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>Mutually exclusive ZSL two-input in-app processing and DNG capture.</td> </tr>
    583      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>Mutually exclusive ZSL still capture and preview with DNG capture.</td> </tr>
    584      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>Mutually exclusive ZSL in-app processing with still capture and DNG capture.</td> </tr>
    585      * </table><br>
    586      * </p>
    587      *
    588      * <p>LEVEL-3 ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
    589      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_3 LEVEL_3}) devices
    590      * support at least the following stream combinations for creating a reprocessable capture
    591      * session in addition to those for
    592      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} devices. Note that while
    593      * the second configuration allows for configuring {@code MAXIMUM} {@code YUV} and {@code JPEG}
    594      * outputs at the same time, that configuration is not listed for regular capture sessions, and
    595      * therefore simultaneous output to both targets is not allowed.
    596      *
    597      * <table>
    598      * <tr><th colspan="13">LEVEL-3 additional guaranteed configurations for creating a reprocessable capture session<br>({@code PRIV} input is guaranteed only if PRIVATE reprocessing is supported. {@code YUV} input is always guaranteed.</th></tr>
    599      * <tr><th colspan="2" id="rb">Input</th><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th><th colspan="2" id="rb">Target 4</th><th colspan="2" id="rb">Target 5</th><th rowspan="2">Sample use case(s)</th> </tr>
    600      * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th></tr>
    601      * <tr> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code 640x480}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td></td><td id="rb"></td> <td>In-app viewfinder analysis with ZSL and RAW.</td> </tr>
    602      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code 640x480}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td><td>In-app viewfinder analysis with ZSL, RAW, and JPEG reprocessing output.</td> </tr>
    603      * </table><br>
    604      * </p>
    605      *
    606      * @param inputConfig The configuration for the input {@link Surface}
    607      * @param outputs The new set of Surfaces that should be made available as
    608      *                targets for captured image data.
    609      * @param callback The callback to notify about the status of the new capture session.
    610      * @param handler The handler on which the callback should be invoked, or {@code null} to use
    611      *                the current thread's {@link android.os.Looper looper}.
    612      *
    613      * @throws IllegalArgumentException if the input configuration is null or not supported, the set
    614      *                                  of output Surfaces do not meet the requirements, the
    615      *                                  callback is null, or the handler is null but the current
    616      *                                  thread has no looper.
    617      * @throws CameraAccessException if the camera device is no longer connected or has
    618      *                               encountered a fatal error
    619      * @throws IllegalStateException if the camera device has been closed
    620      *
    621      * @see #createCaptureSession
    622      * @see CameraCaptureSession
    623      * @see StreamConfigurationMap#getInputFormats
    624      * @see StreamConfigurationMap#getInputSizes
    625      * @see StreamConfigurationMap#getValidOutputFormatsForInput
    626      * @see StreamConfigurationMap#getOutputSizes
    627      * @see android.media.ImageWriter
    628      * @see android.media.ImageReader
    629      */
    630     public abstract void createReprocessableCaptureSession(@NonNull InputConfiguration inputConfig,
    631             @NonNull List<Surface> outputs, @NonNull CameraCaptureSession.StateCallback callback,
    632             @Nullable Handler handler)
    633             throws CameraAccessException;
    634 
    635     /**
    636      * Create a new reprocessable camera capture session by providing the desired reprocessing
    637      * input configuration and output {@link OutputConfiguration}
    638      * to the camera device.
    639      *
    640      * @see #createReprocessableCaptureSession
    641      * @see OutputConfiguration
    642      *
    643      */
    644     public abstract void createReprocessableCaptureSessionByConfigurations(
    645             @NonNull InputConfiguration inputConfig,
    646             @NonNull List<OutputConfiguration> outputs,
    647             @NonNull CameraCaptureSession.StateCallback callback,
    648             @Nullable Handler handler)
    649             throws CameraAccessException;
    650 
    651     /**
    652      * <p>Create a new constrained high speed capture session.</p>
    653      *
    654      * <p>The application can use normal capture session (created via {@link #createCaptureSession})
    655      * for high speed capture if the desired high speed FPS ranges are advertised by
    656      * {@link CameraCharacteristics#CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES}, in which case all API
    657      * semantics associated with normal capture sessions applies.</p>
    658      *
    659      * <p>The method creates a specialized capture session that is only targeted at high speed
    660      * video recording (>=120fps) use case if the camera device supports high speed video
    661      * capability (i.e., {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} contains
    662      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO}).
    663      * Therefore, it has special characteristics compared with a normal capture session:</p>
    664      *
    665      * <ul>
    666      *
    667      * <li>In addition to the output target Surface requirements specified by the
    668      *   {@link #createCaptureSession} method, an active high speed capture session will support up
    669      *   to 2 output Surfaces, though the application might choose to configure just one Surface
    670      *   (e.g., preview only). All Surfaces must be either video encoder surfaces (acquired by
    671      *   {@link android.media.MediaRecorder#getSurface} or
    672      *   {@link android.media.MediaCodec#createInputSurface}) or preview surfaces (obtained from
    673      *   {@link android.view.SurfaceView}, {@link android.graphics.SurfaceTexture} via
    674      *   {@link android.view.Surface#Surface(android.graphics.SurfaceTexture)}). The Surface sizes
    675      *   must be one of the sizes reported by {@link StreamConfigurationMap#getHighSpeedVideoSizes}.
    676      *   When multiple Surfaces are configured, their size must be same.</li>
    677      *
    678      * <li>An active high speed capture session only accepts request lists created via
    679      *   {@link CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList}, and the
    680      *   request list can only be submitted to this session via
    681      *   {@link CameraCaptureSession#captureBurst captureBurst}, or
    682      *   {@link CameraCaptureSession#setRepeatingBurst setRepeatingBurst}.</li>
    683      *
    684      * <li>The FPS ranges being requested to this session must be selected from
    685      *   {@link StreamConfigurationMap#getHighSpeedVideoFpsRangesFor}. The application can still use
    686      *   {@link CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE} to control the desired FPS range.
    687      *   Switching to an FPS range that has different
    688      *   {@link android.util.Range#getUpper() maximum FPS} may trigger some camera device
    689      *   reconfigurations, which may introduce extra latency. It is recommended that the
    690      *   application avoids unnecessary maximum target FPS changes as much as possible during high
    691      *   speed streaming.</li>
    692      *
    693      * <li>For the request lists submitted to this session, the camera device will override the
    694      *   {@link CaptureRequest#CONTROL_MODE control mode}, auto-exposure (AE), auto-white balance
    695      *   (AWB) and auto-focus (AF) to {@link CameraMetadata#CONTROL_MODE_AUTO},
    696      *   {@link CameraMetadata#CONTROL_AE_MODE_ON}, {@link CameraMetadata#CONTROL_AWB_MODE_AUTO}
    697      *   and {@link CameraMetadata#CONTROL_AF_MODE_CONTINUOUS_VIDEO}, respectively. All
    698      *   post-processing block mode controls will be overridden to be FAST. Therefore, no manual
    699      *   control of capture and post-processing parameters is possible. Beside these, only a subset
    700      *   of controls will work, see
    701      *   {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO} for
    702      *   more details.</li>
    703      *
    704      * </ul>
    705      *
    706      * @param outputs The new set of Surfaces that should be made available as
    707      *                targets for captured high speed image data.
    708      * @param callback The callback to notify about the status of the new capture session.
    709      * @param handler The handler on which the callback should be invoked, or {@code null} to use
    710      *                the current thread's {@link android.os.Looper looper}.
    711      *
    712      * @throws IllegalArgumentException if the set of output Surfaces do not meet the requirements,
    713      *                                  the callback is null, or the handler is null but the current
    714      *                                  thread has no looper, or the camera device doesn't support
    715      *                                  high speed video capability.
    716      * @throws CameraAccessException if the camera device is no longer connected or has
    717      *                               encountered a fatal error
    718      * @throws IllegalStateException if the camera device has been closed
    719      *
    720      * @see #createCaptureSession
    721      * @see CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE
    722      * @see StreamConfigurationMap#getHighSpeedVideoSizes
    723      * @see StreamConfigurationMap#getHighSpeedVideoFpsRangesFor
    724      * @see CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES
    725      * @see CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO
    726      * @see CameraCaptureSession#captureBurst
    727      * @see CameraCaptureSession#setRepeatingBurst
    728      * @see CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList
    729      */
    730     public abstract void createConstrainedHighSpeedCaptureSession(@NonNull List<Surface> outputs,
    731             @NonNull CameraCaptureSession.StateCallback callback,
    732             @Nullable Handler handler)
    733             throws CameraAccessException;
    734 
    735     /**
    736      * Standard camera operation mode.
    737      *
    738      * @see #createCustomCaptureSession
    739      * @hide
    740      */
    741     @SystemApi
    742     @TestApi
    743     public static final int SESSION_OPERATION_MODE_NORMAL =
    744             0; // ICameraDeviceUser.NORMAL_MODE;
    745 
    746     /**
    747      * Constrained high-speed operation mode.
    748      *
    749      * @see #createCustomCaptureSession
    750      * @hide
    751      */
    752     @SystemApi
    753     @TestApi
    754     public static final int SESSION_OPERATION_MODE_CONSTRAINED_HIGH_SPEED =
    755             1; // ICameraDeviceUser.CONSTRAINED_HIGH_SPEED_MODE;
    756 
    757     /**
    758      * First vendor-specific operating mode
    759      *
    760      * @see #createCustomCaptureSession
    761      * @hide
    762      */
    763     @SystemApi
    764     @TestApi
    765     public static final int SESSION_OPERATION_MODE_VENDOR_START =
    766             0x8000; // ICameraDeviceUser.VENDOR_MODE_START;
    767 
    768     /** @hide */
    769     @Retention(RetentionPolicy.SOURCE)
    770     @IntDef(prefix = {"SESSION_OPERATION_MODE"}, value =
    771             {SESSION_OPERATION_MODE_NORMAL,
    772              SESSION_OPERATION_MODE_CONSTRAINED_HIGH_SPEED,
    773              SESSION_OPERATION_MODE_VENDOR_START})
    774     public @interface SessionOperatingMode {};
    775 
    776     /**
    777      * Create a new camera capture session with a custom operating mode.
    778      *
    779      * @param inputConfig The configuration for the input {@link Surface} if a reprocessing session
    780      *                is desired, or {@code null} otherwise.
    781      * @param outputs The new set of {@link OutputConfiguration OutputConfigurations} that should be
    782      *                made available as targets for captured image data.
    783      * @param operatingMode The custom operating mode to use; a nonnegative value, either a custom
    784      *                vendor value or one of the SESSION_OPERATION_MODE_* values.
    785      * @param callback The callback to notify about the status of the new capture session.
    786      * @param handler The handler on which the callback should be invoked, or {@code null} to use
    787      *                the current thread's {@link android.os.Looper looper}.
    788      *
    789      * @throws IllegalArgumentException if the input configuration is null or not supported, the set
    790      *                                  of output Surfaces do not meet the requirements, the
    791      *                                  callback is null, or the handler is null but the current
    792      *                                  thread has no looper.
    793      * @throws CameraAccessException if the camera device is no longer connected or has
    794      *                               encountered a fatal error
    795      * @throws IllegalStateException if the camera device has been closed
    796      *
    797      * @see #createCaptureSession
    798      * @see #createReprocessableCaptureSession
    799      * @see CameraCaptureSession
    800      * @see OutputConfiguration
    801      * @hide
    802      */
    803     @SystemApi
    804     @TestApi
    805     public abstract void createCustomCaptureSession(
    806             InputConfiguration inputConfig,
    807             @NonNull List<OutputConfiguration> outputs,
    808             @SessionOperatingMode int operatingMode,
    809             @NonNull CameraCaptureSession.StateCallback callback,
    810             @Nullable Handler handler)
    811             throws CameraAccessException;
    812 
    813     /**
    814      * <p>Create a {@link CaptureRequest.Builder} for new capture requests,
    815      * initialized with template for a target use case. The settings are chosen
    816      * to be the best options for the specific camera device, so it is not
    817      * recommended to reuse the same request for a different camera device;
    818      * create a builder specific for that device and template and override the
    819      * settings as desired, instead.</p>
    820      *
    821      * @param templateType An enumeration selecting the use case for this request. Not all template
    822      * types are supported on every device. See the documentation for each template type for
    823      * details.
    824      * @return a builder for a capture request, initialized with default
    825      * settings for that template, and no output streams
    826      *
    827      * @throws IllegalArgumentException if the templateType is not supported by
    828      * this device.
    829      * @throws CameraAccessException if the camera device is no longer connected or has
    830      *                               encountered a fatal error
    831      * @throws IllegalStateException if the camera device has been closed
    832      *
    833      * @see #TEMPLATE_PREVIEW
    834      * @see #TEMPLATE_RECORD
    835      * @see #TEMPLATE_STILL_CAPTURE
    836      * @see #TEMPLATE_VIDEO_SNAPSHOT
    837      * @see #TEMPLATE_MANUAL
    838      */
    839     @NonNull
    840     public abstract CaptureRequest.Builder createCaptureRequest(@RequestTemplate int templateType)
    841             throws CameraAccessException;
    842 
    843     /**
    844      * <p>Create a {@link CaptureRequest.Builder} for a new reprocess {@link CaptureRequest} from a
    845      * {@link TotalCaptureResult}.
    846      *
    847      * <p>Each reprocess {@link CaptureRequest} processes one buffer from
    848      * {@link CameraCaptureSession}'s input {@link Surface} to all output {@link Surface Surfaces}
    849      * included in the reprocess capture request. The reprocess input images must be generated from
    850      * one or multiple output images captured from the same camera device. The application can
    851      * provide input images to camera device via {@link android.media.ImageWriter#queueInputImage}.
    852      * The application must use the capture result of one of those output images to create a
    853      * reprocess capture request so that the camera device can use the information to achieve
    854      * optimal reprocess image quality. For camera devices that support only 1 output
    855      * {@link Surface}, submitting a reprocess {@link CaptureRequest} with multiple
    856      * output targets will result in a {@link CaptureFailure}.
    857      *
    858      * @param inputResult The capture result of the output image or one of the output images used
    859      *                       to generate the reprocess input image for this capture request.
    860      *
    861      * @throws IllegalArgumentException if inputResult is null.
    862      * @throws CameraAccessException if the camera device is no longer connected or has
    863      *                               encountered a fatal error
    864      * @throws IllegalStateException if the camera device has been closed
    865      *
    866      * @see CaptureRequest.Builder
    867      * @see TotalCaptureResult
    868      * @see CameraDevice#createReprocessableCaptureSession
    869      * @see android.media.ImageWriter
    870      */
    871     @NonNull
    872     public abstract CaptureRequest.Builder createReprocessCaptureRequest(
    873             @NonNull TotalCaptureResult inputResult) throws CameraAccessException;
    874 
    875     /**
    876      * Close the connection to this camera device as quickly as possible.
    877      *
    878      * <p>Immediately after this call, all calls to the camera device or active session interface
    879      * will throw a {@link IllegalStateException}, except for calls to close(). Once the device has
    880      * fully shut down, the {@link StateCallback#onClosed} callback will be called, and the camera
    881      * is free to be re-opened.</p>
    882      *
    883      * <p>Immediately after this call, besides the final {@link StateCallback#onClosed} calls, no
    884      * further callbacks from the device or the active session will occur, and any remaining
    885      * submitted capture requests will be discarded, as if
    886      * {@link CameraCaptureSession#abortCaptures} had been called, except that no success or failure
    887      * callbacks will be invoked.</p>
    888      *
    889      */
    890     @Override
    891     public abstract void close();
    892 
    893     /**
    894      * A callback objects for receiving updates about the state of a camera device.
    895      *
    896      * <p>A callback instance must be provided to the {@link CameraManager#openCamera} method to
    897      * open a camera device.</p>
    898      *
    899      * <p>These state updates include notifications about the device completing startup (
    900      * allowing for {@link #createCaptureSession} to be called), about device
    901      * disconnection or closure, and about unexpected device errors.</p>
    902      *
    903      * <p>Events about the progress of specific {@link CaptureRequest CaptureRequests} are provided
    904      * through a {@link CameraCaptureSession.CaptureCallback} given to the
    905      * {@link CameraCaptureSession#capture}, {@link CameraCaptureSession#captureBurst},
    906      * {@link CameraCaptureSession#setRepeatingRequest}, or
    907      * {@link CameraCaptureSession#setRepeatingBurst} methods.
    908      *
    909      * @see CameraManager#openCamera
    910      */
    911     public static abstract class StateCallback {
    912        /**
    913          * An error code that can be reported by {@link #onError}
    914          * indicating that the camera device is in use already.
    915          *
    916          * <p>
    917          * This error can be produced when opening the camera fails due to the camera
    918         *  being used by a higher-priority camera API client.
    919          * </p>
    920          *
    921          * @see #onError
    922          */
    923         public static final int ERROR_CAMERA_IN_USE = 1;
    924 
    925         /**
    926          * An error code that can be reported by {@link #onError}
    927          * indicating that the camera device could not be opened
    928          * because there are too many other open camera devices.
    929          *
    930          * <p>
    931          * The system-wide limit for number of open cameras has been reached,
    932          * and more camera devices cannot be opened until previous instances are
    933          * closed.
    934          * </p>
    935          *
    936          * <p>
    937          * This error can be produced when opening the camera fails.
    938          * </p>
    939          *
    940          * @see #onError
    941          */
    942         public static final int ERROR_MAX_CAMERAS_IN_USE = 2;
    943 
    944         /**
    945          * An error code that can be reported by {@link #onError}
    946          * indicating that the camera device could not be opened due to a device
    947          * policy.
    948          *
    949          * @see android.app.admin.DevicePolicyManager#setCameraDisabled(android.content.ComponentName, boolean)
    950          * @see #onError
    951          */
    952         public static final int ERROR_CAMERA_DISABLED = 3;
    953 
    954        /**
    955          * An error code that can be reported by {@link #onError}
    956          * indicating that the camera device has encountered a fatal error.
    957          *
    958          * <p>The camera device needs to be re-opened to be used again.</p>
    959          *
    960          * @see #onError
    961          */
    962         public static final int ERROR_CAMERA_DEVICE = 4;
    963 
    964         /**
    965          * An error code that can be reported by {@link #onError}
    966          * indicating that the camera service has encountered a fatal error.
    967          *
    968          * <p>The Android device may need to be shut down and restarted to restore
    969          * camera function, or there may be a persistent hardware problem.</p>
    970          *
    971          * <p>An attempt at recovery <i>may</i> be possible by closing the
    972          * CameraDevice and the CameraManager, and trying to acquire all resources
    973          * again from scratch.</p>
    974          *
    975          * @see #onError
    976          */
    977         public static final int ERROR_CAMERA_SERVICE = 5;
    978 
    979         /** @hide */
    980         @Retention(RetentionPolicy.SOURCE)
    981         @IntDef(prefix = {"ERROR_"}, value =
    982             {ERROR_CAMERA_IN_USE,
    983              ERROR_MAX_CAMERAS_IN_USE,
    984              ERROR_CAMERA_DISABLED,
    985              ERROR_CAMERA_DEVICE,
    986              ERROR_CAMERA_SERVICE })
    987         public @interface ErrorCode {};
    988 
    989         /**
    990          * The method called when a camera device has finished opening.
    991          *
    992          * <p>At this point, the camera device is ready to use, and
    993          * {@link CameraDevice#createCaptureSession} can be called to set up the first capture
    994          * session.</p>
    995          *
    996          * @param camera the camera device that has become opened
    997          */
    998         public abstract void onOpened(@NonNull CameraDevice camera); // Must implement
    999 
   1000         /**
   1001          * The method called when a camera device has been closed with
   1002          * {@link CameraDevice#close}.
   1003          *
   1004          * <p>Any attempt to call methods on this CameraDevice in the
   1005          * future will throw a {@link IllegalStateException}.</p>
   1006          *
   1007          * <p>The default implementation of this method does nothing.</p>
   1008          *
   1009          * @param camera the camera device that has become closed
   1010          */
   1011         public void onClosed(@NonNull CameraDevice camera) {
   1012             // Default empty implementation
   1013         }
   1014 
   1015         /**
   1016          * The method called when a camera device is no longer available for
   1017          * use.
   1018          *
   1019          * <p>This callback may be called instead of {@link #onOpened}
   1020          * if opening the camera fails.</p>
   1021          *
   1022          * <p>Any attempt to call methods on this CameraDevice will throw a
   1023          * {@link CameraAccessException}. The disconnection could be due to a
   1024          * change in security policy or permissions; the physical disconnection
   1025          * of a removable camera device; or the camera being needed for a
   1026          * higher-priority camera API client.</p>
   1027          *
   1028          * <p>There may still be capture callbacks that are invoked
   1029          * after this method is called, or new image buffers that are delivered
   1030          * to active outputs.</p>
   1031          *
   1032          * <p>The default implementation logs a notice to the system log
   1033          * about the disconnection.</p>
   1034          *
   1035          * <p>You should clean up the camera with {@link CameraDevice#close} after
   1036          * this happens, as it is not recoverable until the camera can be opened
   1037          * again. For most use cases, this will be when the camera again becomes
   1038          * {@link CameraManager.AvailabilityCallback#onCameraAvailable available}.
   1039          * </p>
   1040          *
   1041          * @param camera the device that has been disconnected
   1042          */
   1043         public abstract void onDisconnected(@NonNull CameraDevice camera); // Must implement
   1044 
   1045         /**
   1046          * The method called when a camera device has encountered a serious error.
   1047          *
   1048          * <p>This callback may be called instead of {@link #onOpened}
   1049          * if opening the camera fails.</p>
   1050          *
   1051          * <p>This indicates a failure of the camera device or camera service in
   1052          * some way. Any attempt to call methods on this CameraDevice in the
   1053          * future will throw a {@link CameraAccessException} with the
   1054          * {@link CameraAccessException#CAMERA_ERROR CAMERA_ERROR} reason.
   1055          * </p>
   1056          *
   1057          * <p>There may still be capture completion or camera stream callbacks
   1058          * that will be called after this error is received.</p>
   1059          *
   1060          * <p>You should clean up the camera with {@link CameraDevice#close} after
   1061          * this happens. Further attempts at recovery are error-code specific.</p>
   1062          *
   1063          * @param camera The device reporting the error
   1064          * @param error The error code.
   1065          *
   1066          * @see #ERROR_CAMERA_IN_USE
   1067          * @see #ERROR_MAX_CAMERAS_IN_USE
   1068          * @see #ERROR_CAMERA_DISABLED
   1069          * @see #ERROR_CAMERA_DEVICE
   1070          * @see #ERROR_CAMERA_SERVICE
   1071          */
   1072         public abstract void onError(@NonNull CameraDevice camera,
   1073                 @ErrorCode int error); // Must implement
   1074     }
   1075 
   1076     /**
   1077      * To be inherited by android.hardware.camera2.* code only.
   1078      * @hide
   1079      */
   1080     public CameraDevice() {}
   1081 }
   1082