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.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.annotation.SystemApi;
23 import android.hardware.camera2.params.ExtensionSessionConfiguration;
24 import android.hardware.camera2.params.InputConfiguration;
25 import android.hardware.camera2.params.OutputConfiguration;
26 import android.hardware.camera2.params.SessionConfiguration;
27 import android.hardware.camera2.params.StreamConfigurationMap;
28 import android.os.Handler;
29 import android.view.Surface;
30 
31 import java.lang.annotation.Retention;
32 import java.lang.annotation.RetentionPolicy;
33 import java.util.List;
34 import java.util.Set;
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 several levels defined
46  * in {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}.
47  * If a device supports {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY} level,
48  * the camera device is running in backward compatibility mode and has minimum camera2 API support.
49  * If a device supports the {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED}
50  * level, then Camera2 exposes a feature set that is roughly equivalent to the older
51  * {@link android.hardware.Camera Camera} API, although with a cleaner and more
52  * efficient interface.
53  * If a device supports the {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL EXTERNAL}
54  * level, then the device is a removable camera that provides similar but slightly less features
55  * as the {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} level.
56  * Devices that implement the {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} or
57  * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_3 LEVEL3} level of support
58  * provide substantially improved capabilities over the older camera
59  * API. If your application requires a full-level device for
60  * proper operation, declare the "android.hardware.camera.level.full" feature in your
61  * manifest.</p>
62  *
63  * @see CameraManager#openCamera
64  * @see android.Manifest.permission#CAMERA
65  * @see CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL
66  */
67 public abstract class CameraDevice implements AutoCloseable {
68 
69     /**
70      * Create a request suitable for a camera preview window. Specifically, this
71      * means that high frame rate is given priority over the highest-quality
72      * post-processing. These requests would normally be used with the
73      * {@link CameraCaptureSession#setRepeatingRequest} method.
74      * This template is guaranteed to be supported on all camera devices.
75      *
76      * @see #createCaptureRequest
77      */
78     public static final int TEMPLATE_PREVIEW = 1;
79 
80     /**
81      * Create a request suitable for still image capture. Specifically, this
82      * means prioritizing image quality over frame rate. These requests would
83      * commonly be used with the {@link CameraCaptureSession#capture} method.
84      * This template is guaranteed to be supported on all camera devices except
85      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT DEPTH_OUTPUT} devices
86      * that are not {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE
87      * BACKWARD_COMPATIBLE}.
88      * @see #createCaptureRequest
89      */
90     public static final int TEMPLATE_STILL_CAPTURE = 2;
91 
92     /**
93      * Create a request suitable for video recording. Specifically, this means
94      * that a stable frame rate is used, and post-processing is set for
95      * recording quality. These requests would commonly be used with the
96      * {@link CameraCaptureSession#setRepeatingRequest} method.
97      * This template is guaranteed to be supported on all camera devices except
98      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT DEPTH_OUTPUT} devices
99      * that are not {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE
100      * BACKWARD_COMPATIBLE}.
101      *
102      * @see #createCaptureRequest
103      */
104     public static final int TEMPLATE_RECORD  = 3;
105 
106     /**
107      * Create a request suitable for still image capture while recording
108      * video. Specifically, this means maximizing image quality without
109      * disrupting the ongoing recording. These requests would commonly be used
110      * with the {@link CameraCaptureSession#capture} method while a request based on
111      * {@link #TEMPLATE_RECORD} is is in use with {@link CameraCaptureSession#setRepeatingRequest}.
112      * This template is guaranteed to be supported on all camera devices except
113      * legacy devices ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
114      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY}) and
115      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT DEPTH_OUTPUT} devices
116      * that are not {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE
117      * BACKWARD_COMPATIBLE}.
118      *
119      * @see #createCaptureRequest
120      */
121     public static final int TEMPLATE_VIDEO_SNAPSHOT = 4;
122 
123     /**
124      * Create a request suitable for zero shutter lag still capture. This means
125      * means maximizing image quality without compromising preview frame rate.
126      * AE/AWB/AF should be on auto mode. This is intended for application-operated ZSL. For
127      * device-operated ZSL, use {@link CaptureRequest#CONTROL_ENABLE_ZSL} if available.
128      * This template is guaranteed to be supported on camera devices that support the
129      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING PRIVATE_REPROCESSING}
130      * capability or the
131      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING YUV_REPROCESSING}
132      * capability.
133      *
134      * @see #createCaptureRequest
135      * @see CaptureRequest#CONTROL_ENABLE_ZSL
136      */
137     public static final int TEMPLATE_ZERO_SHUTTER_LAG = 5;
138 
139     /**
140      * A basic template for direct application control of capture
141      * parameters. All automatic control is disabled (auto-exposure, auto-white
142      * balance, auto-focus), and post-processing parameters are set to preview
143      * quality. The manual capture parameters (exposure, sensitivity, and so on)
144      * are set to reasonable defaults, but should be overridden by the
145      * application depending on the intended use case.
146      * This template is guaranteed to be supported on camera devices that support the
147      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR MANUAL_SENSOR}
148      * capability.
149      *
150      * @see #createCaptureRequest
151      */
152     public static final int TEMPLATE_MANUAL = 6;
153 
154      /** @hide */
155      @Retention(RetentionPolicy.SOURCE)
156      @IntDef(prefix = {"TEMPLATE_"}, value =
157          {TEMPLATE_PREVIEW,
158           TEMPLATE_STILL_CAPTURE,
159           TEMPLATE_RECORD,
160           TEMPLATE_VIDEO_SNAPSHOT,
161           TEMPLATE_ZERO_SHUTTER_LAG,
162           TEMPLATE_MANUAL})
163      public @interface RequestTemplate {};
164 
165      /**
166       * No vibration or sound muting for this camera device. This is the default
167       * mode for all camera devices.
168       *
169       * @see #setCameraAudioRestriction
170       */
171      public static final int AUDIO_RESTRICTION_NONE = 0;
172 
173      /**
174       * Mute vibration from ringtones, alarms or notifications while this camera device is in use.
175       *
176       * @see #setCameraAudioRestriction
177       */
178      public static final int AUDIO_RESTRICTION_VIBRATION = 1;
179 
180      /**
181       * Mute vibration and sound from ringtones, alarms or notifications while this camera device is
182       * in use.
183       *
184       * @see #setCameraAudioRestriction
185       */
186      public static final int AUDIO_RESTRICTION_VIBRATION_SOUND = 3;
187 
188      /** @hide */
189      @Retention(RetentionPolicy.SOURCE)
190      @IntDef(prefix = {"AUDIO_RESTRICTION_"}, value =
191          {AUDIO_RESTRICTION_NONE,
192           AUDIO_RESTRICTION_VIBRATION,
193           AUDIO_RESTRICTION_VIBRATION_SOUND})
194      public @interface CAMERA_AUDIO_RESTRICTION {};
195 
196     /**
197      * Get the ID of this camera device.
198      *
199      * <p>This matches the ID given to {@link CameraManager#openCamera} to instantiate this
200      * this camera device.</p>
201      *
202      * <p>This ID can be used to query the camera device's {@link
203      * CameraCharacteristics fixed properties} with {@link
204      * CameraManager#getCameraCharacteristics}.</p>
205      *
206      * <p>This method can be called even if the device has been closed or has encountered
207      * a serious error.</p>
208      *
209      * @return the ID for this camera device
210      *
211      * @see CameraManager#getCameraCharacteristics
212      * @see CameraManager#getCameraIdList
213      */
214     @NonNull
getId()215     public abstract String getId();
216 
217     /**
218      * <p>Create a new camera capture session by providing the target output set of Surfaces to the
219      * camera device.</p>
220      *
221      * @param outputs The new set of Surfaces that should be made available as
222      *                targets for captured image data.
223      * @param callback The callback to notify about the status of the new capture session.
224      * @param handler The handler on which the callback should be invoked, or {@code null} to use
225      *                the current thread's {@link android.os.Looper looper}.
226      *
227      * @throws IllegalArgumentException if the set of output Surfaces do not meet the requirements,
228      *                                  the callback is null, or the handler is null but the current
229      *                                  thread has no looper.
230      * @throws CameraAccessException if the camera device is no longer connected or has
231      *                               encountered a fatal error
232      * @throws IllegalStateException if the camera device has been closed
233      *
234      * @see CameraCaptureSession
235      * @see StreamConfigurationMap#getOutputFormats()
236      * @see StreamConfigurationMap#getOutputSizes(int)
237      * @see StreamConfigurationMap#getOutputSizes(Class)
238      * @deprecated Please use {@link
239      *      #createCaptureSession(android.hardware.camera2.params.SessionConfiguration)} for the
240      *      full set of configuration options available.
241      */
242     @Deprecated
createCaptureSession(@onNull List<Surface> outputs, @NonNull CameraCaptureSession.StateCallback callback, @Nullable Handler handler)243     public abstract void createCaptureSession(@NonNull List<Surface> outputs,
244             @NonNull CameraCaptureSession.StateCallback callback, @Nullable Handler handler)
245             throws CameraAccessException;
246 
247     /**
248      * <p>Create a new camera capture session by providing the target output set of Surfaces and
249      * its corresponding surface configuration to the camera device.</p>
250      *
251      * @see #createCaptureSession
252      * @see OutputConfiguration
253      * @deprecated Please use {@link
254      *      #createCaptureSession(android.hardware.camera2.params.SessionConfiguration)} for the
255      *      full set of configuration options available.
256      */
257     @Deprecated
createCaptureSessionByOutputConfigurations( List<OutputConfiguration> outputConfigurations, CameraCaptureSession.StateCallback callback, @Nullable Handler handler)258     public abstract void createCaptureSessionByOutputConfigurations(
259             List<OutputConfiguration> outputConfigurations,
260             CameraCaptureSession.StateCallback callback, @Nullable Handler handler)
261             throws CameraAccessException;
262     /**
263      * Create a new reprocessable camera capture session by providing the desired reprocessing
264      * input Surface configuration and the target output set of Surfaces to the camera device.
265      *
266      * @param inputConfig The configuration for the input {@link Surface}
267      * @param outputs The new set of Surfaces that should be made available as
268      *                targets for captured image data.
269      * @param callback The callback to notify about the status of the new capture session.
270      * @param handler The handler on which the callback should be invoked, or {@code null} to use
271      *                the current thread's {@link android.os.Looper looper}.
272      *
273      * @throws IllegalArgumentException if the input configuration is null or not supported, the set
274      *                                  of output Surfaces do not meet the requirements, the
275      *                                  callback is null, or the handler is null but the current
276      *                                  thread has no looper.
277      * @throws CameraAccessException if the camera device is no longer connected or has
278      *                               encountered a fatal error
279      * @throws IllegalStateException if the camera device has been closed
280      *
281      * @see #createCaptureSession
282      * @see CameraCaptureSession
283      * @see StreamConfigurationMap#getInputFormats
284      * @see StreamConfigurationMap#getInputSizes
285      * @see StreamConfigurationMap#getValidOutputFormatsForInput
286      * @see StreamConfigurationMap#getOutputSizes(int)
287      * @see StreamConfigurationMap#getOutputSizes(Class)
288      * @see android.media.ImageWriter
289      * @see android.media.ImageReader
290      * @deprecated Please use {@link
291      *      #createCaptureSession(android.hardware.camera2.params.SessionConfiguration)} for the
292      *      full set of configuration options available.
293      */
294     @Deprecated
createReprocessableCaptureSession(@onNull InputConfiguration inputConfig, @NonNull List<Surface> outputs, @NonNull CameraCaptureSession.StateCallback callback, @Nullable Handler handler)295     public abstract void createReprocessableCaptureSession(@NonNull InputConfiguration inputConfig,
296             @NonNull List<Surface> outputs, @NonNull CameraCaptureSession.StateCallback callback,
297             @Nullable Handler handler)
298             throws CameraAccessException;
299 
300     /**
301      * Create a new reprocessable camera capture session by providing the desired reprocessing
302      * input configuration and output {@link OutputConfiguration}
303      * to the camera device.
304      *
305      * @see #createReprocessableCaptureSession
306      * @see OutputConfiguration
307      * @deprecated Please use {@link
308      *      #createCaptureSession(android.hardware.camera2.params.SessionConfiguration)} for the
309      *      full set of configuration options available.
310      */
311     @Deprecated
createReprocessableCaptureSessionByConfigurations( @onNull InputConfiguration inputConfig, @NonNull List<OutputConfiguration> outputs, @NonNull CameraCaptureSession.StateCallback callback, @Nullable Handler handler)312     public abstract void createReprocessableCaptureSessionByConfigurations(
313             @NonNull InputConfiguration inputConfig,
314             @NonNull List<OutputConfiguration> outputs,
315             @NonNull CameraCaptureSession.StateCallback callback,
316             @Nullable Handler handler)
317             throws CameraAccessException;
318 
319     /**
320      * <p>Create a new constrained high speed capture session.</p>
321      *
322      * @param outputs The new set of Surfaces that should be made available as
323      *                targets for captured high speed image data.
324      * @param callback The callback to notify about the status of the new capture session.
325      * @param handler The handler on which the callback should be invoked, or {@code null} to use
326      *                the current thread's {@link android.os.Looper looper}.
327      *
328      * @throws IllegalArgumentException if the set of output Surfaces do not meet the requirements,
329      *                                  the callback is null, or the handler is null but the current
330      *                                  thread has no looper, or the camera device doesn't support
331      *                                  high speed video capability.
332      * @throws CameraAccessException if the camera device is no longer connected or has
333      *                               encountered a fatal error
334      * @throws IllegalStateException if the camera device has been closed
335      *
336      * @see #createCaptureSession
337      * @see CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE
338      * @see StreamConfigurationMap#getHighSpeedVideoSizes
339      * @see StreamConfigurationMap#getHighSpeedVideoFpsRangesFor
340      * @see CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES
341      * @see CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO
342      * @see CameraCaptureSession#captureBurst
343      * @see CameraCaptureSession#setRepeatingBurst
344      * @see CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList
345      * @deprecated Please use {@link
346      *      #createCaptureSession(android.hardware.camera2.params.SessionConfiguration)} for the
347      *      full set of configuration options available.
348      */
349     @Deprecated
createConstrainedHighSpeedCaptureSession(@onNull List<Surface> outputs, @NonNull CameraCaptureSession.StateCallback callback, @Nullable Handler handler)350     public abstract void createConstrainedHighSpeedCaptureSession(@NonNull List<Surface> outputs,
351             @NonNull CameraCaptureSession.StateCallback callback,
352             @Nullable Handler handler)
353             throws CameraAccessException;
354 
355     /**
356      * Initialize a specific device-specific extension augmented camera capture
357      * session.
358      *
359      * <p>Extension sessions can be used to enable device-specific operation modes like
360      * {@link CameraExtensionCharacteristics#EXTENSION_NIGHT} or
361      * {@link CameraExtensionCharacteristics#EXTENSION_HDR}. These modes are less flexible than the
362      * full camera API, but enable access to more sophisticated processing algorithms that can
363      * capture multi-frame bursts to generate single output images. To query for available
364      * extensions on this device call
365      * {@link CameraExtensionCharacteristics#getSupportedExtensions()}.</p>
366      *
367      * <p>This method will also trigger the setup of the internal
368      * processing pipeline for extension augmented preview and multi-frame
369      * still capture.</p>
370      *
371      * <p>If a prior CameraCaptureSession already exists when this method is called, the previous
372      * session will no longer be able to accept new capture requests and will be closed. Any
373      * in-progress capture requests made on the prior session will be completed before it's closed.
374      * </p>
375      *
376      * <p>The CameraExtensionSession will be active until the client
377      * either calls CameraExtensionSession.close() or creates a new camera
378      * capture session. In both cases all internal resources will be
379      * released, continuous repeating requests stopped and any pending
380      * multi-frame capture requests flushed.</p>
381      *
382      * <p>Note that the CameraExtensionSession currently supports at most wo
383      * multi frame capture surface formats: ImageFormat.JPEG will be supported
384      * by all extensions and ImageFormat.YUV_420_888 may or may not be supported.
385      * Clients must query the multi-frame capture format support using
386      * {@link CameraExtensionCharacteristics#getExtensionSupportedSizes(int, int)}.
387      * For repeating requests CameraExtensionSession supports only
388      * {@link android.graphics.SurfaceTexture} as output. Clients can query the supported resolution
389      * for the repeating request output using
390      * {@link CameraExtensionCharacteristics#getExtensionSupportedSizes(int, Class)
391      * getExtensionSupportedSizes(..., Class)}.</p>
392      *
393      * <p>At the very minimum the initialization expects either one valid output
394      * surface for repeating or one valid output for high-quality single requests registered in the
395      * outputs argument of the extension configuration argument. At the maximum the initialization
396      * will accept two valid output surfaces, one for repeating and the other for single requests.
397      * Additional unsupported surfaces passed to ExtensionSessionConfiguration will cause an
398      * {@link IllegalArgumentException} to be thrown.</p>
399      *
400      * @param extensionConfiguration extension configuration
401      * @throws IllegalArgumentException If both the preview and still
402      *                                  capture surfaces are not set or invalid, or if any of the
403      *                                  registered surfaces do not meet the device-specific
404      *                                  extension requirements such as dimensions and/or
405      *                                  (output format)/(surface type), or if the extension is not
406      *                                  supported, or if any of the output configurations select
407      *                                  a dynamic range different from
408      *                                  {@link android.hardware.camera2.params.DynamicRangeProfiles#STANDARD},
409      *                                  or if any of the output configurations sets a stream use
410      *                                  case different from {@link
411      *                                  android.hardware.camera2.CameraCharacteristics#SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT}.
412      * @see CameraExtensionCharacteristics#getSupportedExtensions
413      * @see CameraExtensionCharacteristics#getExtensionSupportedSizes
414      */
createExtensionSession( @onNull ExtensionSessionConfiguration extensionConfiguration)415     public void createExtensionSession(
416             @NonNull ExtensionSessionConfiguration extensionConfiguration)
417             throws CameraAccessException {
418         throw new UnsupportedOperationException("No default implementation");
419     }
420 
421     /**
422      * Standard camera operation mode.
423      *
424      * @see #createCustomCaptureSession
425      * @hide
426      */
427     @SystemApi
428     public static final int SESSION_OPERATION_MODE_NORMAL =
429             0; // ICameraDeviceUser.NORMAL_MODE;
430 
431     /**
432      * Constrained high-speed operation mode.
433      *
434      * @see #createCustomCaptureSession
435      * @hide
436      */
437     @SystemApi
438     public static final int SESSION_OPERATION_MODE_CONSTRAINED_HIGH_SPEED =
439             1; // ICameraDeviceUser.CONSTRAINED_HIGH_SPEED_MODE;
440 
441     /**
442      * First vendor-specific operating mode
443      *
444      * @see #createCustomCaptureSession
445      * @hide
446      */
447     @SystemApi
448     public static final int SESSION_OPERATION_MODE_VENDOR_START =
449             0x8000; // ICameraDeviceUser.VENDOR_MODE_START;
450 
451     /** @hide */
452     @Retention(RetentionPolicy.SOURCE)
453     @IntDef(prefix = {"SESSION_OPERATION_MODE"}, value =
454             {SESSION_OPERATION_MODE_NORMAL,
455              SESSION_OPERATION_MODE_CONSTRAINED_HIGH_SPEED,
456              SESSION_OPERATION_MODE_VENDOR_START})
457     public @interface SessionOperatingMode {};
458 
459     /**
460      * Create a new camera capture session with a custom operating mode.
461      *
462      * @param inputConfig The configuration for the input {@link Surface} if a reprocessing session
463      *                is desired, or {@code null} otherwise.
464      * @param outputs The new set of {@link OutputConfiguration OutputConfigurations} that should be
465      *                made available as targets for captured image data.
466      * @param operatingMode The custom operating mode to use; a nonnegative value, either a custom
467      *                vendor value or one of the SESSION_OPERATION_MODE_* values.
468      * @param callback The callback to notify about the status of the new capture session.
469      * @param handler The handler on which the callback should be invoked, or {@code null} to use
470      *                the current thread's {@link android.os.Looper looper}.
471      *
472      * @throws IllegalArgumentException if the input configuration is null or not supported, the set
473      *                                  of output Surfaces do not meet the requirements, the
474      *                                  callback is null, or the handler is null but the current
475      *                                  thread has no looper.
476      * @throws CameraAccessException if the camera device is no longer connected or has
477      *                               encountered a fatal error
478      * @throws IllegalStateException if the camera device has been closed
479      *
480      * @see #createCaptureSession
481      * @see #createReprocessableCaptureSession
482      * @see CameraCaptureSession
483      * @see OutputConfiguration
484      * @deprecated Please use {@link
485      *      #createCaptureSession(android.hardware.camera2.params.SessionConfiguration)} for the
486      *      full set of configuration options available.
487      * @hide
488      */
489     @SystemApi
490     @Deprecated
createCustomCaptureSession( InputConfiguration inputConfig, @NonNull List<OutputConfiguration> outputs, @SessionOperatingMode int operatingMode, @NonNull CameraCaptureSession.StateCallback callback, @Nullable Handler handler)491     public abstract void createCustomCaptureSession(
492             InputConfiguration inputConfig,
493             @NonNull List<OutputConfiguration> outputs,
494             @SessionOperatingMode int operatingMode,
495             @NonNull CameraCaptureSession.StateCallback callback,
496             @Nullable Handler handler)
497             throws CameraAccessException;
498 
499     /**
500      * <p>Create a new {@link CameraCaptureSession} using a {@link SessionConfiguration} helper
501      * object that aggregates all supported parameters.</p>
502      * <p>The active capture session determines the set of potential output Surfaces for
503      * the camera device for each capture request. A given request may use all
504      * or only some of the outputs. Once the CameraCaptureSession is created, requests can be
505      * submitted with {@link CameraCaptureSession#capture capture},
506      * {@link CameraCaptureSession#captureBurst captureBurst},
507      * {@link CameraCaptureSession#setRepeatingRequest setRepeatingRequest}, or
508      * {@link CameraCaptureSession#setRepeatingBurst setRepeatingBurst}.</p>
509      *
510      * <p>Surfaces suitable for inclusion as a camera output can be created for
511      * various use cases and targets:</p>
512      *
513      * <ul>
514      *
515      * <li>For drawing to a {@link android.view.SurfaceView SurfaceView}: Once the SurfaceView's
516      *   Surface is {@link android.view.SurfaceHolder.Callback#surfaceCreated created}, set the size
517      *   of the Surface with {@link android.view.SurfaceHolder#setFixedSize} to be one of the sizes
518      *   returned by {@link StreamConfigurationMap#getOutputSizes(Class)
519      *   getOutputSizes(SurfaceHolder.class)} and then obtain the Surface by calling {@link
520      *   android.view.SurfaceHolder#getSurface}. If the size is not set by the application, it will
521      *   be rounded to the nearest supported size less than 1080p, by the camera device.</li>
522      *
523      * <li>For accessing through an OpenGL texture via a {@link android.graphics.SurfaceTexture
524      *   SurfaceTexture}: Set the size of the SurfaceTexture with {@link
525      *   android.graphics.SurfaceTexture#setDefaultBufferSize} to be one of the sizes returned by
526      *   {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(SurfaceTexture.class)}
527      *   before creating a Surface from the SurfaceTexture with {@link Surface#Surface}. If the size
528      *   is not set by the application, it will be set to be the smallest supported size less than
529      *   1080p, by the camera device.</li>
530      *
531      * <li>For recording with {@link android.media.MediaCodec}: Call
532      *   {@link android.media.MediaCodec#createInputSurface} after configuring
533      *   the media codec to use one of the sizes returned by
534      *   {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(MediaCodec.class)}
535      *   </li>
536      *
537      * <li>For recording with {@link android.media.MediaRecorder}: Call
538      *   {@link android.media.MediaRecorder#getSurface} after configuring the media recorder to use
539      *   one of the sizes returned by
540      *   {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(MediaRecorder.class)},
541      *   or configuring it to use one of the supported
542      *   {@link android.media.CamcorderProfile CamcorderProfiles}.</li>
543      *
544      * <li>For efficient YUV processing with {@link android.renderscript}:
545      *   Create a RenderScript
546      *   {@link android.renderscript.Allocation Allocation} with a supported YUV
547      *   type, the IO_INPUT flag, and one of the sizes returned by
548      *   {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(Allocation.class)},
549      *   Then obtain the Surface with
550      *   {@link android.renderscript.Allocation#getSurface}.</li>
551      *
552      * <li>For access to RAW, uncompressed YUV, or compressed JPEG data in the application: Create an
553      *   {@link android.media.ImageReader} object with one of the supported output formats given by
554      *   {@link StreamConfigurationMap#getOutputFormats()}, setting its size to one of the
555      *   corresponding supported sizes by passing the chosen output format into
556      *   {@link StreamConfigurationMap#getOutputSizes(int)}. Then obtain a
557      *   {@link android.view.Surface} from it with {@link android.media.ImageReader#getSurface()}.
558      *   If the ImageReader size is not set to a supported size, it will be rounded to a supported
559      *   size less than 1080p by the camera device.
560      *   </li>
561      *
562      * </ul>
563      *
564      * <p>The camera device will query each Surface's size and formats upon this
565      * call, so they must be set to a valid setting at this time.</p>
566      *
567      * <p>It can take several hundred milliseconds for the session's configuration to complete,
568      * since camera hardware may need to be powered on or reconfigured. Once the configuration is
569      * complete and the session is ready to actually capture data, the provided
570      * {@link CameraCaptureSession.StateCallback}'s
571      * {@link CameraCaptureSession.StateCallback#onConfigured} callback will be called.</p>
572      *
573      * <p>If a prior CameraCaptureSession already exists when this method is called, the previous
574      * session will no longer be able to accept new capture requests and will be closed. Any
575      * in-progress capture requests made on the prior session will be completed before it's closed.
576      * {@link CameraCaptureSession.StateCallback#onConfigured} for the new session may be invoked
577      * before {@link CameraCaptureSession.StateCallback#onClosed} is invoked for the prior
578      * session. Once the new session is {@link CameraCaptureSession.StateCallback#onConfigured
579      * configured}, it is able to start capturing its own requests. To minimize the transition time,
580      * the {@link CameraCaptureSession#abortCaptures} call can be used to discard the remaining
581      * requests for the prior capture session before a new one is created. Note that once the new
582      * session is created, the old one can no longer have its captures aborted.</p>
583      *
584      * <p>Using larger resolution outputs, or more outputs, can result in slower
585      * output rate from the device.</p>
586      *
587      * <p>Configuring a session with an empty or null list will close the current session, if
588      * any. This can be used to release the current session's target surfaces for another use.</p>
589      *
590      * <h3>Regular capture</h3>
591      *
592      * <p>While any of the sizes from {@link StreamConfigurationMap#getOutputSizes} can be used when
593      * a single output stream is configured, a given camera device may not be able to support all
594      * combination of sizes, formats, and targets when multiple outputs are configured at once.  The
595      * tables below list the maximum guaranteed resolutions for combinations of streams and targets,
596      * given the capabilities of the camera device. These are valid for when the
597      * {@link android.hardware.camera2.params.SessionConfiguration#setInputConfiguration
598      * input configuration} is not set and therefore no reprocessing is active.</p>
599      *
600      * <p>If an application tries to create a session using a set of targets that exceed the limits
601      * described in the below tables, one of three possibilities may occur. First, the session may
602      * be successfully created and work normally. Second, the session may be successfully created,
603      * but the camera device won't meet the frame rate guarantees as described in
604      * {@link StreamConfigurationMap#getOutputMinFrameDuration}. Or third, if the output set
605      * cannot be used at all, session creation will fail entirely, with
606      * {@link CameraCaptureSession.StateCallback#onConfigureFailed} being invoked.</p>
607      *
608      * <p>For the type column, {@code PRIV} refers to any target whose available sizes are found
609      * using {@link StreamConfigurationMap#getOutputSizes(Class)} with no direct application-visible
610      * format, {@code YUV} refers to a target Surface using the
611      * {@link android.graphics.ImageFormat#YUV_420_888} format, {@code JPEG} refers to the
612      * {@link android.graphics.ImageFormat#JPEG} format, and {@code RAW} refers to the
613      * {@link android.graphics.ImageFormat#RAW_SENSOR} format.</p>
614      *
615      * <p>For the maximum size column, {@code PREVIEW} refers to the best size match to the
616      * device's screen resolution, or to 1080p ({@code 1920x1080}), whichever is
617      * smaller. {@code RECORD} refers to the camera device's maximum supported recording resolution,
618      * as determined by {@link android.media.CamcorderProfile}. And {@code MAXIMUM} refers to the
619      * camera device's maximum output resolution for that format or target from
620      * {@link StreamConfigurationMap#getOutputSizes}.</p>
621      *
622      * <p>To use these tables, determine the number and the formats/targets of outputs needed, and
623      * find the row(s) of the table with those targets. The sizes indicate the maximum set of sizes
624      * that can be used; it is guaranteed that for those targets, the listed sizes and anything
625      * smaller from the list given by {@link StreamConfigurationMap#getOutputSizes} can be
626      * successfully used to create a session.  For example, if a row indicates that a 8 megapixel
627      * (MP) YUV_420_888 output can be used together with a 2 MP {@code PRIV} output, then a session
628      * can be created with targets {@code [8 MP YUV, 2 MP PRIV]} or targets {@code [2 MP YUV, 2 MP
629      * PRIV]}; but a session with targets {@code [8 MP YUV, 4 MP PRIV]}, targets {@code [4 MP YUV, 4
630      * MP PRIV]}, or targets {@code [8 MP PRIV, 2 MP YUV]} would not be guaranteed to work, unless
631      * some other row of the table lists such a combination.</p>
632      *
633      * <style scoped>
634      *  #rb { border-right-width: thick; }
635      * </style>
636      *
637      * <h5>LEGACY-level guaranteed configurations</h5>
638      *
639      * <p>Legacy devices ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
640      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY}) support at
641      * least the following stream combinations:
642      *
643      * <table>
644      * <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>
645      * <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>
646      * <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>
647      * <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>
648      * <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>
649      * <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>
650      * <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>
651      * <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>
652      * <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>
653      * <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>
654      * </table><br>
655      * </p>
656      *
657      * <h5>LIMITED-level additional guaranteed configurations</h5>
658      *
659      * <p>Limited-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
660      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED}) devices
661      * support at least the following stream combinations in addition to those for
662      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY} devices:
663      *
664      * <table>
665      * <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>
666      * <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>
667      * <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>
668      * <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>
669      * <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>
670      * <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>
671      * <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>
672      * <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>
673      * </table><br>
674      * </p>
675      *
676      * <h5>FULL-level additional guaranteed configurations</h5>
677      *
678      * <p>FULL-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
679      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) devices
680      * support at least the following stream combinations in addition to those for
681      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
682      *
683      * <table>
684      * <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>
685      * <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>
686      * <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>
687      * <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>
688      * <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 processing.</td> </tr>
689      * <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>
690      * <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>
691      * <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>
692      * </table><br>
693      * </p>
694      *
695      * <h5>RAW-capability additional guaranteed configurations</h5>
696      *
697      * <p>RAW-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
698      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}) devices additionally support
699      * at least the following stream combinations on both
700      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} and
701      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
702      *
703      * <table>
704      * <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>
705      * <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>
706      * <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>
707      * <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>
708      * <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>
709      * <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>
710      * <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>
711      * <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>
712      * <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>
713      * <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>
714      * </table><br>
715      * </p>
716      *
717      * <h5>BURST-capability additional guaranteed configurations</h5>
718      *
719      * <p>BURST-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
720      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE BURST_CAPTURE}) devices
721      * support at least the below stream combinations in addition to those for
722      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices. Note that all
723      * FULL-level devices support the BURST capability, and the below list is a strict subset of the
724      * list for FULL-level devices, so this table is only relevant for LIMITED-level devices that
725      * support the BURST_CAPTURE capability.
726      *
727      * <table>
728      * <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>
729      * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th> </tr>
730      * <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>
731      * <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>
732      * <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 processing.</td> </tr>
733      * </table><br>
734      * </p>
735      *
736      * <h5>LEVEL-3 additional guaranteed configurations</h5>
737      *
738      * <p>LEVEL-3 ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
739      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_3 LEVEL_3})
740      * support at least the following stream combinations in addition to the combinations for
741      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} and for
742      * RAW capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
743      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}):
744      *
745      * <table>
746      * <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>
747      * <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>
748      * <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>
749      * <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>
750      * </table><br>
751      * </p>
752      *
753      * <h5>Concurrent stream guaranteed configurations</h5>
754      *
755      * <p>BACKWARD_COMPATIBLE devices capable of streaming concurrently with other devices as
756      * described by {@link android.hardware.camera2.CameraManager#getConcurrentCameraIds} have the
757      * following guaranteed streams (when streaming concurrently with other devices)</p>
758      *
759      * <p> Note: The sizes mentioned for these concurrent streams are the maximum sizes guaranteed
760      * to be supported. Sizes smaller than these, obtained by {@link StreamConfigurationMap#getOutputSizes} for a particular format, are supported as well. </p>
761      *
762      * <p>
763      * <table>
764      * <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>
765      * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th> </tr>
766      * <tr> <td>{@code YUV}</td><td id="rb">{@code s1440p}</td>  <td colspan="2" id="rb"></td> <td>In-app video / image processing.</td> </tr>
767      * <tr> <td>{@code PRIV}</td><td id="rb">{@code s1440p}</td>  <td colspan="2" id="rb"></td> <td>In-app viewfinder analysis.</td> </tr>
768      * <tr> <td>{@code JPEG}</td><td id="rb">{@code s1440p}</td>  <td colspan="2" id="rb"></td> <td>No viewfinder still image capture.</td> </tr>
769      * <tr> <td>{@code YUV / PRIV}</td><td id="rb">{@code s720p}</td> <td>{@code JPEG}</td><td id="rb">{@code s1440p}</td> <td> Standard still imaging.</td> </tr>
770      * <tr> <td>{@code YUV / PRIV}</td><td id="rb">{@code s720p}</td> <td>{@code YUV / PRIV }</td><td id="rb">{@code s1440p}</td> <td>In-app video / processing with preview.</td> </tr>
771      * </table><br>
772      * </p>
773      *
774      * <p> Devices which are not backwards-compatible, support a mandatory single stream of size sVGA with image format {@code DEPTH16} during concurrent operation. </p>
775      *
776      * <p> For guaranteed concurrent stream configurations:</p>
777      * <p> sVGA refers to the camera device's maximum resolution for that format from {@link StreamConfigurationMap#getOutputSizes} or
778      * VGA resolution (640X480) whichever is lower. </p>
779      * <p> s720p refers to the camera device's maximum resolution for that format from {@link StreamConfigurationMap#getOutputSizes} or
780      * 720p(1280X720) whichever is lower. </p>
781      * <p> s1440p refers to the camera device's maximum resolution for that format from {@link StreamConfigurationMap#getOutputSizes} or
782      * 1440p(1920X1440) whichever is lower. </p>
783      * <p>MONOCHROME-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES}
784      * includes {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME MONOCHROME}) devices
785      * supporting {@link android.graphics.ImageFormat#Y8 Y8} support substituting {@code YUV}
786      * streams with {@code Y8} in all guaranteed stream combinations for the device's hardware level
787      * and capabilities.</p>
788      *
789      * <p>Clients can access the above mandatory stream combination tables via
790      * {@link android.hardware.camera2.params.MandatoryStreamCombination}.</p>
791      *
792      * <p>Devices capable of outputting HEIC formats ({@link StreamConfigurationMap#getOutputFormats}
793      * contains {@link android.graphics.ImageFormat#HEIC}) will support substituting {@code JPEG}
794      * streams with {@code HEIC} in all guaranteed stream combinations for the device's hardware
795      * level and capabilities. Calling createCaptureSession with both JPEG and HEIC outputs is not
796      * supported.</p>
797      *
798      * <h5>LEGACY-level additional guaranteed combinations with multi-resolution outputs</h5>
799      *
800      * <p>Devices capable of multi-resolution output for a particular format (
801      * {@link android.hardware.camera2.params.MultiResolutionStreamConfigurationMap#getOutputInfo}
802      * returns a non-empty list) support using {@link MultiResolutionImageReader} for MAXIMUM
803      * resolution streams of that format for all mandatory stream combinations. For example,
804      * if a LIMITED camera device supports multi-resolution output streams for both {@code JPEG} and
805      * {@code PRIVATE}, in addition to the stream configurations
806      * in the LIMITED and Legacy table above, the camera device supports the following guaranteed
807      * stream combinations ({@code MULTI_RES} in the Max size column refers to a {@link
808      * MultiResolutionImageReader} created based on the variable max resolutions supported):
809      *
810      * <table>
811      * <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>
812      * <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>
813      * <tr> <td>{@code PRIV}</td><td id="rb">{@code MULTI_RES}</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>
814      * <tr> <td>{@code JPEG}</td><td id="rb">{@code MULTI_RES}</td> <td colspan="2" id="rb"></td> <td colspan="2" id="rb"></td> <td>No-viewfinder still image capture.</td> </tr>
815      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MULTI_RES}</td> <td colspan="2" id="rb"></td> <td>Standard still imaging.</td> </tr>
816      * <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 MULTI_RES}</td> <td>Still capture plus in-app processing.</td> </tr>
817      * </table><br>
818      * </p>
819      *
820      * <h5>LIMITED-level additional guaranteed configurations with multi-resolution outputs</h5>
821      *
822      * <p>
823      * <table>
824      * <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>
825      * <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>
826      * <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 MULTI_RES}</td> <td>Two-input in-app processing with still capture.</td> </tr>
827      * </table><br>
828      * The same logic applies to other hardware levels and capabilities.
829      * </p>
830      *
831      * <h5>Additional guaranteed combinations for ULTRA_HIGH_RESOLUTION sensors</h5>
832      *
833      * <p> Devices with the ULTRA_HIGH_RESOLUTION_SENSOR capability have some additional guarantees
834      * which clients can take advantage of:
835      *
836      * <table>
837      * <tr> <th colspan="3" id="rb">Target 1</th> <th colspan="3" id="rb">Target 2</th>  <th colspan="3" id="rb">Target 3</th> <th rowspan="2">Sample use case(s)</th> </tr>
838      * <tr> <th>Type</th><th id="rb"> SC Map</th><th id="rb">Max size</th> <th>Type</th><th id="rb"> SC Map</th><th id="rb">Max size</th> <th>Type</th><th id="rb"> SC Map</th><th id="rb">Max size</th></tr>
839      * <tr> <td>{@code YUV / JPEG / RAW}</td><td id="rb">{@code MAX_RES}</td><td id="rb">{@code MAX}</td><td id="rb">{@code PRIV / YUV}</td><td id="rb">{@code DEFAULT}</td><td id="rb">{@code PREVIEW}</td><td colspan="3" id="rb"></td> <td>Ultra high res still image capture with preview</td> </tr>
840      * <tr> <td>{@code YUV / JPEG / RAW}</td><td id="rb">{@code MAX_RES}</td><td id="rb">{@code MAX}</td><td id="rb">{@code PRIV}</td><td id="rb">{@code DEFAULT}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PRIV / YUV}</td><td id="rb">{@code DEFAULT}</td><td id="rb">{@code RECORD}</td> <td>Ultra high res still capture with preview + app based RECORD size analysis</td> </tr>
841      * <tr> <td>{@code YUV / JPEG / RAW}</td><td id="rb">{@code MAX_RES}</td><td id="rb">{@code MAX}</td><td id="rb">{@code PRIV}</td><td id="rb">{@code DEFAULT}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code JPEG / YUV / RAW}</td><td id="rb">{@code DEFAULT}</td><td id="rb">{@code MAX}</td> <td>Ultra high res still image capture with preview + default sensor pixel mode analysis stream</td> </tr>
842      * </table><br>
843      * </p>
844      *
845      * <p> Here, SC Map, refers to the {@link StreamConfigurationMap}, the target stream sizes must
846      * be chosen from. {@code DEFAULT} refers to the default sensor pixel mode {@link
847      * StreamConfigurationMap} and {@code MAX_RES} refers to the maximum resolution {@link
848      * StreamConfigurationMap}. For {@code MAX_RES} streams, {@code MAX} in the {@code Max size} column refers to the maximum size from
849      * {@link StreamConfigurationMap#getOutputSizes} and {@link StreamConfigurationMap#getHighResolutionOutputSizes}.
850      * Note: The same capture request must not mix targets from
851      * {@link StreamConfigurationMap}s corresponding to different sensor pixel modes. </p>
852      *
853      * <h5>10-bit output additional guaranteed configurations</h5>
854      *
855      * <p>10-bit output capable
856      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT}
857      * devices support at least the following stream combinations:
858      *
859      * <table>
860      * <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>
861      * <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>
862      * <tr> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> </td> <td colspan="4" id="rb"></td> <td>Simple preview, GPU video processing, or no-preview video recording.</td> </tr>
863      * <tr> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> </td> <td colspan="4" id="rb"></td> <td>In-application video/image processing.</td> </tr>
864      * <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>
865      * <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>
866      * <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 processing.</td> </tr>
867      * <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>
868      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code RECORD }</td> <td>{@code YUV}</td><td id="rb">{@code RECORD }</td> <td>High-resolution recording with in-app snapshot.</td> </tr>
869      * <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>
870      * </table><br>
871      * </p>
872      *
873      * <p>Here PRIV can be either 8 or 10-bit {@link android.graphics.ImageFormat#PRIVATE} pixel
874      * format. YUV can be either {@link android.graphics.ImageFormat#YUV_420_888} or
875      * {@link android.graphics.ImageFormat#YCBCR_P010}.
876      * For the maximum size column, PREVIEW refers to the best size match to the device's screen
877      * resolution, or to 1080p (1920x1080), whichever is smaller. RECORD refers to the camera
878      * device's maximum supported recording resolution, as determined by
879      * {@link android.media.CamcorderProfile}. MAXIMUM refers to the camera device's maximum output
880      * resolution for that format or target from {@link StreamConfigurationMap#getOutputSizes(int)}.
881      * Do note that invalid combinations such as having a camera surface configured to use pixel
882      * format {@link android.graphics.ImageFormat#YUV_420_888} with a 10-bit profile
883      * will cause a capture session initialization failure.
884      * </p>
885      * <p>{@link android.graphics.ImageFormat#JPEG_R} may also be supported if advertised by
886      * {@link android.hardware.camera2.params.StreamConfigurationMap}. When initializing a capture
887      * session that includes a Jpeg/R camera output clients must consider the following items w.r.t.
888      * the 10-bit mandatory stream combination table:
889      *
890      * <ul>
891      *     <li>To generate the compressed Jpeg/R image a single
892      *     {@link android.graphics.ImageFormat#YCBCR_P010} output will be used internally by
893      *     the camera device.</li>
894      *     <li>On camera devices that are able to support concurrent 10 and 8-bit capture requests
895      *     see {@link android.hardware.camera2.params.DynamicRangeProfiles#getProfileCaptureRequestConstraints}
896      *     an extra {@link android.graphics.ImageFormat#JPEG} will also
897      *     be configured internally to help speed up the encoding process.</li>
898      * </ul>
899      *
900      * Jpeg/R camera outputs will typically be able to support the MAXIMUM device resolution.
901      * Clients can also call {@link StreamConfigurationMap#getOutputSizes(int)} for a complete list
902      * supported sizes.
903      * Camera clients that register a Jpeg/R output within a stream combination that doesn't fit
904      * in the mandatory stream table above can call
905      * {@link CameraDevice#isSessionConfigurationSupported} to ensure that this particular
906      * configuration is supported.</p>
907      *
908      * <h5>STREAM_USE_CASE capability additional guaranteed configurations</h5>
909      *
910      * <p>Devices with the STREAM_USE_CASE capability ({@link
911      * CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes {@link
912      * CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE}) support below additional
913      * stream combinations:
914      *
915      * <table>
916      * <tr><th colspan="3" id="rb">Target 1</th><th colspan="3" id="rb">Target 2</th><th colspan="3" id="rb">Target 3</th> <th rowspan="2">Sample use case(s)</th> </tr>
917      * <tr><th>Type</th><th id="rb">Max size</th><th>Usecase</th><th>Type</th><th id="rb">Max size</th><th>Usecase</th><th>Type</th><th id="rb">Max size</th><th>Usecase</th> </tr>
918      * <tr> <td>{@code YUV / PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td colspan="3" id="rb"></td> <td colspan="3" id="rb"></td> <td>Simple preview or in-app image processing</td> </tr>
919      * <tr> <td>{@code YUV / PRIV}</td><td id="rb">{@code RECORD}</td><td id="rb">{@code VIDEO_RECORD}</td> <td colspan="3" id="rb"></td> <td colspan="3" id="rb"></td> <td>Simple video recording or in-app video processing</td> </tr>
920      * <tr> <td>{@code YUV / JPEG}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code STILL_CAPTURE}</td> <td colspan="3" id="rb"></td> <td colspan="3" id="rb"></td> <td>Simple JPEG or YUV still image capture</td> </tr>
921      * <tr> <td>{@code YUV / PRIV}</td><td id="rb">{@code s1440p}</td><td id="rb">{@code PREVIEW_VIDEO_STILL}</td> <td colspan="3" id="rb"></td> <td colspan="3" id="rb"></td> <td>Multi-purpose stream for preview, video and still image capture</td> </tr>
922      * <tr> <td>{@code YUV / PRIV}</td><td id="rb">{@code s1440p}</td><td id="rb">{@code VIDEO_CALL}</td> <td colspan="3" id="rb"></td> <td colspan="3" id="rb"></td> <td>Simple video call</td> </tr>
923      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV / JPEG}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code STILL_CAPTURE}</td> <td colspan="3" id="rb"></td> <td>Preview with JPEG or YUV still image capture</td> </tr>
924      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV / PRIV}</td><td id="rb">{@code RECORD}</td><td id="rb">{@code VIDEO_RECORD}</td> <td colspan="3" id="rb"></td> <td>Preview with video recording or in-app video processing</td> </tr>
925      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td colspan="3" id="rb"></td> <td>Preview with in-application image processing</td> </tr>
926      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV / PRIV}</td><td id="rb">{@code s1440p}</td><td id="rb">{@code VIDEO_CALL}</td> <td colspan="3" id="rb"></td> <td>Preview with video call</td> </tr>
927      * <tr> <td>{@code YUV / PRIV}</td><td id="rb">{@code s1440p}</td><td id="rb">{@code PREVIEW_VIDEO_STILL}</td> <td>{@code YUV / JPEG}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code STILL_CAPTURE}</td> <td colspan="3" id="rb"></td> <td>MultI-purpose stream with JPEG or YUV still capture</td> </tr>
928      * <tr> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code STILL_CAPTURE}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code STILL_CAPTURE}</td> <td colspan="3" id="rb"></td> <td>YUV and JPEG concurrent still image capture (for testing)</td> </tr>
929      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV / PRIV}</td><td id="rb">{@code RECORD}</td><td id="rb">{@code VIDEO_RECORD}</td> <td>{@code JPEG}</td><td id="rb">{@code RECORD}</td><td id="rb">{@code STILL_CAPTURE}</td> <td>Preview, video record and JPEG video snapshot</td> </tr>
930      * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code STILL_CAPTURE}</td> <td>Preview, in-application image processing, and JPEG still image capture</td> </tr>
931      * </table><br>
932      * </p>
933      *
934      * <h5>STREAM_USE_CASE_CROPPED_RAW capability additional guaranteed configurations</h5>
935      *
936      * <p>Devices that include the {@link CameraMetadata#SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW}
937      * stream use-case in {@link CameraCharacteristics#SCALER_AVAILABLE_STREAM_USE_CASES},
938      * support the additional stream combinations below:
939      *
940      * <table>
941      * <tr><th colspan="3" id="rb">Target 1</th><th colspan="3" id="rb">Target 2</th><th colspan="3" id="rb">Target 3</th> <th rowspan="2">Sample use case(s)</th> </tr>
942      * <tr><th>Type</th><th id="rb">Max size</th><th>Usecase</th><th>Type</th><th id="rb">Max size</th><th>Usecase</th><th>Type</th><th id="rb">Max size</th><th>Usecase</th> </tr>
943      * <tr> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code CROPPED_RAW}</td> <td colspan="3" id="rb"></td> <td colspan="3" id="rb"></td> <td>Cropped RAW still capture without preview</td> </tr>
944      * <tr> <td>{@code PRIV / YUV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code CROPPED_RAW}</td> <td colspan="3" id="rb"></td> <td>Preview with cropped RAW still capture</td> </tr>
945      * <tr> <td>{@code PRIV / YUV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV / JPEG}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code STILL_CAPTURE}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code CROPPED_RAW}</td> <td>Preview with YUV / JPEG and cropped RAW still capture</td> </tr>
946      * <tr> <td>{@code PRIV / YUV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV / YUV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code VIDEO_RECORD / PREVIEW}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code CROPPED_RAW}</td> <td>Video recording with preview and cropped RAW still capture</td> </tr>
947      * </table><br>
948      * </p>
949      *
950      * <h5>Preview stabilization guaranteed stream configurations</h5>
951      *
952      * <p>For devices where
953      * {@link CameraCharacteristics#CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES} includes
954      * {@link CameraMetadata#CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION},
955      * the following stream combinations are guaranteed,
956      * for CaptureRequests where {@link CaptureRequest#CONTROL_VIDEO_STABILIZATION_MODE} is set to
957      * {@link CameraMetadata#CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION}
958      *
959      * <table>
960      * <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>
961      * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th></tr>
962      * <tr> <td>{@code PRIV / YUV}</td><td id="rb">{@code s1440p}</td><td colspan="2" id="rb"></td> <td>Stabilized preview, GPU video processing, or no-preview stabilized video recording.</td> </tr>
963      * <tr> <td>{@code PRIV / YUV}</td><td id="rb">{@code s1440p}</td> <td>{@code JPEG / YUV}</td><td id="rb">{@code MAXIMUM }</td><td>Standard still imaging with stabilized preview.</td> </tr>
964      * <tr> <td>{@code PRIV / YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV / YUV}</td><td id="rb">{@code s1440p }</td><td>High-resolution recording with stabilized preview and recording stream.</td> </tr>
965      * </table><br>
966      * </p>
967      *
968      * <p>
969      * For the maximum size column, PREVIEW refers to the best size match to the device's screen
970      * resolution, or to 1080p (1920x1080), whichever is smaller. RECORD refers to the camera
971      * device's maximum supported recording resolution, as determined by
972      * {@link android.media.CamcorderProfile}. MAXIMUM refers to the camera device's maximum output
973      * resolution for that format or target from {@link StreamConfigurationMap#getOutputSizes(int)}.
974      * </p>
975      *
976      * <p>Since the capabilities of camera devices vary greatly, a given camera device may support
977      * target combinations with sizes outside of these guarantees, but this can only be tested for
978      * by calling {@link #isSessionConfigurationSupported} or attempting to create a session with
979      * such targets.</p>
980      *
981      * <p>Exception on 176x144 (QCIF) resolution:
982      * Camera devices usually have a fixed capability for downscaling from larger resolution to
983      * smaller, and the QCIF resolution sometimes is not fully supported due to this
984      * limitation on devices with high-resolution image sensors. Therefore, trying to configure a
985      * QCIF resolution stream together with any other stream larger than 1920x1080 resolution
986      * (either width or height) might not be supported, and capture session creation will fail if it
987      * is not.</p>
988      *
989      * <h3>Reprocessing</h3>
990      *
991      * <p>If a camera device supports YUV reprocessing
992      * ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING}) or PRIVATE
993      * reprocessing
994      * ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING}), the
995      * application can also create a reprocessable capture session to submit reprocess capture
996      * requests in addition to regular capture requests, by setting an
997      * {@link android.hardware.camera2.params.SessionConfiguration#setInputConfiguration
998      * input configuration} for the session. A reprocess capture request takes the next available
999      * buffer from the
1000      * session's input Surface, and sends it through the camera device's processing pipeline again,
1001      * to produce buffers for the request's target output Surfaces. No new image data is captured
1002      * for a reprocess request. However the input buffer provided by the application must be
1003      * captured previously by the same camera device in the same session directly (e.g. for
1004      * Zero-Shutter-Lag use case) or indirectly (e.g. combining multiple output images).</p>
1005      *
1006      * <p>The active reprocessable capture session determines an input {@link Surface} and the set
1007      * of potential output Surfaces for the camera devices for each capture request. The application
1008      * can use {@link #createCaptureRequest createCaptureRequest} to create regular capture requests
1009      * to capture new images from the camera device, and use {@link #createReprocessCaptureRequest
1010      * createReprocessCaptureRequest} to create reprocess capture requests to process buffers from
1011      * the input {@link Surface}. Some combinations of output Surfaces in a session may not be used
1012      * in a request simultaneously. The guaranteed combinations of output Surfaces that can be used
1013      * in a request simultaneously are listed in the tables under {@link #createCaptureSession
1014      * createCaptureSession}. All the output Surfaces in one capture request will come from the
1015      * same source, either from a new capture by the camera device, or from the input Surface
1016      * depending on if the request is a reprocess capture request.</p>
1017      *
1018      * <p>Input formats and sizes supported by the camera device can be queried via
1019      * {@link StreamConfigurationMap#getInputFormats} and
1020      * {@link StreamConfigurationMap#getInputSizes}. For each supported input format, the camera
1021      * device supports a set of output formats and sizes for reprocessing that can be queried via
1022      * {@link StreamConfigurationMap#getValidOutputFormatsForInput} and
1023      * {@link StreamConfigurationMap#getOutputSizes}. While output Surfaces with formats that
1024      * aren't valid reprocess output targets for the input configuration can be part of a session,
1025      * they cannot be used as targets for a reprocessing request.</p>
1026      *
1027      * <p>Since the application cannot access {@link android.graphics.ImageFormat#PRIVATE} images
1028      * directly, an output Surface created by {@link android.media.ImageReader#newInstance} with
1029      * {@link android.graphics.ImageFormat#PRIVATE} as the format will be considered as intended to
1030      * be used for reprocessing input and thus the {@link android.media.ImageReader} size must
1031      * match one of the supported input sizes for {@link android.graphics.ImageFormat#PRIVATE}
1032      * format. Otherwise, creating a reprocessable capture session will fail.</p>
1033      *
1034      * <p>Starting from API level 30, recreating a reprocessable capture session will flush all the
1035      * queued but not yet processed buffers from the input surface.</p>
1036      *
1037      * <p>The configurations in the tables below are guaranteed for creating a reprocessable
1038      * capture session if the camera device supports YUV reprocessing or PRIVATE reprocessing.
1039      * However, not all output targets used to create a reprocessable session may be used in a
1040      * {@link CaptureRequest} simultaneously. For devices that support only 1 output target in a
1041      * reprocess {@link CaptureRequest}, submitting a reprocess {@link CaptureRequest} with multiple
1042      * output targets will result in a {@link CaptureFailure}. For devices that support multiple
1043      * output targets in a reprocess {@link CaptureRequest}, the guaranteed output targets that can
1044      * be included in a {@link CaptureRequest} simultaneously are listed in the tables under
1045      * {@link #createCaptureSession createCaptureSession}. For example, with a FULL-capability
1046      * ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL} {@code == }
1047      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) device that supports PRIVATE
1048      * reprocessing, an application can create a reprocessable capture session with 1 input,
1049      * ({@code PRIV}, {@code MAXIMUM}), and 3 outputs, ({@code PRIV}, {@code MAXIMUM}),
1050      * ({@code PRIV}, {@code PREVIEW}), and ({@code YUV}, {@code MAXIMUM}). However, it's not
1051      * guaranteed that an application can submit a regular or reprocess capture with ({@code PRIV},
1052      * {@code MAXIMUM}) and ({@code YUV}, {@code MAXIMUM}) outputs based on the table listed under
1053      * {@link #createCaptureSession createCaptureSession}. In other words, use the tables below to
1054      * determine the guaranteed stream configurations for creating a reprocessable capture session,
1055      * and use the tables under {@link #createCaptureSession createCaptureSession} to determine the
1056      * guaranteed output targets that can be submitted in a regular or reprocess
1057      * {@link CaptureRequest} simultaneously.</p>
1058      *
1059      * <p>Reprocessing with 10-bit output targets on 10-bit capable
1060      * {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT} devices is
1061      * not supported. Trying to initialize a repreocessable capture session with one ore more
1062      * output configurations set {@link OutputConfiguration#setDynamicRangeProfile} to use
1063      * a 10-bit dynamic range profile {@link android.hardware.camera2.params.DynamicRangeProfiles}
1064      * will trigger {@link IllegalArgumentException}.</p>
1065      *
1066      * <style scoped>
1067      *  #rb { border-right-width: thick; }
1068      * </style>
1069      *
1070      * <p>LIMITED-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
1071      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED}) devices
1072      * support at least the following stream combinations for creating a reprocessable capture
1073      * session in addition to those listed earlier for regular captures for
1074      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
1075      *
1076      * <table>
1077      * <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>
1078      * <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>
1079      * <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>
1080      * <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>
1081      * <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>
1082      * <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>
1083      * <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>
1084      * </table><br>
1085      * </p>
1086      *
1087      * <p>FULL-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
1088      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) devices
1089      * support at least the following stream combinations for creating a reprocessable capture
1090      * session in addition to those for
1091      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
1092      *
1093      * <table>
1094      * <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>
1095      * <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>
1096      * <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>
1097      * <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>
1098      * <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>
1099      * <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>
1100      * <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>
1101      * <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>
1102      * <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>
1103      * </table><br>
1104      * </p>
1105      *
1106      * <p>RAW-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
1107      * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}) devices additionally support
1108      * at least the following stream combinations for creating a reprocessable capture session
1109      * on both {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} and
1110      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices
1111      *
1112      * <table>
1113      * <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>
1114      * <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>
1115      * <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>
1116      * <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>
1117      * <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>
1118      * <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>
1119      * <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>
1120      * <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>
1121      * </table><br>
1122      * </p>
1123      *
1124      * <p>LEVEL-3 ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
1125      * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_3 LEVEL_3}) devices
1126      * support at least the following stream combinations for creating a reprocessable capture
1127      * session in addition to those for
1128      * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} devices. Note that while
1129      * the second configuration allows for configuring {@code MAXIMUM} {@code YUV} and {@code JPEG}
1130      * outputs at the same time, that configuration is not listed for regular capture sessions, and
1131      * therefore simultaneous output to both targets is not allowed.
1132      *
1133      * <table>
1134      * <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>
1135      * <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>
1136      * <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>
1137      * <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>
1138      * <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>
1139      * </table><br>
1140      * </p>
1141      *
1142      * <p>If a camera device supports multi-resolution {@code YUV} input and multi-resolution
1143      * {@code YUV} output or supports multi-resolution {@code PRIVATE} input and multi-resolution
1144      * {@code PRIVATE} output, the additional mandatory stream combinations for LIMITED and FULL devices are listed
1145      * below ({@code MULTI_RES} in the Max size column refers to a
1146      * {@link MultiResolutionImageReader} for output, and a multi-resolution
1147      * {@link InputConfiguration} for input):
1148      * <table>
1149      * <tr><th colspan="11">LIMITED-level additional guaranteed configurations for creating a reprocessable capture session with multi-resolution input and multi-resolution outputs<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>
1150      * <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>
1151      * <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>
1152      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MULTI_RES}</td> <td>Same as input</td><td id="rb">{@code MULTI_RES}</td> <td>{@code JPEG}</td><td id="rb">{@code MULTI_RES}</td> <td></td><td id="rb"></td> <td></td><td id="rb"></td> <td>No-viewfinder still image reprocessing.</td> </tr>
1153      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MULTI_RES}</td> <td>Same as input</td><td id="rb">{@code MULTI_RES}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MULTI_RES}</td> <td></td><td id="rb"></td> <td>ZSL(Zero-Shutter-Lag) still imaging.</td> </tr>
1154      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MULTI_RES}</td> <td>Same as input</td><td id="rb">{@code MULTI_RES}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MULTI_RES}</td> <td></td><td id="rb"></td> <td>ZSL still and in-app processing imaging.</td> </tr>
1155      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MULTI_RES}</td> <td>Same as input</td><td id="rb">{@code MULTI_RES}</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 MULTI_RES}</td> <td>ZSL in-app processing with still capture.</td> </tr>
1156      * </table><br>
1157      * <table>
1158      * <tr><th colspan="11">FULL-level additional guaranteed configurations for creating a reprocessable capture session with multi-resolution input and multi-resolution outputs<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>
1159      * <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>
1160      * <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>
1161      * <tr> <td>{@code PRIV}</td><td id="rb">{@code MULTI_RES}</td> <td>{@code PRIV}</td><td id="rb">{@code MULTI_RES}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code MULTI_RES}</td> <td></td><td id="rb"></td> <td>Maximum-resolution ZSL in-app processing with regular preview.</td> </tr>
1162      * <tr> <td>{@code PRIV}</td><td id="rb">{@code MULTI_RES}</td> <td>{@code PRIV}</td><td id="rb">{@code MULTI_RES}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code MULTI_RES}</td> <td></td><td id="rb"></td> <td>Maximum-resolution two-input ZSL in-app processing.</td> </tr>
1163      * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MULTI_RES}</td> <td>Same as input</td><td id="rb">{@code MULTI_RES}</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 MULTI_RES}</td> <td>ZSL still capture and in-app processing.</td> </tr>
1164      * </table><br>
1165      * <p> Devices with the ULTRA_HIGH_RESOLUTION_SENSOR capability have some additional guarantees
1166      * which clients can take advantage of : </p>
1167      * <table>
1168      * <tr><th colspan="13">Additional guaranteed combinations for ULTRA_HIGH_RESOLUTION sensors (YUV / PRIV inputs are guaranteed only if YUV / PRIVATE reprocessing are supported)</th></tr>
1169      * <tr> <th colspan="3" id="rb">Input</th> <th colspan="3" id="rb">Target 1</th> <th colspan="3" id="rb">Target 2</th>  <th colspan="3" id="rb">Target 3</th> <th rowspan="2">Sample use case(s)</th> </tr>
1170      * <tr> <th>Type</th><th id="rb"> SC Map</th><th id="rb">Max size</th><th>Type</th><th id="rb"> SC Map</th><th id="rb">Max size</th> <th>Type</th><th id="rb"> SC Map</th><th id="rb">Max size</th> <th>Type</th><th id="rb"> SC Map</th><th id="rb">Max size</th></tr>
1171      * <tr> <td>{@code RAW}</td><td id="rb">{@code MAX_RES}</td><td id="rb">{@code MAX}</td><td>{@code RAW}</td><td id="rb">{@code MAX_RES}</td><td id="rb">{@code MAX}</td><td id="rb">{@code PRIV / YUV}</td><td id="rb">{@code DEFAULT}</td><td id="rb">{@code PREVIEW}</td><td colspan="3" id="rb"></td> <td>RAW remosaic reprocessing with separate preview</td> </tr>
1172      * <tr> <td>{@code RAW}</td><td id="rb">{@code MAX_RES}</td><td id="rb">{@code MAX}</td><td>{@code RAW}</td><td id="rb">{@code MAX_RES}</td><td id="rb">{@code MAX}</td><td id="rb">{@code PRIV / YUV}</td><td id="rb">{@code DEFAULT}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code JPEG / YUV}</td><td id="rb">{@code MAX_RES}</td><td id="rb">{@code MAX}</td> <td>Ultra high res RAW -> JPEG / YUV with seperate preview</td> </tr>
1173      * <tr> <td>{@code YUV / PRIV}</td><td id="rb">{@code MAX_RES}</td><td id="rb">{@code MAX}</td> <td>{@code YUV / PRIV}</td><td id="rb">{@code MAX_RES}</td><td id="rb">{@code MAX}</td><td id="rb">{@code YUV / PRIV}</td><td id="rb">{@code DEFAULT}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code JPEG }</td><td id="rb">{@code MAX_RES}</td><td id="rb">{@code MAX}</td> <td> Ultra high res PRIV / YUV -> YUV / JPEG reprocessing with seperate preview</td> </tr>
1174      * </table><br>
1175      * No additional mandatory stream combinations for RAW capability and LEVEL-3 hardware level.
1176      * </p>
1177      *
1178      * <h3>Constrained high-speed recording</h3>
1179      *
1180      * <p>The application can use a
1181      * {@link android.hardware.camera2.params.SessionConfiguration#SESSION_REGULAR
1182      * normal capture session}
1183      * for high speed capture if the desired high speed FPS ranges are advertised by
1184      * {@link CameraCharacteristics#CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES}, in which case all API
1185      * semantics associated with normal capture sessions applies.</p>
1186      *
1187      * <p>A
1188      * {@link android.hardware.camera2.params.SessionConfiguration#SESSION_HIGH_SPEED
1189      * high-speed capture session}
1190      * can be use for high speed video recording (>=120fps) when the camera device supports high
1191      * speed video capability (i.e., {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES}
1192      * contains {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO}).
1193      * A constrained high-speed capture session has special limitations compared with a normal
1194      * capture session:</p>
1195      *
1196      * <ul>
1197      *
1198      * <li>In addition to the output target Surface requirements specified above for regular
1199      *   captures, a high speed capture session will only support up to 2 output Surfaces, though
1200      *   the application might choose to configure just one Surface (e.g., preview only). All
1201      *   Surfaces must be either video encoder surfaces (acquired by
1202      *   {@link android.media.MediaRecorder#getSurface} or
1203      *   {@link android.media.MediaCodec#createInputSurface}) or preview surfaces (obtained from
1204      *   {@link android.view.SurfaceView}, {@link android.graphics.SurfaceTexture} via
1205      *   {@link android.view.Surface#Surface(android.graphics.SurfaceTexture)}). The Surface sizes
1206      *   must be one of the sizes reported by {@link StreamConfigurationMap#getHighSpeedVideoSizes}.
1207      *   When multiple Surfaces are configured, their size must be same.</li>
1208      *
1209      * <li>An active high speed capture session only accepts request lists created via
1210      *   {@link CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList}, and the
1211      *   request list can only be submitted to this session via
1212      *   {@link CameraCaptureSession#captureBurst captureBurst}, or
1213      *   {@link CameraCaptureSession#setRepeatingBurst setRepeatingBurst}.</li>
1214      *
1215      * <li>The FPS ranges being requested to this session must be selected from
1216      *   {@link StreamConfigurationMap#getHighSpeedVideoFpsRangesFor}. The application can still use
1217      *   {@link CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE} to control the desired FPS range.
1218      *   Switching to an FPS range that has different
1219      *   {@link android.util.Range#getUpper() maximum FPS} may trigger some camera device
1220      *   reconfigurations, which may introduce extra latency. It is recommended that the
1221      *   application avoids unnecessary maximum target FPS changes as much as possible during high
1222      *   speed streaming.</li>
1223      *
1224      * <li>For the request lists submitted to this session, the camera device will override the
1225      *   {@link CaptureRequest#CONTROL_MODE control mode}, auto-exposure (AE), auto-white balance
1226      *   (AWB) and auto-focus (AF) to {@link CameraMetadata#CONTROL_MODE_AUTO},
1227      *   {@link CameraMetadata#CONTROL_AE_MODE_ON}, {@link CameraMetadata#CONTROL_AWB_MODE_AUTO}
1228      *   and {@link CameraMetadata#CONTROL_AF_MODE_CONTINUOUS_VIDEO}, respectively. All
1229      *   post-processing block mode controls will be overridden to be FAST. Therefore, no manual
1230      *   control of capture and post-processing parameters is possible. Beside these, only a subset
1231      *   of controls will work, see
1232      *   {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO} for
1233      *   more details.</li>
1234      *
1235      * </ul>
1236      *
1237      *
1238      * @param config A session configuration (see {@link SessionConfiguration}).
1239      *
1240      * @throws IllegalArgumentException In case the session configuration is invalid; or the output
1241      *                                  configurations are empty; or the session configuration
1242      *                                  executor is invalid;
1243      *                                  or the output dynamic range combination is
1244      *                                  invalid/unsupported.
1245      * @throws CameraAccessException In case the camera device is no longer connected or has
1246      *                               encountered a fatal error.
1247      * @see #createCaptureSession(List, CameraCaptureSession.StateCallback, Handler)
1248      * @see #createCaptureSessionByOutputConfigurations
1249      * @see #createReprocessableCaptureSession
1250      * @see #createConstrainedHighSpeedCaptureSession
1251      * @see OutputConfiguration#setDynamicRangeProfile
1252      * @see android.hardware.camera2.params.DynamicRangeProfiles
1253      */
createCaptureSession( SessionConfiguration config)1254     public void createCaptureSession(
1255             SessionConfiguration config) throws CameraAccessException {
1256         throw new UnsupportedOperationException("No default implementation");
1257     }
1258 
1259     /**
1260      * <p>Create a {@link CaptureRequest.Builder} for new capture requests,
1261      * initialized with template for a target use case. The settings are chosen
1262      * to be the best options for the specific camera device, so it is not
1263      * recommended to reuse the same request for a different camera device;
1264      * create a builder specific for that device and template and override the
1265      * settings as desired, instead.</p>
1266      *
1267      * @param templateType An enumeration selecting the use case for this request. Not all template
1268      * types are supported on every device. See the documentation for each template type for
1269      * details.
1270      * @return a builder for a capture request, initialized with default
1271      * settings for that template, and no output streams
1272      *
1273      * @throws IllegalArgumentException if the templateType is not supported by
1274      * this device.
1275      * @throws CameraAccessException if the camera device is no longer connected or has
1276      *                               encountered a fatal error
1277      * @throws IllegalStateException if the camera device has been closed
1278      */
1279     @NonNull
createCaptureRequest(@equestTemplate int templateType)1280     public abstract CaptureRequest.Builder createCaptureRequest(@RequestTemplate int templateType)
1281             throws CameraAccessException;
1282 
1283     /**
1284      * <p>Create a {@link CaptureRequest.Builder} for new capture requests,
1285      * initialized with template for a target use case. This methods allows
1286      * clients to pass physical camera ids which can be used to customize the
1287      * request for a specific physical camera. The settings are chosen
1288      * to be the best options for the specific logical camera device. If
1289      * additional physical camera ids are passed, then they will also use the
1290      * same settings template. Clients can further modify individual camera
1291      * settings by calling {@link CaptureRequest.Builder#setPhysicalCameraKey}.</p>
1292      *
1293      * <p>Individual physical camera settings will only be honored for camera session
1294      * that was initialized with corresponding physical camera id output configuration
1295      * {@link OutputConfiguration#setPhysicalCameraId} and the same output targets are
1296      * also attached in the request by {@link CaptureRequest.Builder#addTarget}.</p>
1297      *
1298      * <p>The output is undefined for any logical camera streams in case valid physical camera
1299      * settings are attached.</p>
1300      *
1301      * @param templateType An enumeration selecting the use case for this request. Not all template
1302      * types are supported on every device. See the documentation for each template type for
1303      * details.
1304      * @param physicalCameraIdSet A set of physical camera ids that can be used to customize
1305      *                            the request for a specific physical camera.
1306      * @return a builder for a capture request, initialized with default
1307      * settings for that template, and no output streams
1308      *
1309      * @throws IllegalArgumentException if the templateType is not supported by
1310      * this device, or one of the physical id arguments matches with logical camera id.
1311      * @throws CameraAccessException if the camera device is no longer connected or has
1312      *                               encountered a fatal error
1313      * @throws IllegalStateException if the camera device has been closed
1314      *
1315      * @see #TEMPLATE_PREVIEW
1316      * @see #TEMPLATE_RECORD
1317      * @see #TEMPLATE_STILL_CAPTURE
1318      * @see #TEMPLATE_VIDEO_SNAPSHOT
1319      * @see #TEMPLATE_MANUAL
1320      * @see CaptureRequest.Builder#setPhysicalCameraKey
1321      * @see CaptureRequest.Builder#getPhysicalCameraKey
1322      */
1323     @NonNull
createCaptureRequest(@equestTemplate int templateType, Set<String> physicalCameraIdSet)1324     public CaptureRequest.Builder createCaptureRequest(@RequestTemplate int templateType,
1325             Set<String> physicalCameraIdSet) throws CameraAccessException {
1326         throw new UnsupportedOperationException("Subclasses must override this method");
1327     }
1328 
1329     /**
1330      * <p>Create a {@link CaptureRequest.Builder} for a new reprocess {@link CaptureRequest} from a
1331      * {@link TotalCaptureResult}.
1332      *
1333      * <p>Each reprocess {@link CaptureRequest} processes one buffer from
1334      * {@link CameraCaptureSession}'s input {@link Surface} to all output {@link Surface Surfaces}
1335      * included in the reprocess capture request. The reprocess input images must be generated from
1336      * one or multiple output images captured from the same camera device. The application can
1337      * provide input images to camera device via {@link android.media.ImageWriter#queueInputImage}.
1338      * The application must use the capture result of one of those output images to create a
1339      * reprocess capture request so that the camera device can use the information to achieve
1340      * optimal reprocess image quality. For camera devices that support only 1 output
1341      * {@link Surface}, submitting a reprocess {@link CaptureRequest} with multiple
1342      * output targets will result in a {@link CaptureFailure}.
1343      *
1344      * From Android 14 onward, {@link CaptureRequest#CONTROL_CAPTURE_INTENT} will be set to
1345      * {@link CameraMetadata#CONTROL_CAPTURE_INTENT_STILL_CAPTURE} by default. Prior to Android 14,
1346      * apps will need to explicitly set this key themselves.
1347      *
1348      * @param inputResult The capture result of the output image or one of the output images used
1349      *                       to generate the reprocess input image for this capture request.
1350      *
1351      * @throws IllegalArgumentException if inputResult is null.
1352      * @throws CameraAccessException if the camera device is no longer connected or has
1353      *                               encountered a fatal error
1354      * @throws IllegalStateException if the camera device has been closed
1355      *
1356      * @see CaptureRequest.Builder
1357      * @see TotalCaptureResult
1358      * @see CameraDevice#createCaptureSession(android.hardware.camera2.params.SessionConfiguration)
1359      * @see android.media.ImageWriter
1360      */
1361     @NonNull
createReprocessCaptureRequest( @onNull TotalCaptureResult inputResult)1362     public abstract CaptureRequest.Builder createReprocessCaptureRequest(
1363             @NonNull TotalCaptureResult inputResult) throws CameraAccessException;
1364 
1365     /**
1366      * Close the connection to this camera device as quickly as possible.
1367      *
1368      * <p>Immediately after this call, all calls to the camera device or active session interface
1369      * will throw a {@link IllegalStateException}, except for calls to close(). Once the device has
1370      * fully shut down, the {@link StateCallback#onClosed} callback will be called, and the camera
1371      * is free to be re-opened.</p>
1372      *
1373      * <p>Immediately after this call, besides the final {@link StateCallback#onClosed} calls, no
1374      * further callbacks from the device or the active session will occur, and any remaining
1375      * submitted capture requests will be discarded, as if
1376      * {@link CameraCaptureSession#abortCaptures} had been called, except that no success or failure
1377      * callbacks will be invoked.</p>
1378      *
1379      */
1380     @Override
close()1381     public abstract void close();
1382 
1383     /**
1384      * Checks whether a particular {@link SessionConfiguration} is supported by the camera device.
1385      *
1386      * <p>This method performs a runtime check of a given {@link SessionConfiguration}. The result
1387      * confirms whether or not the passed session configuration can be successfully used to
1388      * create a camera capture session using
1389      * {@link CameraDevice#createCaptureSession(
1390      * android.hardware.camera2.params.SessionConfiguration)}.
1391      * </p>
1392      *
1393      * <p>The method can be called at any point before, during and after active capture session.
1394      * It must not impact normal camera behavior in any way and must complete significantly
1395      * faster than creating a regular or constrained capture session.</p>
1396      *
1397      * <p>Although this method is faster than creating a new capture session, it is not intended
1398      * to be used for exploring the entire space of supported stream combinations. The available
1399      * mandatory stream combinations
1400      * {@link android.hardware.camera2.params.MandatoryStreamCombination} are better suited for this
1401      * purpose.</p>
1402      *
1403      * <p>Note that session parameters will be ignored and calls to
1404      * {@link SessionConfiguration#setSessionParameters} are not required.</p>
1405      *
1406      * @return {@code true} if the given session configuration is supported by the camera device
1407      *         {@code false} otherwise.
1408      * @throws UnsupportedOperationException if the query operation is not supported by the camera
1409      *                                       device
1410      * @throws IllegalArgumentException if the session configuration is invalid
1411      * @throws CameraAccessException if the camera device is no longer connected or has
1412      *                               encountered a fatal error
1413      * @throws IllegalStateException if the camera device has been closed
1414      */
isSessionConfigurationSupported( @onNull SessionConfiguration sessionConfig)1415     public boolean isSessionConfigurationSupported(
1416             @NonNull SessionConfiguration sessionConfig) throws CameraAccessException {
1417         throw new UnsupportedOperationException("Subclasses must override this method");
1418     }
1419 
1420     /**
1421      * A callback objects for receiving updates about the state of a camera device.
1422      *
1423      * <p>A callback instance must be provided to the {@link CameraManager#openCamera} method to
1424      * open a camera device.</p>
1425      *
1426      * <p>These state updates include notifications about the device completing startup (
1427      * allowing for {@link #createCaptureSession} to be called), about device
1428      * disconnection or closure, and about unexpected device errors.</p>
1429      *
1430      * <p>Events about the progress of specific {@link CaptureRequest CaptureRequests} are provided
1431      * through a {@link CameraCaptureSession.CaptureCallback} given to the
1432      * {@link CameraCaptureSession#capture}, {@link CameraCaptureSession#captureBurst},
1433      * {@link CameraCaptureSession#setRepeatingRequest}, or
1434      * {@link CameraCaptureSession#setRepeatingBurst} methods.
1435      *
1436      * @see CameraManager#openCamera
1437      */
1438     public static abstract class StateCallback {
1439        /**
1440          * An error code that can be reported by {@link #onError}
1441          * indicating that the camera device is in use already.
1442          *
1443          * <p>
1444          * This error can be produced when opening the camera fails due to the camera
1445         *  being used by a higher-priority camera API client.
1446          * </p>
1447          *
1448          * @see #onError
1449          */
1450         public static final int ERROR_CAMERA_IN_USE = 1;
1451 
1452         /**
1453          * An error code that can be reported by {@link #onError}
1454          * indicating that the camera device could not be opened
1455          * because there are too many other open camera devices.
1456          *
1457          * <p>
1458          * The system-wide limit for number of open cameras has been reached,
1459          * and more camera devices cannot be opened until previous instances are
1460          * closed.
1461          * </p>
1462          *
1463          * <p>
1464          * This error can be produced when opening the camera fails.
1465          * </p>
1466          *
1467          * @see #onError
1468          */
1469         public static final int ERROR_MAX_CAMERAS_IN_USE = 2;
1470 
1471         /**
1472          * An error code that can be reported by {@link #onError}
1473          * indicating that the camera device could not be opened due to a device
1474          * policy.
1475          *
1476          * @see android.app.admin.DevicePolicyManager#setCameraDisabled(android.content.ComponentName, boolean)
1477          * @see #onError
1478          */
1479         public static final int ERROR_CAMERA_DISABLED = 3;
1480 
1481        /**
1482          * An error code that can be reported by {@link #onError}
1483          * indicating that the camera device has encountered a fatal error.
1484          *
1485          * <p>The camera device needs to be re-opened to be used again.</p>
1486          *
1487          * @see #onError
1488          */
1489         public static final int ERROR_CAMERA_DEVICE = 4;
1490 
1491         /**
1492          * An error code that can be reported by {@link #onError}
1493          * indicating that the camera service has encountered a fatal error.
1494          *
1495          * <p>The Android device may need to be shut down and restarted to restore
1496          * camera function, or there may be a persistent hardware problem.</p>
1497          *
1498          * <p>An attempt at recovery <i>may</i> be possible by closing the
1499          * CameraDevice and the CameraManager, and trying to acquire all resources
1500          * again from scratch.</p>
1501          *
1502          * @see #onError
1503          */
1504         public static final int ERROR_CAMERA_SERVICE = 5;
1505 
1506         /** @hide */
1507         @Retention(RetentionPolicy.SOURCE)
1508         @IntDef(prefix = {"ERROR_"}, value =
1509             {ERROR_CAMERA_IN_USE,
1510              ERROR_MAX_CAMERAS_IN_USE,
1511              ERROR_CAMERA_DISABLED,
1512              ERROR_CAMERA_DEVICE,
1513              ERROR_CAMERA_SERVICE })
1514         public @interface ErrorCode {};
1515 
1516         /**
1517          * The method called when a camera device has finished opening.
1518          *
1519          * <p>At this point, the camera device is ready to use, and
1520          * {@link CameraDevice#createCaptureSession} can be called to set up the first capture
1521          * session.</p>
1522          *
1523          * @param camera the camera device that has become opened
1524          */
onOpened(@onNull CameraDevice camera)1525         public abstract void onOpened(@NonNull CameraDevice camera); // Must implement
1526 
1527         /**
1528          * The method called when a camera device has been closed with
1529          * {@link CameraDevice#close}.
1530          *
1531          * <p>Any attempt to call methods on this CameraDevice in the
1532          * future will throw a {@link IllegalStateException}.</p>
1533          *
1534          * <p>The default implementation of this method does nothing.</p>
1535          *
1536          * @param camera the camera device that has become closed
1537          */
onClosed(@onNull CameraDevice camera)1538         public void onClosed(@NonNull CameraDevice camera) {
1539             // Default empty implementation
1540         }
1541 
1542         /**
1543          * The method called when a camera device is no longer available for
1544          * use.
1545          *
1546          * <p>This callback may be called instead of {@link #onOpened}
1547          * if opening the camera fails.</p>
1548          *
1549          * <p>Any attempt to call methods on this CameraDevice will throw a
1550          * {@link CameraAccessException}. The disconnection could be due to a
1551          * change in security policy or permissions; the physical disconnection
1552          * of a removable camera device; or the camera being needed for a
1553          * higher-priority camera API client.</p>
1554          *
1555          * <p>There may still be capture callbacks that are invoked
1556          * after this method is called, or new image buffers that are delivered
1557          * to active outputs.</p>
1558          *
1559          * <p>The default implementation logs a notice to the system log
1560          * about the disconnection.</p>
1561          *
1562          * <p>You should clean up the camera with {@link CameraDevice#close} after
1563          * this happens, as it is not recoverable until the camera can be opened
1564          * again. For most use cases, this will be when the camera again becomes
1565          * {@link CameraManager.AvailabilityCallback#onCameraAvailable available}.
1566          * </p>
1567          *
1568          * @param camera the device that has been disconnected
1569          */
onDisconnected(@onNull CameraDevice camera)1570         public abstract void onDisconnected(@NonNull CameraDevice camera); // Must implement
1571 
1572         /**
1573          * The method called when a camera device has encountered a serious error.
1574          *
1575          * <p>This callback may be called instead of {@link #onOpened}
1576          * if opening the camera fails.</p>
1577          *
1578          * <p>This indicates a failure of the camera device or camera service in
1579          * some way. Any attempt to call methods on this CameraDevice in the
1580          * future will throw a {@link CameraAccessException} with the
1581          * {@link CameraAccessException#CAMERA_ERROR CAMERA_ERROR} reason.
1582          * </p>
1583          *
1584          * <p>There may still be capture completion or camera stream callbacks
1585          * that will be called after this error is received.</p>
1586          *
1587          * <p>You should clean up the camera with {@link CameraDevice#close} after
1588          * this happens. Further attempts at recovery are error-code specific.</p>
1589          *
1590          * @param camera The device reporting the error
1591          * @param error The error code.
1592          *
1593          * @see #ERROR_CAMERA_IN_USE
1594          * @see #ERROR_MAX_CAMERAS_IN_USE
1595          * @see #ERROR_CAMERA_DISABLED
1596          * @see #ERROR_CAMERA_DEVICE
1597          * @see #ERROR_CAMERA_SERVICE
1598          */
onError(@onNull CameraDevice camera, @ErrorCode int error)1599         public abstract void onError(@NonNull CameraDevice camera,
1600                 @ErrorCode int error); // Must implement
1601     }
1602 
1603     /**
1604      * Set audio restriction mode when this CameraDevice is being used.
1605      *
1606      * <p>Some camera hardware (e.g. devices with optical image stabilization support)
1607      * are sensitive to device vibration and video recordings can be ruined by unexpected sounds.
1608      * Applications can use this method to suppress vibration or sounds coming from
1609      * ringtones, alarms or notifications.
1610      * Other vibration or sounds (e.g. media playback or accessibility) will not be muted.</p>
1611      *
1612      * <p>The mute mode is a system-wide setting. When multiple CameraDevice objects
1613      * are setting different modes, the system will pick a the mode that's union of
1614      * all modes set by CameraDevice. Applications can also use
1615      * {@link #getCameraAudioRestriction} to query current system-wide camera
1616      * mute mode in effect.</p>
1617      *
1618      * <p>The mute settings from this CameraDevice will be automatically removed when the
1619      * CameraDevice is closed or the application is disconnected from the camera.</p>
1620      *
1621      * @param mode An enumeration selecting the audio restriction mode for this camera device.
1622      *
1623      * @throws IllegalArgumentException if the mode is not supported
1624      *
1625      * @throws CameraAccessException if the camera device is no longer connected or has
1626      *                               encountered a fatal error
1627      * @throws IllegalStateException if the camera device has been closed
1628      *
1629      * @see #getCameraAudioRestriction
1630      */
setCameraAudioRestriction( @AMERA_AUDIO_RESTRICTION int mode)1631     public void setCameraAudioRestriction(
1632             @CAMERA_AUDIO_RESTRICTION int mode) throws CameraAccessException {
1633         throw new UnsupportedOperationException("Subclasses must override this method");
1634     }
1635 
1636     /**
1637      * Get currently applied global camera audio restriction mode.
1638      *
1639      * <p>Application can use this method to retrieve the system-wide camera audio restriction
1640      * settings described in {@link #setCameraAudioRestriction}.</p>
1641      *
1642      * @return The current system-wide mute mode setting in effect
1643      *
1644      * @throws CameraAccessException if the camera device is no longer connected or has
1645      *                               encountered a fatal error
1646      * @throws IllegalStateException if the camera device has been closed
1647      *
1648      * @see #setCameraAudioRestriction
1649      */
getCameraAudioRestriction()1650     public @CAMERA_AUDIO_RESTRICTION int getCameraAudioRestriction() throws CameraAccessException {
1651         throw new UnsupportedOperationException("Subclasses must override this method");
1652     }
1653 
1654     /**
1655      * To be inherited by android.hardware.camera2.* code only.
1656      * @hide
1657      */
CameraDevice()1658     public CameraDevice() {}
1659 }
1660