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