1b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala/* 2b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * Copyright (C) 2013 The Android Open Source Project 3b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 4b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * Licensed under the Apache License, Version 2.0 (the "License"); 5b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * you may not use this file except in compliance with the License. 6b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * You may obtain a copy of the License at 7b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 8b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * http://www.apache.org/licenses/LICENSE-2.0 9b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 10b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * Unless required by applicable law or agreed to in writing, software 11b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * distributed under the License is distributed on an "AS IS" BASIS, 12b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * See the License for the specific language governing permissions and 14b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * limitations under the License. 15b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 16b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 172f1a2e423e0fbb64467d6fcfa4e82c6384f31210Eino-Ville Talvalapackage android.hardware.camera2; 18b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 199c595174ccaaf3d36315c4a100e47ee4369073f6Igor Murashkinimport android.hardware.camera2.params.StreamConfigurationMap; 209c595174ccaaf3d36315c4a100e47ee4369073f6Igor Murashkinimport android.graphics.ImageFormat; 214af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvalaimport android.os.Handler; 22599be6182e1a8f647f02d02ed99d16a74db2a4c6Zhijun Heimport android.view.Surface; 23b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 24b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvalaimport java.util.List; 25b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 26b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala/** 2721547d66a9ce591ff30a3ad4102f7f30a4764d80Igor Murashkin * <p>The CameraDevice class is a representation of a single camera connected to an 28b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * Android device, allowing for fine-grain control of image capture and 29b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * post-processing at high frame rates.</p> 30b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 31b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * <p>Your application must declare the 32b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * {@link android.Manifest.permission#CAMERA Camera} permission in its manifest 33b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * in order to access camera devices.</p> 34b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 35b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * <p>A given camera device may provide support at one of two levels: limited or 36b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * full. If a device only supports the limited level, then Camera2 exposes a 37b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * feature set that is roughly equivalent to the older 38b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * {@link android.hardware.Camera Camera} API, although with a cleaner and more 39b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * efficient interface. Devices that implement the full level of support 40b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * provide substantially improved capabilities over the older camera 41b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * API. Applications that target the limited level devices will run unchanged on 42b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * the full-level devices; if your application requires a full-level device for 43b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * proper operation, declare the "android.hardware.camera2.full" feature in your 44b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * manifest.</p> 45b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 46b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @see CameraManager#openCamera 47b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @see android.Manifest.permission#CAMERA 48b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 4921547d66a9ce591ff30a3ad4102f7f30a4764d80Igor Murashkinpublic abstract class CameraDevice implements AutoCloseable { 50b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 51b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala /** 52b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * Create a request suitable for a camera preview window. Specifically, this 53b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * means that high frame rate is given priority over the highest-quality 54b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * post-processing. These requests would normally be used with the 55b67a3b36fd569e63c1b8ca6b2701c34c7a3927c1Eino-Ville Talvala * {@link CameraCaptureSession#setRepeatingRequest} method. 56b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 57b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @see #createCaptureRequest 58b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 59b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala public static final int TEMPLATE_PREVIEW = 1; 60b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 61b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala /** 62b8b77bf59ed377d6a9bcd80b8dbe4e146d5fddd3Zhijun He * Create a request suitable for still image capture. Specifically, this 63b8b77bf59ed377d6a9bcd80b8dbe4e146d5fddd3Zhijun He * means prioritizing image quality over frame rate. These requests would 64b67a3b36fd569e63c1b8ca6b2701c34c7a3927c1Eino-Ville Talvala * commonly be used with the {@link CameraCaptureSession#capture} method. 65b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 66b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @see #createCaptureRequest 67b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 68b8b77bf59ed377d6a9bcd80b8dbe4e146d5fddd3Zhijun He public static final int TEMPLATE_STILL_CAPTURE = 2; 69b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 70b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala /** 71b8b77bf59ed377d6a9bcd80b8dbe4e146d5fddd3Zhijun He * Create a request suitable for video recording. Specifically, this means 72b8b77bf59ed377d6a9bcd80b8dbe4e146d5fddd3Zhijun He * that a stable frame rate is used, and post-processing is set for 73b8b77bf59ed377d6a9bcd80b8dbe4e146d5fddd3Zhijun He * recording quality. These requests would commonly be used with the 74b67a3b36fd569e63c1b8ca6b2701c34c7a3927c1Eino-Ville Talvala * {@link CameraCaptureSession#setRepeatingRequest} method. 75b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 76b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @see #createCaptureRequest 77b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 78b8b77bf59ed377d6a9bcd80b8dbe4e146d5fddd3Zhijun He public static final int TEMPLATE_RECORD = 3; 79b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 80b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala /** 81b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * Create a request suitable for still image capture while recording 82b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * video. Specifically, this means maximizing image quality without 83b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * disrupting the ongoing recording. These requests would commonly be used 84b67a3b36fd569e63c1b8ca6b2701c34c7a3927c1Eino-Ville Talvala * with the {@link CameraCaptureSession#capture} method while a request based on 85b67a3b36fd569e63c1b8ca6b2701c34c7a3927c1Eino-Ville Talvala * {@link #TEMPLATE_RECORD} is is in use with {@link CameraCaptureSession#setRepeatingRequest}. 86b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 87b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @see #createCaptureRequest 88b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 89b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala public static final int TEMPLATE_VIDEO_SNAPSHOT = 4; 90b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 91b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala /** 92bbae94a02e73020646535b0d915f4557c39f357bZhijun He * Create a request suitable for zero shutter lag still capture. This means 93bbae94a02e73020646535b0d915f4557c39f357bZhijun He * means maximizing image quality without compromising preview frame rate. 94bbae94a02e73020646535b0d915f4557c39f357bZhijun He * AE/AWB/AF should be on auto mode. 95bbae94a02e73020646535b0d915f4557c39f357bZhijun He * 96bbae94a02e73020646535b0d915f4557c39f357bZhijun He * @see #createCaptureRequest 97bbae94a02e73020646535b0d915f4557c39f357bZhijun He */ 98bbae94a02e73020646535b0d915f4557c39f357bZhijun He public static final int TEMPLATE_ZERO_SHUTTER_LAG = 5; 99bbae94a02e73020646535b0d915f4557c39f357bZhijun He 100bbae94a02e73020646535b0d915f4557c39f357bZhijun He /** 101b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * A basic template for direct application control of capture 102b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * parameters. All automatic control is disabled (auto-exposure, auto-white 103b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * balance, auto-focus), and post-processing parameters are set to preview 104b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * quality. The manual capture parameters (exposure, sensitivity, and so on) 105b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * are set to reasonable defaults, but should be overriden by the 106b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * application depending on the intended use case. 107b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 108b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @see #createCaptureRequest 109b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 110bbae94a02e73020646535b0d915f4557c39f357bZhijun He public static final int TEMPLATE_MANUAL = 6; 111b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 112b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala /** 1134af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * Get the ID of this camera device. 1144af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 1154af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * <p>This matches the ID given to {@link CameraManager#openCamera} to instantiate this 1164af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * this camera device.</p> 1174af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 1184af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * <p>This ID can be used to query the camera device's {@link 11968f40066c914aefc1f88819dd46dd1135fb9f5bcIgor Murashkin * CameraCharacteristics fixed properties} with {@link 12068f40066c914aefc1f88819dd46dd1135fb9f5bcIgor Murashkin * CameraManager#getCameraCharacteristics}.</p> 1214af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 1224af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * <p>This method can be called even if the device has been closed or has encountered 1234af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * a serious error.</p> 1244af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 1254af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * @return the ID for this camera device 1264af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 12768f40066c914aefc1f88819dd46dd1135fb9f5bcIgor Murashkin * @see CameraManager#getCameraCharacteristics 128599be6182e1a8f647f02d02ed99d16a74db2a4c6Zhijun He * @see CameraManager#getCameraIdList 1294af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala */ 13021547d66a9ce591ff30a3ad4102f7f30a4764d80Igor Murashkin public abstract String getId(); 1314af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala 1324af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala /** 133cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * <p>Create a new camera capture session by providing the target output set of Surfaces to the 134cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * camera device.</p> 135cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 136cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * <p>The active capture session determines the set of potential output Surfaces for 137cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * the camera device for each capture request. A given request may use all 138cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * or a only some of the outputs. Once the CameraCaptureSession is created, requests can be 139cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * can be submitted with {@link CameraCaptureSession#capture capture}, 140cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * {@link CameraCaptureSession#captureBurst captureBurst}, 141cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * {@link CameraCaptureSession#setRepeatingRequest setRepeatingRequest}, or 142cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * {@link CameraCaptureSession#setRepeatingBurst setRepeatingBurst}.</p> 143cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 144cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * <p>Surfaces suitable for inclusion as a camera output can be created for 145cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * various use cases and targets:</p> 146cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 147cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * <ul> 148cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 1495ae1ca5b6932b27f8d3d5a3b4a124fe2b5b84e27Eino-Ville Talvala * <li>For drawing to a {@link android.view.SurfaceView SurfaceView}: Once the SurfaceView's 150fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * Surface is {@link android.view.SurfaceHolder.Callback#surfaceCreated created}, set the size 151fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * of the Surface with {@link android.view.SurfaceHolder#setFixedSize} to be one of the sizes 152fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * returned by {@link StreamConfigurationMap#getOutputSizes(Class) 153fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * getOutputSizes(SurfaceHolder.class)} and then obtain the Surface by calling {@link 154fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * android.view.SurfaceHolder#getSurface}. If the size is not set by the application, it will 155fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * be rounded to the nearest supported size less than 1080p, by the camera device.</li> 156fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * 157fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * <li>For accessing through an OpenGL texture via a {@link android.graphics.SurfaceTexture 158fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * SurfaceTexture}: Set the size of the SurfaceTexture with {@link 159fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * android.graphics.SurfaceTexture#setDefaultBufferSize} to be one of the sizes returned by 160cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(SurfaceTexture.class)} 161fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * before creating a Surface from the SurfaceTexture with {@link Surface#Surface}. If the size 162fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * is not set by the application, it will be set to be the smallest supported size less than 163fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * 1080p, by the camera device.</li> 164cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 165cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * <li>For recording with {@link android.media.MediaCodec}: Call 166cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * {@link android.media.MediaCodec#createInputSurface} after configuring 167cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * the media codec to use one of the sizes returned by 168cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(MediaCodec.class)} 169cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * </li> 170cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 171cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * <li>For recording with {@link android.media.MediaRecorder}: Call 172cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * {@link android.media.MediaRecorder#getSurface} after configuring the media recorder to use 173cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * one of the sizes returned by 174cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(MediaRecorder.class)}, 175cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * or configuring it to use one of the supported 176cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * {@link android.media.CamcorderProfile CamcorderProfiles}.</li> 177cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 178cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * <li>For efficient YUV processing with {@link android.renderscript}: 179cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * Create a RenderScript 180cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * {@link android.renderscript.Allocation Allocation} with a supported YUV 181cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * type, the IO_INPUT flag, and one of the sizes returned by 182cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(Allocation.class)}, 183cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * Then obtain the Surface with 184cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * {@link android.renderscript.Allocation#getSurface}.</li> 185cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 186b8cee5175d7cbc4901bd2d56aa6a380b1464a074Sol Boucher * <li>For access to raw, uncompressed JPEG data in the application: Create an 187b8cee5175d7cbc4901bd2d56aa6a380b1464a074Sol Boucher * {@link android.media.ImageReader} object with one of the supported output formats given by 188b8cee5175d7cbc4901bd2d56aa6a380b1464a074Sol Boucher * {@link StreamConfigurationMap#getOutputFormats()}, setting its size to one of the 189b8cee5175d7cbc4901bd2d56aa6a380b1464a074Sol Boucher * corresponding supported sizes by passing the chosen output format into 190b8cee5175d7cbc4901bd2d56aa6a380b1464a074Sol Boucher * {@link StreamConfigurationMap#getOutputSizes(int)}. Then obtain a 191b8cee5175d7cbc4901bd2d56aa6a380b1464a074Sol Boucher * {@link android.view.Surface} from it with {@link android.media.ImageReader#getSurface()}. 192fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * If the ImageReader size is not set to a supported size, it will be rounded to a supported 193fa0b9a00b48394bd9b7e5d54b2b4a5a33d7bd186Eino-Ville Talvala * size less than 1080p by the camera device. 194b8cee5175d7cbc4901bd2d56aa6a380b1464a074Sol Boucher * </li> 195cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 196cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * </ul> 197cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 198cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * <p>The camera device will query each Surface's size and formats upon this 199b8cee5175d7cbc4901bd2d56aa6a380b1464a074Sol Boucher * call, so they must be set to a valid setting at this time.</p> 200cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 201cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * <p>It can take several hundred milliseconds for the session's configuration to complete, 202cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * since camera hardware may need to be powered on or reconfigured. Once the configuration is 203cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * complete and the session is ready to actually capture data, the provided 204fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * {@link CameraCaptureSession.StateCallback}'s 205fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * {@link CameraCaptureSession.StateCallback#onConfigured} callback will be called.</p> 206cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 207cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * <p>If a prior CameraCaptureSession already exists when a new one is created, the previous 208cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * session is closed. Any in-progress capture requests made on the prior session will be 209cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * completed before the new session is configured and is able to start capturing its own 210cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * requests. To minimize the transition time, the {@link CameraCaptureSession#abortCaptures} 211cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * call can be used to discard the remaining requests for the prior capture session before a new 212cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * one is created. Note that once the new session is created, the old one can no longer have its 213cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * captures aborted.</p> 214cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 215cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * <p>Using larger resolution outputs, or more outputs, can result in slower 216cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * output rate from the device.</p> 217cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 218cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * <p>Configuring a session with an empty or null list will close the current session, if 219cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * any. This can be used to release the current session's target surfaces for another use.</p> 220cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 221f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <p>While any of the sizes from {@link StreamConfigurationMap#getOutputSizes} can be used when 222f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * a single output stream is configured, a given camera device may not be able to support all 223f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * combination of sizes, formats, and targets when multiple outputs are configured at once. The 224f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * tables below list the maximum guaranteed resolutions for combinations of streams and targets, 225f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * given the capabilities of the camera device.</p> 226f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 227f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <p>If an application tries to create a session using a set of targets that exceed the limits 228f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * described in the below tables, one of three possibilities may occur. First, the session may 229f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * be successfully created and work normally. Second, the session may be successfully created, 230f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * but the camera device won't meet the frame rate guarantees as described in 231f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@link StreamConfigurationMap#getOutputMinFrameDuration}. Or third, if the output set 232f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * cannot be used at all, session creation will fail entirely, with 233f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@link CameraCaptureSession.StateListener#onConfigureFailed} being invoked.</p> 234f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 235f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <p>For the type column, {@code PRIV} refers to any target whose available sizes are found 236f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * using {@link StreamConfigurationMap#getOutputSizes(Class)} with no direct application-visible 237f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * format, {@code YUV} refers to a target Surface using the 238f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@link android.graphics.ImageFormat#YUV_420_888} format, {@code JPEG} refers to the 239f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@link android.graphics.ImageFormat#JPEG} format, and {@code RAW} refers to the 240f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@link android.graphics.ImageFormat#RAW_SENSOR} format.</p> 241f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 242f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <p>For the maximum size column, {@code PREVIEW} refers to the best size match to the 243f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * device's screen resolution, or to 1080p ({@code 1920x1080}), whichever is 244f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * smaller. {@code RECORD} refers to the camera device's maximum supported recording resolution, 245f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * as determined by {@link android.media.CamcorderProfile}. And {@code MAXIMUM} refers to the 246f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * camera device's maximum output resolution for that format or target from 247f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@link StreamConfigurationMap#getOutputSizes}.</p> 248f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 249f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <p>To use these tables, determine the number and the formats/targets of outputs needed, and 250f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * find the row(s) of the table with those targets. The sizes indicate the maximum set of sizes 251f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * that can be used; it is guaranteed that for those targets, the listed sizes and anything 252f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * smaller from the list given by {@link StreamConfigurationMap#getOutputSizes} can be 253f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * successfully used to create a session. For example, if a row indicates that a 8 megapixel 254f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * (MP) YUV_420_888 output can be used together with a 2 MP {@code PRIV} output, then a session 255f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * can be created with targets {@code [8 MP YUV, 2 MP PRIV]} or targets {@code [2 MP YUV, 2 MP 256f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * PRIV]}; but a session with targets {@code [8 MP YUV, 4 MP PRIV]}, targets {@code [4 MP YUV, 4 257f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * MP PRIV]}, or targets {@code [8 MP PRIV, 2 MP YUV]} would not be guaranteed to work, unless 258f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * some other row of the table lists such a combination.</p> 259f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 260f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <style scoped> 261f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * #rb { border-right-width: thick; } 262f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * </style> 263f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <p>Legacy devices ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL} 264f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY}) support at 265f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * least the following stream combinations: 266f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 267f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <table> 268f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <tr><th colspan="7">LEGACY-level guaranteed configurations</th></tr> 269f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 270f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 271f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 272f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 273f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 274f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 275f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 276f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 277f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 278f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 279f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * </table><br> 280f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * </p> 281f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 282f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <p>Limited-capability ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL} 283f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED}) devices 284f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * support at least the following stream combinations in addition to those for 285f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY} devices: 286f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 287f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <table> 288f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <tr><th colspan="7">LIMITED-level additional guaranteed configurations</th></tr> 289f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 290f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 291f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 292f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 293f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 294f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 295f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 296f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 297f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * </table><br> 298f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * </p> 299f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 300f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <p>FULL-capability ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL} 301f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) devices 302f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * support at least the following stream combinations in addition to those for 303f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices: 304f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 305f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <table> 306f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <tr><th colspan="7">FULL-capability additional guaranteed configurations</th></tr> 307f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 308f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 309f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 310f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 311f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 312f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 313f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 314f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 315f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * </table><br> 316f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * </p> 317f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 318f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <p>RAW-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes 319f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}) devices additionally support 320f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * at least the following stream combinations on both 321f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} and 322f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices: 323f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 324f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <table> 325f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <tr><th colspan="7">RAW-capability additional guaranteed configurations</th></tr> 326f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 327f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 328f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 329f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 330f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 331f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 332f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 333f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 334f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 335f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <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> 336f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * </table><br> 337f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * </p> 338f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 339126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * <p>BURST-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes 340126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE BURST_CAPTURE}) devices 341126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * support at least the below stream combinations in addition to those for 342126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices. Note that all 343126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * FULL-level devices support the BURST capability, and the below list is a strict subset of the 344126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * list for FULL-level devices, so this table is only relevant for LIMITED-level devices that 345126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * support the BURST_CAPTURE capability. 346126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * 347126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * <table> 348126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * <tr><th colspan="5">BURST-capability additional guaranteed configurations</th></tr> 349126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * <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> 350126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th> </tr> 351126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * <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> 352126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * <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> 353126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * <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> 354126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * </table><br> 355126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * </p> 356126a7468c2b86f27779443f5f2578a03f3ad78e8Eino-Ville Talvala * 357f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * <p>Since the capabilities of camera devices vary greatly, a given camera device may support 358f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * target combinations with sizes outside of these guarantees, but this can only be tested for 359f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * by attempting to create a session with such targets.</p> 360f3621f3a5c5fd16ebedd3ce1ae1b0100d0f64152Eino-Ville Talvala * 361cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * @param outputs The new set of Surfaces that should be made available as 362cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * targets for captured image data. 363fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * @param callback The callback to notify about the status of the new capture session. 364fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * @param handler The handler on which the callback should be invoked, or {@code null} to use 365cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * the current thread's {@link android.os.Looper looper}. 366b67a3b36fd569e63c1b8ca6b2701c34c7a3927c1Eino-Ville Talvala * 367cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * @throws IllegalArgumentException if the set of output Surfaces do not meet the requirements, 368fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * the callback is null, or the handler is null but the current 369cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * thread has no looper. 370cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * @throws CameraAccessException if the camera device is no longer connected or has 371cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * encountered a fatal error 372cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * @throws IllegalStateException if the camera device has been closed 373cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * 374cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * @see CameraCaptureSession 375cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * @see StreamConfigurationMap#getOutputFormats() 376cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * @see StreamConfigurationMap#getOutputSizes(int) 377cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * @see StreamConfigurationMap#getOutputSizes(Class) 378cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala */ 37921547d66a9ce591ff30a3ad4102f7f30a4764d80Igor Murashkin public abstract void createCaptureSession(List<Surface> outputs, 380fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala CameraCaptureSession.StateCallback callback, Handler handler) 381cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala throws CameraAccessException; 382cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala 383cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala /** 38470c2207c34cf0e6b3b383b1b1500ff5385aa51a6Eino-Ville Talvala * <p>Create a {@link CaptureRequest.Builder} for new capture requests, 38570c2207c34cf0e6b3b383b1b1500ff5385aa51a6Eino-Ville Talvala * initialized with template for a target use case. The settings are chosen 38670c2207c34cf0e6b3b383b1b1500ff5385aa51a6Eino-Ville Talvala * to be the best options for the specific camera device, so it is not 38770c2207c34cf0e6b3b383b1b1500ff5385aa51a6Eino-Ville Talvala * recommended to reuse the same request for a different camera device; 38870c2207c34cf0e6b3b383b1b1500ff5385aa51a6Eino-Ville Talvala * create a builder specific for that device and template and override the 38970c2207c34cf0e6b3b383b1b1500ff5385aa51a6Eino-Ville Talvala * settings as desired, instead.</p> 390b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 391b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @param templateType An enumeration selecting the use case for this 392b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * request; one of the CameraDevice.TEMPLATE_ values. 39370c2207c34cf0e6b3b383b1b1500ff5385aa51a6Eino-Ville Talvala * @return a builder for a capture request, initialized with default 39470c2207c34cf0e6b3b383b1b1500ff5385aa51a6Eino-Ville Talvala * settings for that template, and no output streams 395b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 396b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @throws IllegalArgumentException if the templateType is not in the list 397b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * of supported templates. 3985c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * @throws CameraAccessException if the camera device is no longer connected or has 3995c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * encountered a fatal error 4005c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * @throws IllegalStateException if the camera device has been closed 401b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 402b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @see #TEMPLATE_PREVIEW 403b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @see #TEMPLATE_RECORD 404b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @see #TEMPLATE_STILL_CAPTURE 405b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @see #TEMPLATE_VIDEO_SNAPSHOT 406b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @see #TEMPLATE_MANUAL 407b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 40821547d66a9ce591ff30a3ad4102f7f30a4764d80Igor Murashkin public abstract CaptureRequest.Builder createCaptureRequest(int templateType) 40970725500dcf3b666b43d50563d64705aab58d2d3Igor Murashkin throws CameraAccessException; 410b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 411b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala /** 412cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * Close the connection to this camera device as quickly as possible. 413868d904306c6a96d94fa0da03515c51c86eefc63Eino-Ville Talvala * 414cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * <p>Immediately after this call, all calls to the camera device or active session interface 415cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * will throw a {@link IllegalStateException}, except for calls to close(). Once the device has 416fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * fully shut down, the {@link StateCallback#onClosed} callback will be called, and the camera 417cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * is free to be re-opened.</p> 418868d904306c6a96d94fa0da03515c51c86eefc63Eino-Ville Talvala * 419fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * <p>Immediately after this call, besides the final {@link StateCallback#onClosed} calls, no 420cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * further callbacks from the device or the active session will occur, and any remaining 421cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * submitted capture requests will be discarded, as if 422cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * {@link CameraCaptureSession#abortCaptures} had been called, except that no success or failure 423cca00c614c24a71dc234c79ad6241efa9f6c7676Eino-Ville Talvala * callbacks will be invoked.</p> 424868d904306c6a96d94fa0da03515c51c86eefc63Eino-Ville Talvala * 425b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 426e363fbb2647aeb5ef4c87160d84c6b9ae8d45598Igor Murashkin @Override 42721547d66a9ce591ff30a3ad4102f7f30a4764d80Igor Murashkin public abstract void close(); 428b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 429b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala /** 430fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * A callback objects for receiving updates about the state of a camera device. 4314af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 432fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * <p>A callback instance must be provided to the {@link CameraManager#openCamera} method to 433fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * open a camera device.</p> 434868d904306c6a96d94fa0da03515c51c86eefc63Eino-Ville Talvala * 435fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * <p>These state updates include notifications about the device completing startup ( 436b67a3b36fd569e63c1b8ca6b2701c34c7a3927c1Eino-Ville Talvala * allowing for {@link #createCaptureSession} to be called), about device 437b67a3b36fd569e63c1b8ca6b2701c34c7a3927c1Eino-Ville Talvala * disconnection or closure, and about unexpected device errors.</p> 4384af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 439b67a3b36fd569e63c1b8ca6b2701c34c7a3927c1Eino-Ville Talvala * <p>Events about the progress of specific {@link CaptureRequest CaptureRequests} are provided 440fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * through a {@link CameraCaptureSession.CaptureCallback} given to the 441b67a3b36fd569e63c1b8ca6b2701c34c7a3927c1Eino-Ville Talvala * {@link CameraCaptureSession#capture}, {@link CameraCaptureSession#captureBurst}, 442fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * {@link CameraCaptureSession#setRepeatingRequest}, or 443fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * {@link CameraCaptureSession#setRepeatingBurst} methods. 4444af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 445868d904306c6a96d94fa0da03515c51c86eefc63Eino-Ville Talvala * @see CameraManager#openCamera 446b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 447fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala public static abstract class StateCallback { 4485c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin /** 4495c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * An error code that can be reported by {@link #onError} 4505c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * indicating that the camera device is in use already. 4515c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 4525c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * <p> 4535c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * This error can be produced when opening the camera fails. 4545c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * </p> 4555c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 4565c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * @see #onError 4575c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin */ 4585c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin public static final int ERROR_CAMERA_IN_USE = 1; 4594af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala 460b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala /** 4615c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * An error code that can be reported by {@link #onError} 4625c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * indicating that the camera device could not be opened 4635c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * because there are too many other open camera devices. 4645c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 4655c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * <p> 4665c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * The system-wide limit for number of open cameras has been reached, 4675c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * and more camera devices cannot be opened until previous instances are 4685c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * closed. 4695c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * </p> 4705c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 4715c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * <p> 4725c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * This error can be produced when opening the camera fails. 4735c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * </p> 4745c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 4755c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * @see #onError 4765c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin */ 4775c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin public static final int ERROR_MAX_CAMERAS_IN_USE = 2; 4785c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin 4795c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin /** 4805c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * An error code that can be reported by {@link #onError} 4815c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * indicating that the camera device could not be opened due to a device 4825c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * policy. 4835c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 4845c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * @see android.app.admin.DevicePolicyManager#setCameraDisabled(android.content.ComponentName, boolean) 4855c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * @see #onError 4865c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin */ 4875c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin public static final int ERROR_CAMERA_DISABLED = 3; 4885c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin 4895c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin /** 4905c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * An error code that can be reported by {@link #onError} 4914af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * indicating that the camera device has encountered a fatal error. 492b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 4934af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * <p>The camera device needs to be re-opened to be used again.</p> 4944af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 4955c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * @see #onError 496b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 4975c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin public static final int ERROR_CAMERA_DEVICE = 4; 498b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 499b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala /** 5005c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * An error code that can be reported by {@link #onError} 5014af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * indicating that the camera service has encountered a fatal error. 502b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 5034af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * <p>The Android device may need to be shut down and restarted to restore 5044af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * camera function, or there may be a persistent hardware problem.</p> 505b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 5065c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * <p>An attempt at recovery <i>may</i> be possible by closing the 5075c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * CameraDevice and the CameraManager, and trying to acquire all resources 5085c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * again from scratch.</p> 5095c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 5105c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * @see #onError 5115c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin */ 5125c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin public static final int ERROR_CAMERA_SERVICE = 5; 5135c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin 5145c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin /** 5155c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * The method called when a camera device has finished opening. 5165c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 517b67a3b36fd569e63c1b8ca6b2701c34c7a3927c1Eino-Ville Talvala * <p>At this point, the camera device is ready to use, and 518b67a3b36fd569e63c1b8ca6b2701c34c7a3927c1Eino-Ville Talvala * {@link CameraDevice#createCaptureSession} can be called to set up the first capture 519b67a3b36fd569e63c1b8ca6b2701c34c7a3927c1Eino-Ville Talvala * session.</p> 5205c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 5215c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * @param camera the camera device that has become opened 5225c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin */ 5235c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin public abstract void onOpened(CameraDevice camera); // Must implement 5245c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin 5255c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin /** 5265c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * The method called when a camera device has been closed with 5275c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * {@link CameraDevice#close}. 5285c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 5295c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * <p>Any attempt to call methods on this CameraDevice in the 5305c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * future will throw a {@link IllegalStateException}.</p> 5315c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 5325c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * <p>The default implementation of this method does nothing.</p> 5335c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 5345c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * @param camera the camera device that has become closed 535b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 5365c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin public void onClosed(CameraDevice camera) { 5375c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin // Default empty implementation 5385c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin } 539b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 540b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala /** 5414af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * The method called when a camera device is no longer available for 5424af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * use. 5434af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 5445c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * <p>This callback may be called instead of {@link #onOpened} 5455c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * if opening the camera fails.</p> 5465c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 5474af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * <p>Any attempt to call methods on this CameraDevice will throw a 5484af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * {@link CameraAccessException}. The disconnection could be due to a 5494af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * change in security policy or permissions; the physical disconnection 5504af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * of a removable camera device; or the camera being needed for a 5514af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * higher-priority use case.</p> 5524af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 553fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * <p>There may still be capture callbacks that are invoked 5544af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * after this method is called, or new image buffers that are delivered 5554af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * to active outputs.</p> 5564af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 5574af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * <p>The default implementation logs a notice to the system log 5584af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * about the disconnection.</p> 5594af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 5605c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * <p>You should clean up the camera with {@link CameraDevice#close} after 5615c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * this happens, as it is not recoverable until opening the camera again 562fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * after it becomes {@link CameraManager.AvailabilityCallback#onCameraAvailable available}. 5635c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * </p> 5645c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 5654af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * @param camera the device that has been disconnected 566b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 5675c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin public abstract void onDisconnected(CameraDevice camera); // Must implement 568b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala 569b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala /** 5704af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * The method called when a camera device has encountered a serious error. 5714af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 5725c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * <p>This callback may be called instead of {@link #onOpened} 5735c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * if opening the camera fails.</p> 5745c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * 5754af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * <p>This indicates a failure of the camera device or camera service in 5764af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * some way. Any attempt to call methods on this CameraDevice in the 5775c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * future will throw a {@link CameraAccessException} with the 5785c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * {@link CameraAccessException#CAMERA_ERROR CAMERA_ERROR} reason. 5795c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * </p> 5804af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 581fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * <p>There may still be capture completion or camera stream callbacks 5824af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * that will be called after this error is received.</p> 5834af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 5845c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * <p>You should clean up the camera with {@link CameraDevice#close} after 5855c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * this happens. Further attempts at recovery are error-code specific.</p> 586b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * 587b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala * @param camera The device reporting the error 5884af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * @param error The error code, one of the 589fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * {@code StateCallback.ERROR_*} values. 5904af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * 5914af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * @see #ERROR_CAMERA_DEVICE 5924af73c2153747d0624ccc75dfa001cb91982957fEino-Ville Talvala * @see #ERROR_CAMERA_SERVICE 5935c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * @see #ERROR_CAMERA_DISABLED 5945c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin * @see #ERROR_CAMERA_IN_USE 595b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala */ 5965c9eaf6796a4c972710dd5cd23cdfa334fa8ad2eIgor Murashkin public abstract void onError(CameraDevice camera, int error); // Must implement 597b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala } 59821547d66a9ce591ff30a3ad4102f7f30a4764d80Igor Murashkin 59921547d66a9ce591ff30a3ad4102f7f30a4764d80Igor Murashkin /** 600fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * Temporary for migrating to Callback naming 601fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala * @hide 602fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala */ 603fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala public static abstract class StateListener extends StateCallback { 604fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala } 605fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala 606fd887436bd111e4d2c7307578a51b5070025b7f2Eino-Ville Talvala /** 60721547d66a9ce591ff30a3ad4102f7f30a4764d80Igor Murashkin * To be inherited by android.hardware.camera2.* code only. 60821547d66a9ce591ff30a3ad4102f7f30a4764d80Igor Murashkin * @hide 60921547d66a9ce591ff30a3ad4102f7f30a4764d80Igor Murashkin */ 61021547d66a9ce591ff30a3ad4102f7f30a4764d80Igor Murashkin public CameraDevice() {} 611b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala} 612