blob: ce1fba798c0e2680f57b9a1353e15bd425ac00c0 [file] [log] [blame]
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08001/*
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 Talvala2f1a2e42013-07-25 17:12:05 -070017package android.hardware.camera2;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080018
Eino-Ville Talvala8b905572015-05-14 15:43:01 -070019import android.annotation.NonNull;
20import android.annotation.Nullable;
21import android.annotation.IntDef;
Eino-Ville Talvala49c62f52017-02-28 17:57:28 -080022import android.annotation.SystemApi;
23import android.annotation.TestApi;
24import static android.hardware.camera2.ICameraDeviceUser.NORMAL_MODE;
25import static android.hardware.camera2.ICameraDeviceUser.CONSTRAINED_HIGH_SPEED_MODE;
Chien-Yu Chen5398a672015-03-19 14:48:43 -070026import android.hardware.camera2.params.InputConfiguration;
Igor Murashkin9c595172014-05-12 13:56:20 -070027import android.hardware.camera2.params.StreamConfigurationMap;
Yin-Chia Yeh49ea6ae2015-03-09 16:53:14 -070028import android.hardware.camera2.params.OutputConfiguration;
Emilian Peev75a55702017-11-07 16:09:59 +000029import android.hardware.camera2.params.SessionConfiguration;
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -070030import android.os.Handler;
Zhijun He599be612013-09-27 13:43:25 -070031import android.view.Surface;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080032
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080033import java.util.List;
Eino-Ville Talvala8b905572015-05-14 15:43:01 -070034import java.lang.annotation.Retention;
35import java.lang.annotation.RetentionPolicy;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080036
37/**
Igor Murashkin21547d62014-06-04 15:21:42 -070038 * <p>The CameraDevice class is a representation of a single camera connected to an
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080039 * Android device, allowing for fine-grain control of image capture and
40 * post-processing at high frame rates.</p>
41 *
42 * <p>Your application must declare the
43 * {@link android.Manifest.permission#CAMERA Camera} permission in its manifest
44 * in order to access camera devices.</p>
45 *
46 * <p>A given camera device may provide support at one of two levels: limited or
47 * full. If a device only supports the limited level, then Camera2 exposes a
48 * feature set that is roughly equivalent to the older
49 * {@link android.hardware.Camera Camera} API, although with a cleaner and more
50 * efficient interface. Devices that implement the full level of support
51 * provide substantially improved capabilities over the older camera
52 * API. Applications that target the limited level devices will run unchanged on
53 * the full-level devices; if your application requires a full-level device for
Yin-Chia Yeha636be62015-10-06 13:45:20 -070054 * proper operation, declare the "android.hardware.camera.level.full" feature in your
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080055 * manifest.</p>
56 *
57 * @see CameraManager#openCamera
58 * @see android.Manifest.permission#CAMERA
59 */
Igor Murashkin21547d62014-06-04 15:21:42 -070060public abstract class CameraDevice implements AutoCloseable {
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080061
62 /**
63 * Create a request suitable for a camera preview window. Specifically, this
64 * means that high frame rate is given priority over the highest-quality
65 * post-processing. These requests would normally be used with the
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -070066 * {@link CameraCaptureSession#setRepeatingRequest} method.
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -070067 * This template is guaranteed to be supported on all camera devices.
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080068 *
69 * @see #createCaptureRequest
70 */
71 public static final int TEMPLATE_PREVIEW = 1;
72
73 /**
Zhijun Heb8b77bf2013-06-28 16:30:12 -070074 * Create a request suitable for still image capture. Specifically, this
75 * means prioritizing image quality over frame rate. These requests would
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -070076 * commonly be used with the {@link CameraCaptureSession#capture} method.
Chien-Yu Chen5b0a58e2017-07-28 14:52:05 -070077 * This template is guaranteed to be supported on all camera devices except
78 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT DEPTH_OUTPUT} devices
79 * that are not {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE
80 * BACKWARD_COMPATIBLE}.
Zhijun Heb8b77bf2013-06-28 16:30:12 -070081 * @see #createCaptureRequest
82 */
83 public static final int TEMPLATE_STILL_CAPTURE = 2;
84
85 /**
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080086 * Create a request suitable for video recording. Specifically, this means
87 * that a stable frame rate is used, and post-processing is set for
88 * recording quality. These requests would commonly be used with the
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -070089 * {@link CameraCaptureSession#setRepeatingRequest} method.
Chien-Yu Chen5b0a58e2017-07-28 14:52:05 -070090 * This template is guaranteed to be supported on all camera devices except
91 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT DEPTH_OUTPUT} devices
92 * that are not {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE
93 * BACKWARD_COMPATIBLE}.
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080094 *
95 * @see #createCaptureRequest
96 */
Zhijun Heb8b77bf2013-06-28 16:30:12 -070097 public static final int TEMPLATE_RECORD = 3;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080098
99 /**
100 * Create a request suitable for still image capture while recording
101 * video. Specifically, this means maximizing image quality without
102 * disrupting the ongoing recording. These requests would commonly be used
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -0700103 * with the {@link CameraCaptureSession#capture} method while a request based on
104 * {@link #TEMPLATE_RECORD} is is in use with {@link CameraCaptureSession#setRepeatingRequest}.
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -0700105 * This template is guaranteed to be supported on all camera devices except
106 * legacy devices ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
Chien-Yu Chen5b0a58e2017-07-28 14:52:05 -0700107 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY}) and
108 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT DEPTH_OUTPUT} devices
109 * that are not {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE
110 * BACKWARD_COMPATIBLE}.
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800111 *
112 * @see #createCaptureRequest
113 */
114 public static final int TEMPLATE_VIDEO_SNAPSHOT = 4;
115
116 /**
Zhijun Hebbae94a2013-09-13 11:32:20 -0700117 * Create a request suitable for zero shutter lag still capture. This means
118 * means maximizing image quality without compromising preview frame rate.
Chien-Yu Chen6828bb92017-05-03 12:08:08 -0700119 * AE/AWB/AF should be on auto mode. This is intended for application-operated ZSL. For
120 * device-operated ZSL, use {@link CaptureRequest#CONTROL_ENABLE_ZSL} if available.
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -0700121 * This template is guaranteed to be supported on camera devices that support the
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700122 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING PRIVATE_REPROCESSING}
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -0700123 * capability or the
124 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING YUV_REPROCESSING}
125 * capability.
Zhijun Hebbae94a2013-09-13 11:32:20 -0700126 *
127 * @see #createCaptureRequest
Chien-Yu Chen6828bb92017-05-03 12:08:08 -0700128 * @see CaptureRequest#CONTROL_ENABLE_ZSL
Zhijun Hebbae94a2013-09-13 11:32:20 -0700129 */
130 public static final int TEMPLATE_ZERO_SHUTTER_LAG = 5;
131
132 /**
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800133 * A basic template for direct application control of capture
134 * parameters. All automatic control is disabled (auto-exposure, auto-white
135 * balance, auto-focus), and post-processing parameters are set to preview
136 * quality. The manual capture parameters (exposure, sensitivity, and so on)
137 * are set to reasonable defaults, but should be overriden by the
138 * application depending on the intended use case.
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -0700139 * This template is guaranteed to be supported on camera devices that support the
140 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR MANUAL_SENSOR}
141 * capability.
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800142 *
143 * @see #createCaptureRequest
144 */
Zhijun Hebbae94a2013-09-13 11:32:20 -0700145 public static final int TEMPLATE_MANUAL = 6;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800146
Eino-Ville Talvalaec99efa2017-11-29 15:35:42 -0800147 /**
148 * A template for selecting camera parameters that match TEMPLATE_PREVIEW as closely as
149 * possible while improving the camera output for motion tracking use cases.
150 *
151 * <p>This template is best used by applications that are frequently switching between motion
152 * tracking use cases and regular still capture use cases, to minimize the IQ changes
153 * when swapping use cases.</p>
154 *
155 * <p>This template is guaranteed to be supported on camera devices that support the
156 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING MOTION_TRACKING}
157 * capability.</p>
158 *
159 * @see #createCaptureRequest
160 */
161 public static final int TEMPLATE_MOTION_TRACKING_PREVIEW = 7;
162
163 /**
164 * A template for selecting camera parameters that maximize the quality of camera output for
165 * motion tracking use cases.
166 *
167 * <p>This template is best used by applications dedicated to motion tracking applications,
168 * which aren't concerned about fast switches between motion tracking and other use cases.</p>
169 *
170 * <p>This template is guaranteed to be supported on camera devices that support the
171 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING MOTION_TRACKING}
172 * capability.</p>
173 *
174 * @see #createCaptureRequest
175 */
176 public static final int TEMPLATE_MOTION_TRACKING_BEST = 8;
177
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700178 /** @hide */
179 @Retention(RetentionPolicy.SOURCE)
Eino-Ville Talvala16ffbc62017-04-24 13:10:21 -0700180 @IntDef(prefix = {"TEMPLATE_"}, value =
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700181 {TEMPLATE_PREVIEW,
182 TEMPLATE_STILL_CAPTURE,
183 TEMPLATE_RECORD,
184 TEMPLATE_VIDEO_SNAPSHOT,
185 TEMPLATE_ZERO_SHUTTER_LAG,
186 TEMPLATE_MANUAL })
187 public @interface RequestTemplate {};
188
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800189 /**
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700190 * Get the ID of this camera device.
191 *
192 * <p>This matches the ID given to {@link CameraManager#openCamera} to instantiate this
193 * this camera device.</p>
194 *
195 * <p>This ID can be used to query the camera device's {@link
Igor Murashkin68f40062013-09-10 12:15:54 -0700196 * CameraCharacteristics fixed properties} with {@link
197 * CameraManager#getCameraCharacteristics}.</p>
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700198 *
199 * <p>This method can be called even if the device has been closed or has encountered
200 * a serious error.</p>
201 *
202 * @return the ID for this camera device
203 *
Igor Murashkin68f40062013-09-10 12:15:54 -0700204 * @see CameraManager#getCameraCharacteristics
Zhijun He599be612013-09-27 13:43:25 -0700205 * @see CameraManager#getCameraIdList
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700206 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700207 @NonNull
Igor Murashkin21547d62014-06-04 15:21:42 -0700208 public abstract String getId();
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700209
210 /**
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700211 * <p>Create a new camera capture session by providing the target output set of Surfaces to the
212 * camera device.</p>
213 *
214 * <p>The active capture session determines the set of potential output Surfaces for
215 * the camera device for each capture request. A given request may use all
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700216 * or only some of the outputs. Once the CameraCaptureSession is created, requests can be
Hidenari Koshimae0fa49142016-01-08 16:18:28 +0900217 * submitted with {@link CameraCaptureSession#capture capture},
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700218 * {@link CameraCaptureSession#captureBurst captureBurst},
219 * {@link CameraCaptureSession#setRepeatingRequest setRepeatingRequest}, or
220 * {@link CameraCaptureSession#setRepeatingBurst setRepeatingBurst}.</p>
221 *
222 * <p>Surfaces suitable for inclusion as a camera output can be created for
223 * various use cases and targets:</p>
224 *
225 * <ul>
226 *
Eino-Ville Talvala5ae1ca52014-06-12 16:46:58 -0700227 * <li>For drawing to a {@link android.view.SurfaceView SurfaceView}: Once the SurfaceView's
Eino-Ville Talvalafa0b9a02015-01-20 12:30:59 -0800228 * Surface is {@link android.view.SurfaceHolder.Callback#surfaceCreated created}, set the size
229 * of the Surface with {@link android.view.SurfaceHolder#setFixedSize} to be one of the sizes
230 * returned by {@link StreamConfigurationMap#getOutputSizes(Class)
231 * getOutputSizes(SurfaceHolder.class)} and then obtain the Surface by calling {@link
232 * android.view.SurfaceHolder#getSurface}. If the size is not set by the application, it will
233 * be rounded to the nearest supported size less than 1080p, by the camera device.</li>
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700234 *
Eino-Ville Talvalafa0b9a02015-01-20 12:30:59 -0800235 * <li>For accessing through an OpenGL texture via a {@link android.graphics.SurfaceTexture
236 * SurfaceTexture}: Set the size of the SurfaceTexture with {@link
237 * android.graphics.SurfaceTexture#setDefaultBufferSize} to be one of the sizes returned by
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700238 * {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(SurfaceTexture.class)}
Eino-Ville Talvalafa0b9a02015-01-20 12:30:59 -0800239 * before creating a Surface from the SurfaceTexture with {@link Surface#Surface}. If the size
240 * is not set by the application, it will be set to be the smallest supported size less than
241 * 1080p, by the camera device.</li>
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700242 *
243 * <li>For recording with {@link android.media.MediaCodec}: Call
244 * {@link android.media.MediaCodec#createInputSurface} after configuring
245 * the media codec to use one of the sizes returned by
246 * {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(MediaCodec.class)}
247 * </li>
248 *
249 * <li>For recording with {@link android.media.MediaRecorder}: Call
250 * {@link android.media.MediaRecorder#getSurface} after configuring the media recorder to use
251 * one of the sizes returned by
252 * {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(MediaRecorder.class)},
253 * or configuring it to use one of the supported
254 * {@link android.media.CamcorderProfile CamcorderProfiles}.</li>
255 *
256 * <li>For efficient YUV processing with {@link android.renderscript}:
257 * Create a RenderScript
258 * {@link android.renderscript.Allocation Allocation} with a supported YUV
259 * type, the IO_INPUT flag, and one of the sizes returned by
260 * {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(Allocation.class)},
261 * Then obtain the Surface with
262 * {@link android.renderscript.Allocation#getSurface}.</li>
263 *
Martin Storsjo5c533e42014-11-19 11:58:03 +0200264 * <li>For access to RAW, uncompressed YUV, or compressed JPEG data in the application: Create an
Sol Boucherb8cee512014-06-11 16:35:57 -0700265 * {@link android.media.ImageReader} object with one of the supported output formats given by
266 * {@link StreamConfigurationMap#getOutputFormats()}, setting its size to one of the
267 * corresponding supported sizes by passing the chosen output format into
268 * {@link StreamConfigurationMap#getOutputSizes(int)}. Then obtain a
269 * {@link android.view.Surface} from it with {@link android.media.ImageReader#getSurface()}.
Eino-Ville Talvalafa0b9a02015-01-20 12:30:59 -0800270 * If the ImageReader size is not set to a supported size, it will be rounded to a supported
271 * size less than 1080p by the camera device.
Sol Boucherb8cee512014-06-11 16:35:57 -0700272 * </li>
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700273 *
274 * </ul>
275 *
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700276 * <p>The camera device will query each Surface's size and formats upon this
Sol Boucherb8cee512014-06-11 16:35:57 -0700277 * call, so they must be set to a valid setting at this time.</p>
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700278 *
279 * <p>It can take several hundred milliseconds for the session's configuration to complete,
280 * since camera hardware may need to be powered on or reconfigured. Once the configuration is
281 * complete and the session is ready to actually capture data, the provided
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700282 * {@link CameraCaptureSession.StateCallback}'s
283 * {@link CameraCaptureSession.StateCallback#onConfigured} callback will be called.</p>
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700284 *
Chien-Yu Chen078c92a2015-06-25 16:54:17 -0700285 * <p>If a prior CameraCaptureSession already exists when this method is called, the previous
286 * session will no longer be able to accept new capture requests and will be closed. Any
287 * in-progress capture requests made on the prior session will be completed before it's closed.
Eino-Ville Talvala3c8c16f2016-09-06 15:28:46 -0700288 * {@link CameraCaptureSession.StateCallback#onConfigured} for the new session may be invoked
289 * before {@link CameraCaptureSession.StateCallback#onClosed} is invoked for the prior
290 * session. Once the new session is {@link CameraCaptureSession.StateCallback#onConfigured
Chien-Yu Chen078c92a2015-06-25 16:54:17 -0700291 * configured}, it is able to start capturing its own requests. To minimize the transition time,
292 * the {@link CameraCaptureSession#abortCaptures} call can be used to discard the remaining
293 * requests for the prior capture session before a new one is created. Note that once the new
294 * session is created, the old one can no longer have its captures aborted.</p>
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700295 *
296 * <p>Using larger resolution outputs, or more outputs, can result in slower
297 * output rate from the device.</p>
298 *
299 * <p>Configuring a session with an empty or null list will close the current session, if
300 * any. This can be used to release the current session's target surfaces for another use.</p>
301 *
Eino-Ville Talvalaf3621f32014-08-26 14:53:39 -0700302 * <p>While any of the sizes from {@link StreamConfigurationMap#getOutputSizes} can be used when
303 * a single output stream is configured, a given camera device may not be able to support all
304 * combination of sizes, formats, and targets when multiple outputs are configured at once. The
305 * tables below list the maximum guaranteed resolutions for combinations of streams and targets,
306 * given the capabilities of the camera device.</p>
307 *
308 * <p>If an application tries to create a session using a set of targets that exceed the limits
309 * described in the below tables, one of three possibilities may occur. First, the session may
310 * be successfully created and work normally. Second, the session may be successfully created,
311 * but the camera device won't meet the frame rate guarantees as described in
312 * {@link StreamConfigurationMap#getOutputMinFrameDuration}. Or third, if the output set
313 * cannot be used at all, session creation will fail entirely, with
Eino-Ville Talvala3c8c16f2016-09-06 15:28:46 -0700314 * {@link CameraCaptureSession.StateCallback#onConfigureFailed} being invoked.</p>
Eino-Ville Talvalaf3621f32014-08-26 14:53:39 -0700315 *
316 * <p>For the type column, {@code PRIV} refers to any target whose available sizes are found
317 * using {@link StreamConfigurationMap#getOutputSizes(Class)} with no direct application-visible
318 * format, {@code YUV} refers to a target Surface using the
319 * {@link android.graphics.ImageFormat#YUV_420_888} format, {@code JPEG} refers to the
320 * {@link android.graphics.ImageFormat#JPEG} format, and {@code RAW} refers to the
321 * {@link android.graphics.ImageFormat#RAW_SENSOR} format.</p>
322 *
323 * <p>For the maximum size column, {@code PREVIEW} refers to the best size match to the
324 * device's screen resolution, or to 1080p ({@code 1920x1080}), whichever is
325 * smaller. {@code RECORD} refers to the camera device's maximum supported recording resolution,
326 * as determined by {@link android.media.CamcorderProfile}. And {@code MAXIMUM} refers to the
327 * camera device's maximum output resolution for that format or target from
328 * {@link StreamConfigurationMap#getOutputSizes}.</p>
329 *
330 * <p>To use these tables, determine the number and the formats/targets of outputs needed, and
331 * find the row(s) of the table with those targets. The sizes indicate the maximum set of sizes
332 * that can be used; it is guaranteed that for those targets, the listed sizes and anything
333 * smaller from the list given by {@link StreamConfigurationMap#getOutputSizes} can be
334 * successfully used to create a session. For example, if a row indicates that a 8 megapixel
335 * (MP) YUV_420_888 output can be used together with a 2 MP {@code PRIV} output, then a session
336 * can be created with targets {@code [8 MP YUV, 2 MP PRIV]} or targets {@code [2 MP YUV, 2 MP
337 * PRIV]}; but a session with targets {@code [8 MP YUV, 4 MP PRIV]}, targets {@code [4 MP YUV, 4
338 * MP PRIV]}, or targets {@code [8 MP PRIV, 2 MP YUV]} would not be guaranteed to work, unless
339 * some other row of the table lists such a combination.</p>
340 *
341 * <style scoped>
342 * #rb { border-right-width: thick; }
343 * </style>
344 * <p>Legacy devices ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
345 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY}) support at
346 * least the following stream combinations:
347 *
348 * <table>
349 * <tr><th colspan="7">LEGACY-level guaranteed configurations</th></tr>
350 * <tr> <th colspan="2" id="rb">Target 1</th> <th colspan="2" id="rb">Target 2</th> <th colspan="2" id="rb">Target 3</th> <th rowspan="2">Sample use case(s)</th> </tr>
351 * <tr> <th>Type</th><th id="rb">Max size</th> <th>Type</th><th id="rb">Max size</th> <th>Type</th><th id="rb">Max size</th></tr>
352 * <tr> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td colspan="2" id="rb"></td> <td>Simple preview, GPU video processing, or no-preview video recording.</td> </tr>
353 * <tr> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td colspan="2" id="rb"></td> <td>No-viewfinder still image capture.</td> </tr>
354 * <tr> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td colspan="2" id="rb"></td> <td>In-application video/image processing.</td> </tr>
355 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>Standard still imaging.</td> </tr>
356 * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>In-app processing plus still capture.</td> </tr>
357 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td colspan="2" id="rb"></td> <td>Standard recording.</td> </tr>
358 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td colspan="2" id="rb"></td> <td>Preview plus in-app processing.</td> </tr>
359 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>Still capture plus in-app processing.</td> </tr>
360 * </table><br>
361 * </p>
362 *
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800363 * <p>Limited-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
Eino-Ville Talvalaf3621f32014-08-26 14:53:39 -0700364 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED}) devices
365 * support at least the following stream combinations in addition to those for
366 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY} devices:
367 *
368 * <table>
369 * <tr><th colspan="7">LIMITED-level additional guaranteed configurations</th></tr>
370 * <tr><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th> <th rowspan="2">Sample use case(s)</th> </tr>
371 * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th></tr>
372 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code RECORD }</td> <td colspan="2" id="rb"></td> <td>High-resolution video recording with preview.</td> </tr>
373 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code RECORD }</td> <td colspan="2" id="rb"></td> <td>High-resolution in-app video processing with preview.</td> </tr>
374 * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code RECORD }</td> <td colspan="2" id="rb"></td> <td>Two-input in-app video processing.</td> </tr>
375 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code RECORD }</td> <td>{@code JPEG}</td><td id="rb">{@code RECORD }</td> <td>High-resolution recording with video snapshot.</td> </tr>
376 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code RECORD }</td> <td>{@code JPEG}</td><td id="rb">{@code RECORD }</td> <td>High-resolution in-app processing with video snapshot.</td> </tr>
377 * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>Two-input in-app processing with still capture.</td> </tr>
378 * </table><br>
379 * </p>
380 *
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800381 * <p>FULL-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
Eino-Ville Talvalaf3621f32014-08-26 14:53:39 -0700382 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) devices
383 * support at least the following stream combinations in addition to those for
384 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
385 *
386 * <table>
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800387 * <tr><th colspan="7">FULL-level additional guaranteed configurations</th></tr>
Eino-Ville Talvalaf3621f32014-08-26 14:53:39 -0700388 * <tr><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th> <th rowspan="2">Sample use case(s)</th> </tr>
389 * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th> </tr>
390 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>Maximum-resolution GPU processing with preview.</td> </tr>
391 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>Maximum-resolution in-app processing with preview.</td> </tr>
392 * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>Maximum-resolution two-input in-app processsing.</td> </tr>
393 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>Video recording with maximum-size video snapshot</td> </tr>
394 * <tr> <td>{@code YUV }</td><td id="rb">{@code 640x480}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td>Standard video recording plus maximum-resolution in-app processing.</td> </tr>
395 * <tr> <td>{@code YUV }</td><td id="rb">{@code 640x480}</td> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td>Preview plus two-input maximum-resolution in-app processing.</td> </tr>
396 * </table><br>
397 * </p>
398 *
399 * <p>RAW-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
400 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}) devices additionally support
401 * at least the following stream combinations on both
402 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} and
403 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
404 *
405 * <table>
406 * <tr><th colspan="7">RAW-capability additional guaranteed configurations</th></tr>
407 * <tr><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th> <th rowspan="2">Sample use case(s)</th> </tr>
408 * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th> </tr>
409 * <tr> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td colspan="2" id="rb"></td> <td>No-preview DNG capture.</td> </tr>
410 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>Standard DNG capture.</td> </tr>
411 * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td colspan="2" id="rb"></td> <td>In-app processing plus DNG capture.</td> </tr>
412 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td>Video recording with DNG capture.</td> </tr>
413 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td>Preview with in-app processing and DNG capture.</td> </tr>
414 * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td>Two-input in-app processing plus DNG capture.</td> </tr>
415 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td>Still capture with simultaneous JPEG and DNG.</td> </tr>
416 * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code RAW }</td><td id="rb">{@code MAXIMUM}</td> <td>In-app processing with simultaneous JPEG and DNG.</td> </tr>
417 * </table><br>
418 * </p>
419 *
Eino-Ville Talvalaec99efa2017-11-29 15:35:42 -0800420 * <p>MOTION_TRACKING-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES}
421 * includes
422 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING MOTION_TRACKING})
423 * devices support at least the below stream combinations in addition to those for
424 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices. The
425 * {@code FULL FOV 640} entry means that the device will support a resolution that's 640 pixels
426 * wide, with the height set so that the resolution aspect ratio matches the MAXIMUM output
427 * aspect ratio. So for a device with a 4:3 image sensor, this will be 640x480, and for a
428 * device with a 16:9 sensor, this will be 640x360, and so on.
429 *
430 * <table>
431 * <tr><th colspan="7">MOTION_TRACKING-capability additional guaranteed configurations</th></tr>
432 * <tr><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th><th rowspan="2">Sample use case(s)</th> </tr>
433 * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th></tr>
434 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code FULL FOV 640}</td> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td>Live preview with a tracking YUV output and a maximum-resolution YUV for still captures.</td> </tr>
435 * </table><br>
436 * </p>
437 *
Eino-Ville Talvala126a7462014-11-04 16:31:01 -0800438 * <p>BURST-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
439 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE BURST_CAPTURE}) devices
440 * support at least the below stream combinations in addition to those for
441 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices. Note that all
442 * FULL-level devices support the BURST capability, and the below list is a strict subset of the
443 * list for FULL-level devices, so this table is only relevant for LIMITED-level devices that
444 * support the BURST_CAPTURE capability.
445 *
446 * <table>
447 * <tr><th colspan="5">BURST-capability additional guaranteed configurations</th></tr>
448 * <tr><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th rowspan="2">Sample use case(s)</th> </tr>
449 * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th> </tr>
450 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td>Maximum-resolution GPU processing with preview.</td> </tr>
451 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td>Maximum-resolution in-app processing with preview.</td> </tr>
452 * <tr> <td>{@code YUV }</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV }</td><td id="rb">{@code MAXIMUM}</td> <td>Maximum-resolution two-input in-app processsing.</td> </tr>
453 * </table><br>
454 * </p>
455 *
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800456 * <p>LEVEL-3 ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
457 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_3 LEVEL_3})
458 * support at least the following stream combinations in addition to the combinations for
459 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} and for
460 * RAW capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
461 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}):
462 *
463 * <table>
464 * <tr><th colspan="11">LEVEL-3 additional guaranteed configurations</th></tr>
465 * <tr><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th><th colspan="2" id="rb">Target 4</th><th rowspan="2">Sample use case(s)</th> </tr>
466 * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th> </tr>
467 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code 640x480}</td> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>In-app viewfinder analysis with dynamic selection of output format.</td> </tr>
468 * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code 640x480}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>In-app viewfinder analysis with dynamic selection of output format.</td> </tr>
469 * </table><br>
470 * </p>
471 *
Eino-Ville Talvalaf3621f32014-08-26 14:53:39 -0700472 * <p>Since the capabilities of camera devices vary greatly, a given camera device may support
473 * target combinations with sizes outside of these guarantees, but this can only be tested for
474 * by attempting to create a session with such targets.</p>
475 *
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700476 * @param outputs The new set of Surfaces that should be made available as
477 * targets for captured image data.
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700478 * @param callback The callback to notify about the status of the new capture session.
479 * @param handler The handler on which the callback should be invoked, or {@code null} to use
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700480 * the current thread's {@link android.os.Looper looper}.
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -0700481 *
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700482 * @throws IllegalArgumentException if the set of output Surfaces do not meet the requirements,
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700483 * the callback is null, or the handler is null but the current
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700484 * thread has no looper.
485 * @throws CameraAccessException if the camera device is no longer connected or has
486 * encountered a fatal error
487 * @throws IllegalStateException if the camera device has been closed
488 *
489 * @see CameraCaptureSession
490 * @see StreamConfigurationMap#getOutputFormats()
491 * @see StreamConfigurationMap#getOutputSizes(int)
492 * @see StreamConfigurationMap#getOutputSizes(Class)
493 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700494 public abstract void createCaptureSession(@NonNull List<Surface> outputs,
495 @NonNull CameraCaptureSession.StateCallback callback, @Nullable Handler handler)
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700496 throws CameraAccessException;
497
498 /**
Yin-Chia Yeh49ea6ae2015-03-09 16:53:14 -0700499 * <p>Create a new camera capture session by providing the target output set of Surfaces and
500 * its corresponding surface configuration to the camera device.</p>
501 *
502 * @see #createCaptureSession
503 * @see OutputConfiguration
Yin-Chia Yeh49ea6ae2015-03-09 16:53:14 -0700504 */
Zhijun He00347432016-04-07 17:34:10 -0700505 public abstract void createCaptureSessionByOutputConfigurations(
Yin-Chia Yeh49ea6ae2015-03-09 16:53:14 -0700506 List<OutputConfiguration> outputConfigurations,
Eino-Ville Talvalad5b9c6b2016-12-01 11:29:55 -0800507 CameraCaptureSession.StateCallback callback, @Nullable Handler handler)
Yin-Chia Yeh49ea6ae2015-03-09 16:53:14 -0700508 throws CameraAccessException;
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700509 /**
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700510 * Create a new reprocessable camera capture session by providing the desired reprocessing
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700511 * input Surface configuration and the target output set of Surfaces to the camera device.
512 *
513 * <p>If a camera device supports YUV reprocessing
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700514 * ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING}) or PRIVATE
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700515 * reprocessing
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700516 * ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING}), besides
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700517 * the capture session created via {@link #createCaptureSession createCaptureSession}, the
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700518 * application can also create a reprocessable capture session to submit reprocess capture
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700519 * requests in addition to regular capture requests. A reprocess capture request takes the next
520 * available buffer from the session's input Surface, and sends it through the camera device's
521 * processing pipeline again, to produce buffers for the request's target output Surfaces. No
522 * new image data is captured for a reprocess request. However the input buffer provided by
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700523 * the application must be captured previously by the same camera device in the same session
524 * directly (e.g. for Zero-Shutter-Lag use case) or indirectly (e.g. combining multiple output
525 * images).</p>
526 *
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700527 * <p>The active reprocessable capture session determines an input {@link Surface} and the set
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700528 * of potential output Surfaces for the camera devices for each capture request. The application
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700529 * can use {@link #createCaptureRequest createCaptureRequest} to create regular capture requests
530 * to capture new images from the camera device, and use {@link #createReprocessCaptureRequest
531 * createReprocessCaptureRequest} to create reprocess capture requests to process buffers from
532 * the input {@link Surface}. Some combinations of output Surfaces in a session may not be used
533 * in a request simultaneously. The guaranteed combinations of output Surfaces that can be used
534 * in a request simultaneously are listed in the tables under {@link #createCaptureSession
535 * createCaptureSession}. All the output Surfaces in one capture request will come from the
536 * same source, either from a new capture by the camera device, or from the input Surface
537 * depending on if the request is a reprocess capture request.</p>
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700538 *
539 * <p>Input formats and sizes supported by the camera device can be queried via
540 * {@link StreamConfigurationMap#getInputFormats} and
541 * {@link StreamConfigurationMap#getInputSizes}. For each supported input format, the camera
542 * device supports a set of output formats and sizes for reprocessing that can be queried via
543 * {@link StreamConfigurationMap#getValidOutputFormatsForInput} and
544 * {@link StreamConfigurationMap#getOutputSizes}. While output Surfaces with formats that
545 * aren't valid reprocess output targets for the input configuration can be part of a session,
546 * they cannot be used as targets for a reprocessing request.</p>
547 *
548 * <p>Since the application cannot access {@link android.graphics.ImageFormat#PRIVATE} images
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700549 * directly, an output Surface created by {@link android.media.ImageReader#newInstance} with
550 * {@link android.graphics.ImageFormat#PRIVATE} as the format will be considered as intended to
551 * be used for reprocessing input and thus the {@link android.media.ImageReader} size must
552 * match one of the supported input sizes for {@link android.graphics.ImageFormat#PRIVATE}
553 * format. Otherwise, creating a reprocessable capture session will fail.</p>
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700554 *
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700555 * <p>The guaranteed stream configurations listed in
556 * {@link #createCaptureSession createCaptureSession} are also guaranteed to work for
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700557 * {@link #createReprocessableCaptureSession createReprocessableCaptureSession}. In addition,
558 * the configurations in the tables below are also guaranteed for creating a reprocessable
559 * capture session if the camera device supports YUV reprocessing or PRIVATE reprocessing.
560 * However, not all output targets used to create a reprocessable session may be used in a
Chien-Yu Chene90c6d02015-08-25 11:31:58 -0700561 * {@link CaptureRequest} simultaneously. For devices that support only 1 output target in a
562 * reprocess {@link CaptureRequest}, submitting a reprocess {@link CaptureRequest} with multiple
563 * output targets will result in a {@link CaptureFailure}. For devices that support multiple
564 * output targets in a reprocess {@link CaptureRequest}, the guaranteed output targets that can
565 * be included in a {@link CaptureRequest} simultaneously are listed in the tables under
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700566 * {@link #createCaptureSession createCaptureSession}. For example, with a FULL-capability
567 * ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL} {@code == }
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700568 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) device that supports PRIVATE
569 * reprocessing, an application can create a reprocessable capture session with 1 input,
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700570 * ({@code PRIV}, {@code MAXIMUM}), and 3 outputs, ({@code PRIV}, {@code MAXIMUM}),
571 * ({@code PRIV}, {@code PREVIEW}), and ({@code YUV}, {@code MAXIMUM}). However, it's not
572 * guaranteed that an application can submit a regular or reprocess capture with ({@code PRIV},
573 * {@code MAXIMUM}) and ({@code YUV}, {@code MAXIMUM}) outputs based on the table listed under
574 * {@link #createCaptureSession createCaptureSession}. In other words, use the tables below to
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700575 * determine the guaranteed stream configurations for creating a reprocessable capture session,
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700576 * and use the tables under {@link #createCaptureSession createCaptureSession} to determine the
577 * guaranteed output targets that can be submitted in a regular or reprocess
578 * {@link CaptureRequest} simultaneously.</p>
579 *
580 * <style scoped>
581 * #rb { border-right-width: thick; }
582 * </style>
583 *
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800584 * <p>LIMITED-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700585 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED}) devices
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700586 * support at least the following stream combinations for creating a reprocessable capture
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700587 * session in addition to those listed in {@link #createCaptureSession createCaptureSession} for
588 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
589 *
590 * <table>
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700591 * <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 Chenf723db72015-04-30 13:06:09 -0700592 * <tr><th colspan="2" id="rb">Input</th><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th><th colspan="2" id="rb">Target 4</th><th rowspan="2">Sample use case(s)</th> </tr>
593 * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th></tr>
594 * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td></td><td id="rb"></td> <td></td><td id="rb"></td> <td>No-viewfinder still image reprocessing.</td> </tr>
595 * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td></td><td id="rb"></td> <td>ZSL(Zero-Shutter-Lag) still imaging.</td> </tr>
596 * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td></td><td id="rb"></td> <td>ZSL still and in-app processing imaging.</td> </tr>
597 * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>ZSL in-app processing with still capture.</td> </tr>
598 * </table><br>
599 * </p>
600 *
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800601 * <p>FULL-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700602 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) devices
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700603 * support at least the following stream combinations for creating a reprocessable capture
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700604 * session in addition to those for
605 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
606 *
607 * <table>
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800608 * <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 Chenf723db72015-04-30 13:06:09 -0700609 * <tr><th colspan="2" id="rb">Input</th><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th><th colspan="2" id="rb">Target 4</th><th rowspan="2">Sample use case(s)</th> </tr>
610 * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th></tr>
611 * <tr> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td></td><td id="rb"></td> <td></td><td id="rb"></td> <td>Maximum-resolution multi-frame image fusion in-app processing with regular preview.</td> </tr>
612 * <tr> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td></td><td id="rb"></td> <td></td><td id="rb"></td> <td>Maximum-resolution multi-frame image fusion two-input in-app processing.</td> </tr>
613 * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code RECORD}</td> <td></td><td id="rb"></td> <td>High-resolution ZSL in-app video processing with regular preview.</td> </tr>
614 * <tr> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td></td><td id="rb"></td> <td>Maximum-resolution ZSL in-app processing with regular preview.</td> </tr>
615 * <tr> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td></td><td id="rb"></td> <td>Maximum-resolution two-input ZSL in-app processing.</td> </tr>
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700616 * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>ZSL still capture and in-app processing.</td> </tr>
617 * </table><br>
618 * </p>
619 *
620 * <p>RAW-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
621 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}) devices additionally support
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700622 * at least the following stream combinations for creating a reprocessable capture session
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700623 * on both {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} and
624 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices
625 *
626 * <table>
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700627 * <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 Chenf723db72015-04-30 13:06:09 -0700628 * <tr><th colspan="2" id="rb">Input</th><th colspan="2" id="rb">Target 1</th><th colspan="2" id="rb">Target 2</th><th colspan="2" id="rb">Target 3</th><th colspan="2" id="rb">Target 4</th><th rowspan="2">Sample use case(s)</th> </tr>
629 * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th></tr>
630 * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td></td><td id="rb"></td> <td>Mutually exclusive ZSL in-app processing and DNG capture.</td> </tr>
631 * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>Mutually exclusive ZSL in-app processing and preview with DNG capture.</td> </tr>
632 * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>Mutually exclusive ZSL two-input in-app processing and DNG capture.</td> </tr>
633 * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>Mutually exclusive ZSL still capture and preview with DNG capture.</td> </tr>
634 * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>Mutually exclusive ZSL in-app processing with still capture and DNG capture.</td> </tr>
635 * </table><br>
636 * </p>
637 *
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800638 * <p>LEVEL-3 ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
639 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_3 LEVEL_3}) devices
640 * support at least the following stream combinations for creating a reprocessable capture
641 * session in addition to those for
Eino-Ville Talvalaefa0be92016-01-27 14:16:20 -0800642 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} devices. Note that while
643 * the second configuration allows for configuring {@code MAXIMUM} {@code YUV} and {@code JPEG}
644 * outputs at the same time, that configuration is not listed for regular capture sessions, and
645 * therefore simultaneous output to both targets is not allowed.
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800646 *
647 * <table>
648 * <tr><th colspan="13">LEVEL-3 additional guaranteed configurations for creating a reprocessable capture session<br>({@code PRIV} input is guaranteed only if PRIVATE reprocessing is supported. {@code YUV} input is always guaranteed.</th></tr>
Eino-Ville Talvalaefa0be92016-01-27 14:16:20 -0800649 * <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 Talvala7c6d73f2016-01-21 13:55:11 -0800650 * <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 Talvalaefa0be92016-01-27 14:16:20 -0800651 * <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 Talvala7c6d73f2016-01-21 13:55:11 -0800652 * <tr> <td>{@code PRIV}/{@code YUV}</td><td id="rb">{@code MAXIMUM}</td> <td>Same as input</td><td id="rb">{@code MAXIMUM}</td> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td> <td>{@code PRIV}</td><td id="rb">{@code 640x480}</td> <td>{@code RAW}</td><td id="rb">{@code MAXIMUM}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td><td>In-app viewfinder analysis with ZSL, RAW, and JPEG reprocessing output.</td> </tr>
653 * </table><br>
654 * </p>
655 *
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700656 * @param inputConfig The configuration for the input {@link Surface}
657 * @param outputs The new set of Surfaces that should be made available as
658 * targets for captured image data.
659 * @param callback The callback to notify about the status of the new capture session.
660 * @param handler The handler on which the callback should be invoked, or {@code null} to use
661 * the current thread's {@link android.os.Looper looper}.
662 *
663 * @throws IllegalArgumentException if the input configuration is null or not supported, the set
664 * of output Surfaces do not meet the requirements, the
665 * callback is null, or the handler is null but the current
666 * thread has no looper.
667 * @throws CameraAccessException if the camera device is no longer connected or has
668 * encountered a fatal error
669 * @throws IllegalStateException if the camera device has been closed
670 *
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700671 * @see #createCaptureSession
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700672 * @see CameraCaptureSession
673 * @see StreamConfigurationMap#getInputFormats
674 * @see StreamConfigurationMap#getInputSizes
675 * @see StreamConfigurationMap#getValidOutputFormatsForInput
676 * @see StreamConfigurationMap#getOutputSizes
677 * @see android.media.ImageWriter
678 * @see android.media.ImageReader
679 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700680 public abstract void createReprocessableCaptureSession(@NonNull InputConfiguration inputConfig,
681 @NonNull List<Surface> outputs, @NonNull CameraCaptureSession.StateCallback callback,
682 @Nullable Handler handler)
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700683 throws CameraAccessException;
Yin-Chia Yeh49ea6ae2015-03-09 16:53:14 -0700684
685 /**
Zhijun He445b3162016-01-18 15:34:28 -0800686 * Create a new reprocessable camera capture session by providing the desired reprocessing
687 * input configuration and output {@link OutputConfiguration}
688 * to the camera device.
689 *
690 * @see #createReprocessableCaptureSession
691 * @see OutputConfiguration
692 *
693 */
Zhijun He00347432016-04-07 17:34:10 -0700694 public abstract void createReprocessableCaptureSessionByConfigurations(
Zhijun He445b3162016-01-18 15:34:28 -0800695 @NonNull InputConfiguration inputConfig,
696 @NonNull List<OutputConfiguration> outputs,
697 @NonNull CameraCaptureSession.StateCallback callback,
698 @Nullable Handler handler)
699 throws CameraAccessException;
700
701 /**
Zhijun Heb1300e32015-05-28 12:51:52 -0700702 * <p>Create a new constrained high speed capture session.</p>
703 *
704 * <p>The application can use normal capture session (created via {@link #createCaptureSession})
705 * for high speed capture if the desired high speed FPS ranges are advertised by
706 * {@link CameraCharacteristics#CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES}, in which case all API
707 * semantics associated with normal capture sessions applies.</p>
708 *
709 * <p>The method creates a specialized capture session that is only targeted at high speed
710 * video recording (>=120fps) use case if the camera device supports high speed video
711 * capability (i.e., {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} contains
712 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO}).
713 * Therefore, it has special characteristics compared with a normal capture session:</p>
714 *
715 * <ul>
716 *
717 * <li>In addition to the output target Surface requirements specified by the
718 * {@link #createCaptureSession} method, an active high speed capture session will support up
719 * to 2 output Surfaces, though the application might choose to configure just one Surface
720 * (e.g., preview only). All Surfaces must be either video encoder surfaces (acquired by
721 * {@link android.media.MediaRecorder#getSurface} or
722 * {@link android.media.MediaCodec#createInputSurface}) or preview surfaces (obtained from
723 * {@link android.view.SurfaceView}, {@link android.graphics.SurfaceTexture} via
724 * {@link android.view.Surface#Surface(android.graphics.SurfaceTexture)}). The Surface sizes
725 * must be one of the sizes reported by {@link StreamConfigurationMap#getHighSpeedVideoSizes}.
726 * When multiple Surfaces are configured, their size must be same.</li>
727 *
728 * <li>An active high speed capture session only accepts request lists created via
Eino-Ville Talvala639fffe2015-06-30 10:34:48 -0700729 * {@link CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList}, and the
730 * request list can only be submitted to this session via
731 * {@link CameraCaptureSession#captureBurst captureBurst}, or
Zhijun Heb1300e32015-05-28 12:51:52 -0700732 * {@link CameraCaptureSession#setRepeatingBurst setRepeatingBurst}.</li>
733 *
734 * <li>The FPS ranges being requested to this session must be selected from
735 * {@link StreamConfigurationMap#getHighSpeedVideoFpsRangesFor}. The application can still use
736 * {@link CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE} to control the desired FPS range.
737 * Switching to an FPS range that has different
738 * {@link android.util.Range#getUpper() maximum FPS} may trigger some camera device
739 * reconfigurations, which may introduce extra latency. It is recommended that the
740 * application avoids unnecessary maximum target FPS changes as much as possible during high
741 * speed streaming.</li>
742 *
743 * <li>For the request lists submitted to this session, the camera device will override the
744 * {@link CaptureRequest#CONTROL_MODE control mode}, auto-exposure (AE), auto-white balance
745 * (AWB) and auto-focus (AF) to {@link CameraMetadata#CONTROL_MODE_AUTO},
746 * {@link CameraMetadata#CONTROL_AE_MODE_ON}, {@link CameraMetadata#CONTROL_AWB_MODE_AUTO}
747 * and {@link CameraMetadata#CONTROL_AF_MODE_CONTINUOUS_VIDEO}, respectively. All
748 * post-processing block mode controls will be overridden to be FAST. Therefore, no manual
749 * control of capture and post-processing parameters is possible. Beside these, only a subset
750 * of controls will work, see
751 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO} for
752 * more details.</li>
753 *
754 * </ul>
755 *
756 * @param outputs The new set of Surfaces that should be made available as
757 * targets for captured high speed image data.
758 * @param callback The callback to notify about the status of the new capture session.
759 * @param handler The handler on which the callback should be invoked, or {@code null} to use
760 * the current thread's {@link android.os.Looper looper}.
761 *
762 * @throws IllegalArgumentException if the set of output Surfaces do not meet the requirements,
763 * the callback is null, or the handler is null but the current
764 * thread has no looper, or the camera device doesn't support
765 * high speed video capability.
766 * @throws CameraAccessException if the camera device is no longer connected or has
767 * encountered a fatal error
768 * @throws IllegalStateException if the camera device has been closed
769 *
770 * @see #createCaptureSession
771 * @see CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE
772 * @see StreamConfigurationMap#getHighSpeedVideoSizes
773 * @see StreamConfigurationMap#getHighSpeedVideoFpsRangesFor
774 * @see CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES
775 * @see CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO
776 * @see CameraCaptureSession#captureBurst
777 * @see CameraCaptureSession#setRepeatingBurst
Eino-Ville Talvala639fffe2015-06-30 10:34:48 -0700778 * @see CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList
Zhijun Heb1300e32015-05-28 12:51:52 -0700779 */
780 public abstract void createConstrainedHighSpeedCaptureSession(@NonNull List<Surface> outputs,
781 @NonNull CameraCaptureSession.StateCallback callback,
782 @Nullable Handler handler)
783 throws CameraAccessException;
784
Zhijun Heb1300e32015-05-28 12:51:52 -0700785 /**
Eino-Ville Talvala49c62f52017-02-28 17:57:28 -0800786 * Standard camera operation mode.
787 *
788 * @see #createCustomCaptureSession
789 * @hide
790 */
791 @SystemApi
792 @TestApi
793 public static final int SESSION_OPERATION_MODE_NORMAL =
Eino-Ville Talvala4e79fe72017-03-08 16:02:48 -0800794 0; // ICameraDeviceUser.NORMAL_MODE;
Eino-Ville Talvala49c62f52017-02-28 17:57:28 -0800795
796 /**
797 * Constrained high-speed operation mode.
798 *
799 * @see #createCustomCaptureSession
800 * @hide
801 */
802 @SystemApi
803 @TestApi
804 public static final int SESSION_OPERATION_MODE_CONSTRAINED_HIGH_SPEED =
Eino-Ville Talvala4e79fe72017-03-08 16:02:48 -0800805 1; // ICameraDeviceUser.CONSTRAINED_HIGH_SPEED_MODE;
Eino-Ville Talvala49c62f52017-02-28 17:57:28 -0800806
807 /**
808 * First vendor-specific operating mode
809 *
810 * @see #createCustomCaptureSession
811 * @hide
812 */
813 @SystemApi
814 @TestApi
815 public static final int SESSION_OPERATION_MODE_VENDOR_START =
Eino-Ville Talvala4e79fe72017-03-08 16:02:48 -0800816 0x8000; // ICameraDeviceUser.VENDOR_MODE_START;
Eino-Ville Talvala49c62f52017-02-28 17:57:28 -0800817
818 /** @hide */
819 @Retention(RetentionPolicy.SOURCE)
Eino-Ville Talvala16ffbc62017-04-24 13:10:21 -0700820 @IntDef(prefix = {"SESSION_OPERATION_MODE"}, value =
Eino-Ville Talvala49c62f52017-02-28 17:57:28 -0800821 {SESSION_OPERATION_MODE_NORMAL,
822 SESSION_OPERATION_MODE_CONSTRAINED_HIGH_SPEED,
823 SESSION_OPERATION_MODE_VENDOR_START})
824 public @interface SessionOperatingMode {};
825
826 /**
Eino-Ville Talvala0e04e912017-02-28 17:49:41 -0800827 * Create a new camera capture session with a custom operating mode.
828 *
829 * @param inputConfig The configuration for the input {@link Surface} if a reprocessing session
830 * is desired, or {@code null} otherwise.
831 * @param outputs The new set of {@link OutputConfiguration OutputConfigurations} that should be
832 * made available as targets for captured image data.
Eino-Ville Talvala49c62f52017-02-28 17:57:28 -0800833 * @param operatingMode The custom operating mode to use; a nonnegative value, either a custom
834 * vendor value or one of the SESSION_OPERATION_MODE_* values.
Eino-Ville Talvala0e04e912017-02-28 17:49:41 -0800835 * @param callback The callback to notify about the status of the new capture session.
836 * @param handler The handler on which the callback should be invoked, or {@code null} to use
837 * the current thread's {@link android.os.Looper looper}.
838 *
839 * @throws IllegalArgumentException if the input configuration is null or not supported, the set
840 * of output Surfaces do not meet the requirements, the
841 * callback is null, or the handler is null but the current
842 * thread has no looper.
843 * @throws CameraAccessException if the camera device is no longer connected or has
844 * encountered a fatal error
845 * @throws IllegalStateException if the camera device has been closed
846 *
847 * @see #createCaptureSession
848 * @see #createReprocessableCaptureSession
849 * @see CameraCaptureSession
850 * @see OutputConfiguration
851 * @hide
852 */
Eino-Ville Talvala49c62f52017-02-28 17:57:28 -0800853 @SystemApi
854 @TestApi
Eino-Ville Talvala0e04e912017-02-28 17:49:41 -0800855 public abstract void createCustomCaptureSession(
856 InputConfiguration inputConfig,
857 @NonNull List<OutputConfiguration> outputs,
Eino-Ville Talvala49c62f52017-02-28 17:57:28 -0800858 @SessionOperatingMode int operatingMode,
Eino-Ville Talvala0e04e912017-02-28 17:49:41 -0800859 @NonNull CameraCaptureSession.StateCallback callback,
860 @Nullable Handler handler)
861 throws CameraAccessException;
862
863 /**
Emilian Peev75a55702017-11-07 16:09:59 +0000864 * <p>Create a new {@link CameraCaptureSession} using a {@link SessionConfiguration} helper
865 * object that aggregates all supported parameters.</p>
866 *
867 * @param config A session configuration (see {@link SessionConfiguration}).
868 *
869 * @throws IllegalArgumentException In case the session configuration is invalid; or the output
870 * configurations are empty.
871 * @throws CameraAccessException In case the camera device is no longer connected or has
872 * encountered a fatal error.
873 * @see #createCaptureSession(List, CameraCaptureSession.StateCallback, Handler)
874 * @see #createCaptureSessionByOutputConfigurations
875 * @see #createReprocessableCaptureSession
876 * @see #createConstrainedHighSpeedCaptureSession
877 */
878 public void createCaptureSession(
879 SessionConfiguration config) throws CameraAccessException {
880 throw new UnsupportedOperationException("No default implementation");
881 }
882
883 /**
Eino-Ville Talvala70c22072013-08-27 12:09:04 -0700884 * <p>Create a {@link CaptureRequest.Builder} for new capture requests,
885 * initialized with template for a target use case. The settings are chosen
886 * to be the best options for the specific camera device, so it is not
887 * recommended to reuse the same request for a different camera device;
888 * create a builder specific for that device and template and override the
889 * settings as desired, instead.</p>
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800890 *
Eino-Ville Talvala16ffbc62017-04-24 13:10:21 -0700891 * @param templateType An enumeration selecting the use case for this request. Not all template
892 * types are supported on every device. See the documentation for each template type for
893 * details.
Eino-Ville Talvala70c22072013-08-27 12:09:04 -0700894 * @return a builder for a capture request, initialized with default
895 * settings for that template, and no output streams
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800896 *
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -0700897 * @throws IllegalArgumentException if the templateType is not supported by
898 * this device.
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700899 * @throws CameraAccessException if the camera device is no longer connected or has
900 * encountered a fatal error
901 * @throws IllegalStateException if the camera device has been closed
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800902 *
903 * @see #TEMPLATE_PREVIEW
904 * @see #TEMPLATE_RECORD
905 * @see #TEMPLATE_STILL_CAPTURE
906 * @see #TEMPLATE_VIDEO_SNAPSHOT
907 * @see #TEMPLATE_MANUAL
908 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700909 @NonNull
910 public abstract CaptureRequest.Builder createCaptureRequest(@RequestTemplate int templateType)
Igor Murashkin70725502013-06-25 20:27:06 +0000911 throws CameraAccessException;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800912
913 /**
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700914 * <p>Create a {@link CaptureRequest.Builder} for a new reprocess {@link CaptureRequest} from a
915 * {@link TotalCaptureResult}.
916 *
917 * <p>Each reprocess {@link CaptureRequest} processes one buffer from
918 * {@link CameraCaptureSession}'s input {@link Surface} to all output {@link Surface Surfaces}
919 * included in the reprocess capture request. The reprocess input images must be generated from
920 * one or multiple output images captured from the same camera device. The application can
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700921 * provide input images to camera device via {@link android.media.ImageWriter#queueInputImage}.
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700922 * The application must use the capture result of one of those output images to create a
923 * reprocess capture request so that the camera device can use the information to achieve
Chien-Yu Chene90c6d02015-08-25 11:31:58 -0700924 * optimal reprocess image quality. For camera devices that support only 1 output
925 * {@link Surface}, submitting a reprocess {@link CaptureRequest} with multiple
926 * output targets will result in a {@link CaptureFailure}.
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700927 *
928 * @param inputResult The capture result of the output image or one of the output images used
929 * to generate the reprocess input image for this capture request.
930 *
931 * @throws IllegalArgumentException if inputResult is null.
932 * @throws CameraAccessException if the camera device is no longer connected or has
933 * encountered a fatal error
934 * @throws IllegalStateException if the camera device has been closed
935 *
936 * @see CaptureRequest.Builder
937 * @see TotalCaptureResult
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700938 * @see CameraDevice#createReprocessableCaptureSession
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700939 * @see android.media.ImageWriter
940 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700941 @NonNull
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700942 public abstract CaptureRequest.Builder createReprocessCaptureRequest(
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700943 @NonNull TotalCaptureResult inputResult) throws CameraAccessException;
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700944
945 /**
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700946 * Close the connection to this camera device as quickly as possible.
Eino-Ville Talvala868d9042013-10-03 11:15:21 -0700947 *
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700948 * <p>Immediately after this call, all calls to the camera device or active session interface
949 * will throw a {@link IllegalStateException}, except for calls to close(). Once the device has
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700950 * fully shut down, the {@link StateCallback#onClosed} callback will be called, and the camera
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700951 * is free to be re-opened.</p>
Eino-Ville Talvala868d9042013-10-03 11:15:21 -0700952 *
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700953 * <p>Immediately after this call, besides the final {@link StateCallback#onClosed} calls, no
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700954 * further callbacks from the device or the active session will occur, and any remaining
955 * submitted capture requests will be discarded, as if
956 * {@link CameraCaptureSession#abortCaptures} had been called, except that no success or failure
957 * callbacks will be invoked.</p>
Eino-Ville Talvala868d9042013-10-03 11:15:21 -0700958 *
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800959 */
Igor Murashkine363fbb2013-06-25 20:26:06 +0000960 @Override
Igor Murashkin21547d62014-06-04 15:21:42 -0700961 public abstract void close();
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800962
963 /**
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700964 * A callback objects for receiving updates about the state of a camera device.
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700965 *
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700966 * <p>A callback instance must be provided to the {@link CameraManager#openCamera} method to
967 * open a camera device.</p>
Eino-Ville Talvala868d9042013-10-03 11:15:21 -0700968 *
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700969 * <p>These state updates include notifications about the device completing startup (
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -0700970 * allowing for {@link #createCaptureSession} to be called), about device
971 * disconnection or closure, and about unexpected device errors.</p>
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700972 *
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -0700973 * <p>Events about the progress of specific {@link CaptureRequest CaptureRequests} are provided
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700974 * through a {@link CameraCaptureSession.CaptureCallback} given to the
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -0700975 * {@link CameraCaptureSession#capture}, {@link CameraCaptureSession#captureBurst},
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700976 * {@link CameraCaptureSession#setRepeatingRequest}, or
977 * {@link CameraCaptureSession#setRepeatingBurst} methods.
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700978 *
Eino-Ville Talvala868d9042013-10-03 11:15:21 -0700979 * @see CameraManager#openCamera
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800980 */
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700981 public static abstract class StateCallback {
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700982 /**
983 * An error code that can be reported by {@link #onError}
984 * indicating that the camera device is in use already.
985 *
986 * <p>
Ruben Brunk0f2be132015-04-17 14:23:40 -0700987 * This error can be produced when opening the camera fails due to the camera
988 * being used by a higher-priority camera API client.
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700989 * </p>
990 *
991 * @see #onError
992 */
993 public static final int ERROR_CAMERA_IN_USE = 1;
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700994
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800995 /**
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700996 * An error code that can be reported by {@link #onError}
997 * indicating that the camera device could not be opened
998 * because there are too many other open camera devices.
999 *
1000 * <p>
1001 * The system-wide limit for number of open cameras has been reached,
1002 * and more camera devices cannot be opened until previous instances are
1003 * closed.
1004 * </p>
1005 *
1006 * <p>
1007 * This error can be produced when opening the camera fails.
1008 * </p>
1009 *
1010 * @see #onError
1011 */
1012 public static final int ERROR_MAX_CAMERAS_IN_USE = 2;
1013
1014 /**
1015 * An error code that can be reported by {@link #onError}
1016 * indicating that the camera device could not be opened due to a device
1017 * policy.
1018 *
1019 * @see android.app.admin.DevicePolicyManager#setCameraDisabled(android.content.ComponentName, boolean)
1020 * @see #onError
1021 */
1022 public static final int ERROR_CAMERA_DISABLED = 3;
1023
1024 /**
1025 * An error code that can be reported by {@link #onError}
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001026 * indicating that the camera device has encountered a fatal error.
1027 *
1028 * <p>The camera device needs to be re-opened to be used again.</p>
1029 *
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001030 * @see #onError
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001031 */
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001032 public static final int ERROR_CAMERA_DEVICE = 4;
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001033
1034 /**
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001035 * An error code that can be reported by {@link #onError}
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001036 * indicating that the camera service has encountered a fatal error.
1037 *
1038 * <p>The Android device may need to be shut down and restarted to restore
1039 * camera function, or there may be a persistent hardware problem.</p>
1040 *
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001041 * <p>An attempt at recovery <i>may</i> be possible by closing the
1042 * CameraDevice and the CameraManager, and trying to acquire all resources
1043 * again from scratch.</p>
1044 *
1045 * @see #onError
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001046 */
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001047 public static final int ERROR_CAMERA_SERVICE = 5;
1048
Eino-Ville Talvala8b905572015-05-14 15:43:01 -07001049 /** @hide */
1050 @Retention(RetentionPolicy.SOURCE)
Eino-Ville Talvala16ffbc62017-04-24 13:10:21 -07001051 @IntDef(prefix = {"ERROR_"}, value =
Eino-Ville Talvala8b905572015-05-14 15:43:01 -07001052 {ERROR_CAMERA_IN_USE,
1053 ERROR_MAX_CAMERAS_IN_USE,
1054 ERROR_CAMERA_DISABLED,
1055 ERROR_CAMERA_DEVICE,
1056 ERROR_CAMERA_SERVICE })
1057 public @interface ErrorCode {};
1058
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001059 /**
1060 * The method called when a camera device has finished opening.
1061 *
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -07001062 * <p>At this point, the camera device is ready to use, and
1063 * {@link CameraDevice#createCaptureSession} can be called to set up the first capture
1064 * session.</p>
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001065 *
1066 * @param camera the camera device that has become opened
1067 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -07001068 public abstract void onOpened(@NonNull CameraDevice camera); // Must implement
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001069
1070 /**
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001071 * The method called when a camera device has been closed with
1072 * {@link CameraDevice#close}.
1073 *
1074 * <p>Any attempt to call methods on this CameraDevice in the
1075 * future will throw a {@link IllegalStateException}.</p>
1076 *
1077 * <p>The default implementation of this method does nothing.</p>
1078 *
1079 * @param camera the camera device that has become closed
1080 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -07001081 public void onClosed(@NonNull CameraDevice camera) {
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001082 // Default empty implementation
1083 }
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001084
1085 /**
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001086 * The method called when a camera device is no longer available for
1087 * use.
1088 *
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001089 * <p>This callback may be called instead of {@link #onOpened}
1090 * if opening the camera fails.</p>
1091 *
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001092 * <p>Any attempt to call methods on this CameraDevice will throw a
1093 * {@link CameraAccessException}. The disconnection could be due to a
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08001094 * change in security policy or permissions; the physical disconnection
1095 * of a removable camera device; or the camera being needed for a
Ruben Brunk0f2be132015-04-17 14:23:40 -07001096 * higher-priority camera API client.</p>
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08001097 *
Eino-Ville Talvalafd887432014-09-04 13:07:40 -07001098 * <p>There may still be capture callbacks that are invoked
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001099 * after this method is called, or new image buffers that are delivered
1100 * to active outputs.</p>
1101 *
1102 * <p>The default implementation logs a notice to the system log
1103 * about the disconnection.</p>
1104 *
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001105 * <p>You should clean up the camera with {@link CameraDevice#close} after
Ruben Brunk0f2be132015-04-17 14:23:40 -07001106 * this happens, as it is not recoverable until the camera can be opened
1107 * again. For most use cases, this will be when the camera again becomes
1108 * {@link CameraManager.AvailabilityCallback#onCameraAvailable available}.
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001109 * </p>
1110 *
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001111 * @param camera the device that has been disconnected
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08001112 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -07001113 public abstract void onDisconnected(@NonNull CameraDevice camera); // Must implement
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08001114
1115 /**
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001116 * The method called when a camera device has encountered a serious error.
1117 *
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001118 * <p>This callback may be called instead of {@link #onOpened}
1119 * if opening the camera fails.</p>
1120 *
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001121 * <p>This indicates a failure of the camera device or camera service in
1122 * some way. Any attempt to call methods on this CameraDevice in the
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001123 * future will throw a {@link CameraAccessException} with the
1124 * {@link CameraAccessException#CAMERA_ERROR CAMERA_ERROR} reason.
1125 * </p>
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08001126 *
Eino-Ville Talvalafd887432014-09-04 13:07:40 -07001127 * <p>There may still be capture completion or camera stream callbacks
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08001128 * that will be called after this error is received.</p>
1129 *
Igor Murashkin5c9eaf62013-09-10 19:35:24 -07001130 * <p>You should clean up the camera with {@link CameraDevice#close} after
1131 * this happens. Further attempts at recovery are error-code specific.</p>
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08001132 *
1133 * @param camera The device reporting the error
Eino-Ville Talvala16ffbc62017-04-24 13:10:21 -07001134 * @param error The error code.
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001135 *
Eino-Ville Talvala8b905572015-05-14 15:43:01 -07001136 * @see #ERROR_CAMERA_IN_USE
1137 * @see #ERROR_MAX_CAMERAS_IN_USE
1138 * @see #ERROR_CAMERA_DISABLED
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -07001139 * @see #ERROR_CAMERA_DEVICE
1140 * @see #ERROR_CAMERA_SERVICE
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08001141 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -07001142 public abstract void onError(@NonNull CameraDevice camera,
1143 @ErrorCode int error); // Must implement
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08001144 }
Igor Murashkin21547d62014-06-04 15:21:42 -07001145
1146 /**
1147 * To be inherited by android.hardware.camera2.* code only.
1148 * @hide
1149 */
1150 public CameraDevice() {}
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08001151}