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