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