blob: 6aacc9cf3df71e78b7a105a04279a3f40c93ea25 [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;
Chien-Yu Chen5398a672015-03-19 14:48:43 -070022import android.hardware.camera2.params.InputConfiguration;
Igor Murashkin9c595172014-05-12 13:56:20 -070023import android.hardware.camera2.params.StreamConfigurationMap;
Yin-Chia Yeh49ea6ae2015-03-09 16:53:14 -070024import android.hardware.camera2.params.OutputConfiguration;
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -070025import android.os.Handler;
Zhijun He599be612013-09-27 13:43:25 -070026import android.view.Surface;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080027
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080028import java.util.List;
Eino-Ville Talvala8b905572015-05-14 15:43:01 -070029import java.lang.annotation.Retention;
30import java.lang.annotation.RetentionPolicy;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080031
32/**
Igor Murashkin21547d62014-06-04 15:21:42 -070033 * <p>The CameraDevice class is a representation of a single camera connected to an
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080034 * Android device, allowing for fine-grain control of image capture and
35 * post-processing at high frame rates.</p>
36 *
37 * <p>Your application must declare the
38 * {@link android.Manifest.permission#CAMERA Camera} permission in its manifest
39 * in order to access camera devices.</p>
40 *
41 * <p>A given camera device may provide support at one of two levels: limited or
42 * full. If a device only supports the limited level, then Camera2 exposes a
43 * feature set that is roughly equivalent to the older
44 * {@link android.hardware.Camera Camera} API, although with a cleaner and more
45 * efficient interface. Devices that implement the full level of support
46 * provide substantially improved capabilities over the older camera
47 * API. Applications that target the limited level devices will run unchanged on
48 * the full-level devices; if your application requires a full-level device for
Yin-Chia Yeha636be62015-10-06 13:45:20 -070049 * proper operation, declare the "android.hardware.camera.level.full" feature in your
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080050 * manifest.</p>
51 *
52 * @see CameraManager#openCamera
53 * @see android.Manifest.permission#CAMERA
54 */
Igor Murashkin21547d62014-06-04 15:21:42 -070055public abstract class CameraDevice implements AutoCloseable {
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080056
57 /**
58 * Create a request suitable for a camera preview window. Specifically, this
59 * means that high frame rate is given priority over the highest-quality
60 * post-processing. These requests would normally be used with the
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -070061 * {@link CameraCaptureSession#setRepeatingRequest} method.
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -070062 * This template is guaranteed to be supported on all camera devices.
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080063 *
64 * @see #createCaptureRequest
65 */
66 public static final int TEMPLATE_PREVIEW = 1;
67
68 /**
Zhijun Heb8b77bf2013-06-28 16:30:12 -070069 * Create a request suitable for still image capture. Specifically, this
70 * means prioritizing image quality over frame rate. These requests would
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -070071 * commonly be used with the {@link CameraCaptureSession#capture} method.
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -070072 * This template is guaranteed to be supported on all camera devices.
Zhijun Heb8b77bf2013-06-28 16:30:12 -070073 *
74 * @see #createCaptureRequest
75 */
76 public static final int TEMPLATE_STILL_CAPTURE = 2;
77
78 /**
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080079 * Create a request suitable for video recording. Specifically, this means
80 * that a stable frame rate is used, and post-processing is set for
81 * recording quality. These requests would commonly be used with the
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -070082 * {@link CameraCaptureSession#setRepeatingRequest} method.
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -070083 * This template is guaranteed to be supported on all camera devices.
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080084 *
85 * @see #createCaptureRequest
86 */
Zhijun Heb8b77bf2013-06-28 16:30:12 -070087 public static final int TEMPLATE_RECORD = 3;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080088
89 /**
90 * Create a request suitable for still image capture while recording
91 * video. Specifically, this means maximizing image quality without
92 * disrupting the ongoing recording. These requests would commonly be used
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -070093 * with the {@link CameraCaptureSession#capture} method while a request based on
94 * {@link #TEMPLATE_RECORD} is is in use with {@link CameraCaptureSession#setRepeatingRequest}.
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -070095 * This template is guaranteed to be supported on all camera devices except
96 * legacy devices ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
97 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY})
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080098 *
99 * @see #createCaptureRequest
100 */
101 public static final int TEMPLATE_VIDEO_SNAPSHOT = 4;
102
103 /**
Zhijun Hebbae94a2013-09-13 11:32:20 -0700104 * Create a request suitable for zero shutter lag still capture. This means
105 * means maximizing image quality without compromising preview frame rate.
106 * AE/AWB/AF should be on auto mode.
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -0700107 * This template is guaranteed to be supported on camera devices that support the
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700108 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING PRIVATE_REPROCESSING}
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -0700109 * capability or the
110 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING YUV_REPROCESSING}
111 * capability.
Zhijun Hebbae94a2013-09-13 11:32:20 -0700112 *
113 * @see #createCaptureRequest
Zhijun Hebbae94a2013-09-13 11:32:20 -0700114 */
115 public static final int TEMPLATE_ZERO_SHUTTER_LAG = 5;
116
117 /**
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800118 * A basic template for direct application control of capture
119 * parameters. All automatic control is disabled (auto-exposure, auto-white
120 * balance, auto-focus), and post-processing parameters are set to preview
121 * quality. The manual capture parameters (exposure, sensitivity, and so on)
122 * are set to reasonable defaults, but should be overriden by the
123 * application depending on the intended use case.
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -0700124 * This template is guaranteed to be supported on camera devices that support the
125 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR MANUAL_SENSOR}
126 * capability.
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800127 *
128 * @see #createCaptureRequest
129 */
Zhijun Hebbae94a2013-09-13 11:32:20 -0700130 public static final int TEMPLATE_MANUAL = 6;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800131
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700132 /** @hide */
133 @Retention(RetentionPolicy.SOURCE)
134 @IntDef(
135 {TEMPLATE_PREVIEW,
136 TEMPLATE_STILL_CAPTURE,
137 TEMPLATE_RECORD,
138 TEMPLATE_VIDEO_SNAPSHOT,
139 TEMPLATE_ZERO_SHUTTER_LAG,
140 TEMPLATE_MANUAL })
141 public @interface RequestTemplate {};
142
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800143 /**
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700144 * Get the ID of this camera device.
145 *
146 * <p>This matches the ID given to {@link CameraManager#openCamera} to instantiate this
147 * this camera device.</p>
148 *
149 * <p>This ID can be used to query the camera device's {@link
Igor Murashkin68f40062013-09-10 12:15:54 -0700150 * CameraCharacteristics fixed properties} with {@link
151 * CameraManager#getCameraCharacteristics}.</p>
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700152 *
153 * <p>This method can be called even if the device has been closed or has encountered
154 * a serious error.</p>
155 *
156 * @return the ID for this camera device
157 *
Igor Murashkin68f40062013-09-10 12:15:54 -0700158 * @see CameraManager#getCameraCharacteristics
Zhijun He599be612013-09-27 13:43:25 -0700159 * @see CameraManager#getCameraIdList
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700160 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700161 @NonNull
Igor Murashkin21547d62014-06-04 15:21:42 -0700162 public abstract String getId();
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700163
164 /**
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700165 * <p>Create a new camera capture session by providing the target output set of Surfaces to the
166 * camera device.</p>
167 *
168 * <p>The active capture session determines the set of potential output Surfaces for
169 * the camera device for each capture request. A given request may use all
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700170 * or only some of the outputs. Once the CameraCaptureSession is created, requests can be
Hidenari Koshimae0fa49142016-01-08 16:18:28 +0900171 * submitted with {@link CameraCaptureSession#capture capture},
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700172 * {@link CameraCaptureSession#captureBurst captureBurst},
173 * {@link CameraCaptureSession#setRepeatingRequest setRepeatingRequest}, or
174 * {@link CameraCaptureSession#setRepeatingBurst setRepeatingBurst}.</p>
175 *
176 * <p>Surfaces suitable for inclusion as a camera output can be created for
177 * various use cases and targets:</p>
178 *
179 * <ul>
180 *
Eino-Ville Talvala5ae1ca52014-06-12 16:46:58 -0700181 * <li>For drawing to a {@link android.view.SurfaceView SurfaceView}: Once the SurfaceView's
Eino-Ville Talvalafa0b9a02015-01-20 12:30:59 -0800182 * Surface is {@link android.view.SurfaceHolder.Callback#surfaceCreated created}, set the size
183 * of the Surface with {@link android.view.SurfaceHolder#setFixedSize} to be one of the sizes
184 * returned by {@link StreamConfigurationMap#getOutputSizes(Class)
185 * getOutputSizes(SurfaceHolder.class)} and then obtain the Surface by calling {@link
186 * android.view.SurfaceHolder#getSurface}. If the size is not set by the application, it will
187 * be rounded to the nearest supported size less than 1080p, by the camera device.</li>
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700188 *
Eino-Ville Talvalafa0b9a02015-01-20 12:30:59 -0800189 * <li>For accessing through an OpenGL texture via a {@link android.graphics.SurfaceTexture
190 * SurfaceTexture}: Set the size of the SurfaceTexture with {@link
191 * android.graphics.SurfaceTexture#setDefaultBufferSize} to be one of the sizes returned by
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700192 * {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(SurfaceTexture.class)}
Eino-Ville Talvalafa0b9a02015-01-20 12:30:59 -0800193 * before creating a Surface from the SurfaceTexture with {@link Surface#Surface}. If the size
194 * is not set by the application, it will be set to be the smallest supported size less than
195 * 1080p, by the camera device.</li>
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700196 *
197 * <li>For recording with {@link android.media.MediaCodec}: Call
198 * {@link android.media.MediaCodec#createInputSurface} after configuring
199 * the media codec to use one of the sizes returned by
200 * {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(MediaCodec.class)}
201 * </li>
202 *
203 * <li>For recording with {@link android.media.MediaRecorder}: Call
204 * {@link android.media.MediaRecorder#getSurface} after configuring the media recorder to use
205 * one of the sizes returned by
206 * {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(MediaRecorder.class)},
207 * or configuring it to use one of the supported
208 * {@link android.media.CamcorderProfile CamcorderProfiles}.</li>
209 *
210 * <li>For efficient YUV processing with {@link android.renderscript}:
211 * Create a RenderScript
212 * {@link android.renderscript.Allocation Allocation} with a supported YUV
213 * type, the IO_INPUT flag, and one of the sizes returned by
214 * {@link StreamConfigurationMap#getOutputSizes(Class) getOutputSizes(Allocation.class)},
215 * Then obtain the Surface with
216 * {@link android.renderscript.Allocation#getSurface}.</li>
217 *
Martin Storsjo5c533e42014-11-19 11:58:03 +0200218 * <li>For access to RAW, uncompressed YUV, or compressed JPEG data in the application: Create an
Sol Boucherb8cee512014-06-11 16:35:57 -0700219 * {@link android.media.ImageReader} object with one of the supported output formats given by
220 * {@link StreamConfigurationMap#getOutputFormats()}, setting its size to one of the
221 * corresponding supported sizes by passing the chosen output format into
222 * {@link StreamConfigurationMap#getOutputSizes(int)}. Then obtain a
223 * {@link android.view.Surface} from it with {@link android.media.ImageReader#getSurface()}.
Eino-Ville Talvalafa0b9a02015-01-20 12:30:59 -0800224 * If the ImageReader size is not set to a supported size, it will be rounded to a supported
225 * size less than 1080p by the camera device.
Sol Boucherb8cee512014-06-11 16:35:57 -0700226 * </li>
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700227 *
228 * </ul>
229 *
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700230 * <p>The camera device will query each Surface's size and formats upon this
Sol Boucherb8cee512014-06-11 16:35:57 -0700231 * call, so they must be set to a valid setting at this time.</p>
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700232 *
233 * <p>It can take several hundred milliseconds for the session's configuration to complete,
234 * since camera hardware may need to be powered on or reconfigured. Once the configuration is
235 * complete and the session is ready to actually capture data, the provided
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700236 * {@link CameraCaptureSession.StateCallback}'s
237 * {@link CameraCaptureSession.StateCallback#onConfigured} callback will be called.</p>
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700238 *
Chien-Yu Chen078c92a2015-06-25 16:54:17 -0700239 * <p>If a prior CameraCaptureSession already exists when this method is called, the previous
240 * session will no longer be able to accept new capture requests and will be closed. Any
241 * in-progress capture requests made on the prior session will be completed before it's closed.
242 * {@link CameraCaptureSession.StateListener#onConfigured} for the new session may be invoked
243 * before {@link CameraCaptureSession.StateListener#onClosed} is invoked for the prior
244 * session. Once the new session is {@link CameraCaptureSession.StateListener#onConfigured
245 * configured}, it is able to start capturing its own requests. To minimize the transition time,
246 * the {@link CameraCaptureSession#abortCaptures} call can be used to discard the remaining
247 * requests for the prior capture session before a new one is created. Note that once the new
248 * session is created, the old one can no longer have its captures aborted.</p>
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700249 *
250 * <p>Using larger resolution outputs, or more outputs, can result in slower
251 * output rate from the device.</p>
252 *
253 * <p>Configuring a session with an empty or null list will close the current session, if
254 * any. This can be used to release the current session's target surfaces for another use.</p>
255 *
Eino-Ville Talvalaf3621f32014-08-26 14:53:39 -0700256 * <p>While any of the sizes from {@link StreamConfigurationMap#getOutputSizes} can be used when
257 * a single output stream is configured, a given camera device may not be able to support all
258 * combination of sizes, formats, and targets when multiple outputs are configured at once. The
259 * tables below list the maximum guaranteed resolutions for combinations of streams and targets,
260 * given the capabilities of the camera device.</p>
261 *
262 * <p>If an application tries to create a session using a set of targets that exceed the limits
263 * described in the below tables, one of three possibilities may occur. First, the session may
264 * be successfully created and work normally. Second, the session may be successfully created,
265 * but the camera device won't meet the frame rate guarantees as described in
266 * {@link StreamConfigurationMap#getOutputMinFrameDuration}. Or third, if the output set
267 * cannot be used at all, session creation will fail entirely, with
268 * {@link CameraCaptureSession.StateListener#onConfigureFailed} being invoked.</p>
269 *
270 * <p>For the type column, {@code PRIV} refers to any target whose available sizes are found
271 * using {@link StreamConfigurationMap#getOutputSizes(Class)} with no direct application-visible
272 * format, {@code YUV} refers to a target Surface using the
273 * {@link android.graphics.ImageFormat#YUV_420_888} format, {@code JPEG} refers to the
274 * {@link android.graphics.ImageFormat#JPEG} format, and {@code RAW} refers to the
275 * {@link android.graphics.ImageFormat#RAW_SENSOR} format.</p>
276 *
277 * <p>For the maximum size column, {@code PREVIEW} refers to the best size match to the
278 * device's screen resolution, or to 1080p ({@code 1920x1080}), whichever is
279 * smaller. {@code RECORD} refers to the camera device's maximum supported recording resolution,
280 * as determined by {@link android.media.CamcorderProfile}. And {@code MAXIMUM} refers to the
281 * camera device's maximum output resolution for that format or target from
282 * {@link StreamConfigurationMap#getOutputSizes}.</p>
283 *
284 * <p>To use these tables, determine the number and the formats/targets of outputs needed, and
285 * find the row(s) of the table with those targets. The sizes indicate the maximum set of sizes
286 * that can be used; it is guaranteed that for those targets, the listed sizes and anything
287 * smaller from the list given by {@link StreamConfigurationMap#getOutputSizes} can be
288 * successfully used to create a session. For example, if a row indicates that a 8 megapixel
289 * (MP) YUV_420_888 output can be used together with a 2 MP {@code PRIV} output, then a session
290 * can be created with targets {@code [8 MP YUV, 2 MP PRIV]} or targets {@code [2 MP YUV, 2 MP
291 * PRIV]}; but a session with targets {@code [8 MP YUV, 4 MP PRIV]}, targets {@code [4 MP YUV, 4
292 * MP PRIV]}, or targets {@code [8 MP PRIV, 2 MP YUV]} would not be guaranteed to work, unless
293 * some other row of the table lists such a combination.</p>
294 *
295 * <style scoped>
296 * #rb { border-right-width: thick; }
297 * </style>
298 * <p>Legacy devices ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
299 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY}) support at
300 * least the following stream combinations:
301 *
302 * <table>
303 * <tr><th colspan="7">LEGACY-level guaranteed configurations</th></tr>
304 * <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>
305 * <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>
306 * <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>
307 * <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>
308 * <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>
309 * <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>
310 * <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>
311 * <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>
312 * <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>
313 * <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>
314 * </table><br>
315 * </p>
316 *
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800317 * <p>Limited-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
Eino-Ville Talvalaf3621f32014-08-26 14:53:39 -0700318 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED}) devices
319 * support at least the following stream combinations in addition to those for
320 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY} devices:
321 *
322 * <table>
323 * <tr><th colspan="7">LIMITED-level additional guaranteed configurations</th></tr>
324 * <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>
325 * <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>
326 * <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>
327 * <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>
328 * <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>
329 * <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>
330 * <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>
331 * <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>
332 * </table><br>
333 * </p>
334 *
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800335 * <p>FULL-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
Eino-Ville Talvalaf3621f32014-08-26 14:53:39 -0700336 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) devices
337 * support at least the following stream combinations in addition to those for
338 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
339 *
340 * <table>
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800341 * <tr><th colspan="7">FULL-level additional guaranteed configurations</th></tr>
Eino-Ville Talvalaf3621f32014-08-26 14:53:39 -0700342 * <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>
343 * <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>
344 * <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>
345 * <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>
346 * <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>
347 * <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>
348 * <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>
349 * <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>
350 * </table><br>
351 * </p>
352 *
353 * <p>RAW-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
354 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}) devices additionally support
355 * at least the following stream combinations on both
356 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} and
357 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
358 *
359 * <table>
360 * <tr><th colspan="7">RAW-capability additional guaranteed configurations</th></tr>
361 * <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>
362 * <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>
363 * <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>
364 * <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>
365 * <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>
366 * <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>
367 * <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>
368 * <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>
369 * <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>
370 * <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>
371 * </table><br>
372 * </p>
373 *
Eino-Ville Talvala126a7462014-11-04 16:31:01 -0800374 * <p>BURST-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
375 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE BURST_CAPTURE}) devices
376 * support at least the below stream combinations in addition to those for
377 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices. Note that all
378 * FULL-level devices support the BURST capability, and the below list is a strict subset of the
379 * list for FULL-level devices, so this table is only relevant for LIMITED-level devices that
380 * support the BURST_CAPTURE capability.
381 *
382 * <table>
383 * <tr><th colspan="5">BURST-capability additional guaranteed configurations</th></tr>
384 * <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>
385 * <tr><th>Type</th><th id="rb">Max size</th><th>Type</th><th id="rb">Max size</th> </tr>
386 * <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>
387 * <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>
388 * <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>
389 * </table><br>
390 * </p>
391 *
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800392 * <p>LEVEL-3 ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
393 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_3 LEVEL_3})
394 * support at least the following stream combinations in addition to the combinations for
395 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} and for
396 * RAW capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
397 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}):
398 *
399 * <table>
400 * <tr><th colspan="11">LEVEL-3 additional guaranteed configurations</th></tr>
401 * <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>
402 * <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>
403 * <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>
404 * <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>
405 * </table><br>
406 * </p>
407 *
Eino-Ville Talvalaf3621f32014-08-26 14:53:39 -0700408 * <p>Since the capabilities of camera devices vary greatly, a given camera device may support
409 * target combinations with sizes outside of these guarantees, but this can only be tested for
410 * by attempting to create a session with such targets.</p>
411 *
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700412 * @param outputs The new set of Surfaces that should be made available as
413 * targets for captured image data.
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700414 * @param callback The callback to notify about the status of the new capture session.
415 * @param handler The handler on which the callback should be invoked, or {@code null} to use
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700416 * the current thread's {@link android.os.Looper looper}.
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -0700417 *
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700418 * @throws IllegalArgumentException if the set of output Surfaces do not meet the requirements,
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700419 * the callback is null, or the handler is null but the current
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700420 * thread has no looper.
421 * @throws CameraAccessException if the camera device is no longer connected or has
422 * encountered a fatal error
423 * @throws IllegalStateException if the camera device has been closed
424 *
425 * @see CameraCaptureSession
426 * @see StreamConfigurationMap#getOutputFormats()
427 * @see StreamConfigurationMap#getOutputSizes(int)
428 * @see StreamConfigurationMap#getOutputSizes(Class)
429 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700430 public abstract void createCaptureSession(@NonNull List<Surface> outputs,
431 @NonNull CameraCaptureSession.StateCallback callback, @Nullable Handler handler)
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700432 throws CameraAccessException;
433
434 /**
Yin-Chia Yeh49ea6ae2015-03-09 16:53:14 -0700435 * <p>Create a new camera capture session by providing the target output set of Surfaces and
436 * its corresponding surface configuration to the camera device.</p>
437 *
438 * @see #createCaptureSession
439 * @see OutputConfiguration
Yin-Chia Yeh49ea6ae2015-03-09 16:53:14 -0700440 */
441 public abstract void createCaptureSessionByOutputConfiguration(
442 List<OutputConfiguration> outputConfigurations,
443 CameraCaptureSession.StateCallback callback, Handler handler)
444 throws CameraAccessException;
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700445 /**
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700446 * Create a new reprocessable camera capture session by providing the desired reprocessing
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700447 * input Surface configuration and the target output set of Surfaces to the camera device.
448 *
449 * <p>If a camera device supports YUV reprocessing
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700450 * ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING}) or PRIVATE
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700451 * reprocessing
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700452 * ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING}), besides
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700453 * the capture session created via {@link #createCaptureSession createCaptureSession}, the
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700454 * application can also create a reprocessable capture session to submit reprocess capture
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700455 * requests in addition to regular capture requests. A reprocess capture request takes the next
456 * available buffer from the session's input Surface, and sends it through the camera device's
457 * processing pipeline again, to produce buffers for the request's target output Surfaces. No
458 * new image data is captured for a reprocess request. However the input buffer provided by
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700459 * the application must be captured previously by the same camera device in the same session
460 * directly (e.g. for Zero-Shutter-Lag use case) or indirectly (e.g. combining multiple output
461 * images).</p>
462 *
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700463 * <p>The active reprocessable capture session determines an input {@link Surface} and the set
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700464 * of potential output Surfaces for the camera devices for each capture request. The application
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700465 * can use {@link #createCaptureRequest createCaptureRequest} to create regular capture requests
466 * to capture new images from the camera device, and use {@link #createReprocessCaptureRequest
467 * createReprocessCaptureRequest} to create reprocess capture requests to process buffers from
468 * the input {@link Surface}. Some combinations of output Surfaces in a session may not be used
469 * in a request simultaneously. The guaranteed combinations of output Surfaces that can be used
470 * in a request simultaneously are listed in the tables under {@link #createCaptureSession
471 * createCaptureSession}. All the output Surfaces in one capture request will come from the
472 * same source, either from a new capture by the camera device, or from the input Surface
473 * depending on if the request is a reprocess capture request.</p>
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700474 *
475 * <p>Input formats and sizes supported by the camera device can be queried via
476 * {@link StreamConfigurationMap#getInputFormats} and
477 * {@link StreamConfigurationMap#getInputSizes}. For each supported input format, the camera
478 * device supports a set of output formats and sizes for reprocessing that can be queried via
479 * {@link StreamConfigurationMap#getValidOutputFormatsForInput} and
480 * {@link StreamConfigurationMap#getOutputSizes}. While output Surfaces with formats that
481 * aren't valid reprocess output targets for the input configuration can be part of a session,
482 * they cannot be used as targets for a reprocessing request.</p>
483 *
484 * <p>Since the application cannot access {@link android.graphics.ImageFormat#PRIVATE} images
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700485 * directly, an output Surface created by {@link android.media.ImageReader#newInstance} with
486 * {@link android.graphics.ImageFormat#PRIVATE} as the format will be considered as intended to
487 * be used for reprocessing input and thus the {@link android.media.ImageReader} size must
488 * match one of the supported input sizes for {@link android.graphics.ImageFormat#PRIVATE}
489 * format. Otherwise, creating a reprocessable capture session will fail.</p>
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700490 *
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700491 * <p>The guaranteed stream configurations listed in
492 * {@link #createCaptureSession createCaptureSession} are also guaranteed to work for
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700493 * {@link #createReprocessableCaptureSession createReprocessableCaptureSession}. In addition,
494 * the configurations in the tables below are also guaranteed for creating a reprocessable
495 * capture session if the camera device supports YUV reprocessing or PRIVATE reprocessing.
496 * However, not all output targets used to create a reprocessable session may be used in a
Chien-Yu Chene90c6d02015-08-25 11:31:58 -0700497 * {@link CaptureRequest} simultaneously. For devices that support only 1 output target in a
498 * reprocess {@link CaptureRequest}, submitting a reprocess {@link CaptureRequest} with multiple
499 * output targets will result in a {@link CaptureFailure}. For devices that support multiple
500 * output targets in a reprocess {@link CaptureRequest}, the guaranteed output targets that can
501 * be included in a {@link CaptureRequest} simultaneously are listed in the tables under
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700502 * {@link #createCaptureSession createCaptureSession}. For example, with a FULL-capability
503 * ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL} {@code == }
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700504 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) device that supports PRIVATE
505 * reprocessing, an application can create a reprocessable capture session with 1 input,
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700506 * ({@code PRIV}, {@code MAXIMUM}), and 3 outputs, ({@code PRIV}, {@code MAXIMUM}),
507 * ({@code PRIV}, {@code PREVIEW}), and ({@code YUV}, {@code MAXIMUM}). However, it's not
508 * guaranteed that an application can submit a regular or reprocess capture with ({@code PRIV},
509 * {@code MAXIMUM}) and ({@code YUV}, {@code MAXIMUM}) outputs based on the table listed under
510 * {@link #createCaptureSession createCaptureSession}. In other words, use the tables below to
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700511 * determine the guaranteed stream configurations for creating a reprocessable capture session,
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700512 * and use the tables under {@link #createCaptureSession createCaptureSession} to determine the
513 * guaranteed output targets that can be submitted in a regular or reprocess
514 * {@link CaptureRequest} simultaneously.</p>
515 *
516 * <style scoped>
517 * #rb { border-right-width: thick; }
518 * </style>
519 *
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800520 * <p>LIMITED-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700521 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED}) devices
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700522 * support at least the following stream combinations for creating a reprocessable capture
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700523 * session in addition to those listed in {@link #createCaptureSession createCaptureSession} for
524 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
525 *
526 * <table>
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700527 * <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 -0700528 * <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>
529 * <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>
530 * <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>
531 * <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>
532 * <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>
533 * <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>
534 * </table><br>
535 * </p>
536 *
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800537 * <p>FULL-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700538 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) devices
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700539 * support at least the following stream combinations for creating a reprocessable capture
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700540 * session in addition to those for
541 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices:
542 *
543 * <table>
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800544 * <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 -0700545 * <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>
546 * <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>
547 * <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>
548 * <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>
549 * <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>
550 * <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>
551 * <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 -0700552 * <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>
553 * </table><br>
554 * </p>
555 *
556 * <p>RAW-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes
557 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}) devices additionally support
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700558 * at least the following stream combinations for creating a reprocessable capture session
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700559 * on both {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} and
560 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} devices
561 *
562 * <table>
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700563 * <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 -0700564 * <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>
565 * <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>
566 * <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>
567 * <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>
568 * <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>
569 * <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>
570 * <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>
571 * </table><br>
572 * </p>
573 *
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800574 * <p>LEVEL-3 ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}
575 * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_3 LEVEL_3}) devices
576 * support at least the following stream combinations for creating a reprocessable capture
577 * session in addition to those for
Eino-Ville Talvalaefa0be92016-01-27 14:16:20 -0800578 * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} devices. Note that while
579 * the second configuration allows for configuring {@code MAXIMUM} {@code YUV} and {@code JPEG}
580 * outputs at the same time, that configuration is not listed for regular capture sessions, and
581 * therefore simultaneous output to both targets is not allowed.
Eino-Ville Talvala7c6d73f2016-01-21 13:55:11 -0800582 *
583 * <table>
584 * <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 -0800585 * <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 -0800586 * <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 -0800587 * <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 -0800588 * <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>
589 * </table><br>
590 * </p>
591 *
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700592 * @param inputConfig The configuration for the input {@link Surface}
593 * @param outputs The new set of Surfaces that should be made available as
594 * targets for captured image data.
595 * @param callback The callback to notify about the status of the new capture session.
596 * @param handler The handler on which the callback should be invoked, or {@code null} to use
597 * the current thread's {@link android.os.Looper looper}.
598 *
599 * @throws IllegalArgumentException if the input configuration is null or not supported, the set
600 * of output Surfaces do not meet the requirements, the
601 * callback is null, or the handler is null but the current
602 * thread has no looper.
603 * @throws CameraAccessException if the camera device is no longer connected or has
604 * encountered a fatal error
605 * @throws IllegalStateException if the camera device has been closed
606 *
Chien-Yu Chenf723db72015-04-30 13:06:09 -0700607 * @see #createCaptureSession
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700608 * @see CameraCaptureSession
609 * @see StreamConfigurationMap#getInputFormats
610 * @see StreamConfigurationMap#getInputSizes
611 * @see StreamConfigurationMap#getValidOutputFormatsForInput
612 * @see StreamConfigurationMap#getOutputSizes
613 * @see android.media.ImageWriter
614 * @see android.media.ImageReader
615 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700616 public abstract void createReprocessableCaptureSession(@NonNull InputConfiguration inputConfig,
617 @NonNull List<Surface> outputs, @NonNull CameraCaptureSession.StateCallback callback,
618 @Nullable Handler handler)
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700619 throws CameraAccessException;
Yin-Chia Yeh49ea6ae2015-03-09 16:53:14 -0700620
621 /**
Zhijun He445b3162016-01-18 15:34:28 -0800622 * Create a new reprocessable camera capture session by providing the desired reprocessing
623 * input configuration and output {@link OutputConfiguration}
624 * to the camera device.
625 *
626 * @see #createReprocessableCaptureSession
627 * @see OutputConfiguration
628 *
629 */
630 public abstract void createReprocessableCaptureSessionWithConfigurations(
631 @NonNull InputConfiguration inputConfig,
632 @NonNull List<OutputConfiguration> outputs,
633 @NonNull CameraCaptureSession.StateCallback callback,
634 @Nullable Handler handler)
635 throws CameraAccessException;
636
637 /**
Zhijun Heb1300e32015-05-28 12:51:52 -0700638 * <p>Create a new constrained high speed capture session.</p>
639 *
640 * <p>The application can use normal capture session (created via {@link #createCaptureSession})
641 * for high speed capture if the desired high speed FPS ranges are advertised by
642 * {@link CameraCharacteristics#CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES}, in which case all API
643 * semantics associated with normal capture sessions applies.</p>
644 *
645 * <p>The method creates a specialized capture session that is only targeted at high speed
646 * video recording (>=120fps) use case if the camera device supports high speed video
647 * capability (i.e., {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} contains
648 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO}).
649 * Therefore, it has special characteristics compared with a normal capture session:</p>
650 *
651 * <ul>
652 *
653 * <li>In addition to the output target Surface requirements specified by the
654 * {@link #createCaptureSession} method, an active high speed capture session will support up
655 * to 2 output Surfaces, though the application might choose to configure just one Surface
656 * (e.g., preview only). All Surfaces must be either video encoder surfaces (acquired by
657 * {@link android.media.MediaRecorder#getSurface} or
658 * {@link android.media.MediaCodec#createInputSurface}) or preview surfaces (obtained from
659 * {@link android.view.SurfaceView}, {@link android.graphics.SurfaceTexture} via
660 * {@link android.view.Surface#Surface(android.graphics.SurfaceTexture)}). The Surface sizes
661 * must be one of the sizes reported by {@link StreamConfigurationMap#getHighSpeedVideoSizes}.
662 * When multiple Surfaces are configured, their size must be same.</li>
663 *
664 * <li>An active high speed capture session only accepts request lists created via
Eino-Ville Talvala639fffe2015-06-30 10:34:48 -0700665 * {@link CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList}, and the
666 * request list can only be submitted to this session via
667 * {@link CameraCaptureSession#captureBurst captureBurst}, or
Zhijun Heb1300e32015-05-28 12:51:52 -0700668 * {@link CameraCaptureSession#setRepeatingBurst setRepeatingBurst}.</li>
669 *
670 * <li>The FPS ranges being requested to this session must be selected from
671 * {@link StreamConfigurationMap#getHighSpeedVideoFpsRangesFor}. The application can still use
672 * {@link CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE} to control the desired FPS range.
673 * Switching to an FPS range that has different
674 * {@link android.util.Range#getUpper() maximum FPS} may trigger some camera device
675 * reconfigurations, which may introduce extra latency. It is recommended that the
676 * application avoids unnecessary maximum target FPS changes as much as possible during high
677 * speed streaming.</li>
678 *
679 * <li>For the request lists submitted to this session, the camera device will override the
680 * {@link CaptureRequest#CONTROL_MODE control mode}, auto-exposure (AE), auto-white balance
681 * (AWB) and auto-focus (AF) to {@link CameraMetadata#CONTROL_MODE_AUTO},
682 * {@link CameraMetadata#CONTROL_AE_MODE_ON}, {@link CameraMetadata#CONTROL_AWB_MODE_AUTO}
683 * and {@link CameraMetadata#CONTROL_AF_MODE_CONTINUOUS_VIDEO}, respectively. All
684 * post-processing block mode controls will be overridden to be FAST. Therefore, no manual
685 * control of capture and post-processing parameters is possible. Beside these, only a subset
686 * of controls will work, see
687 * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO} for
688 * more details.</li>
689 *
690 * </ul>
691 *
692 * @param outputs The new set of Surfaces that should be made available as
693 * targets for captured high speed image data.
694 * @param callback The callback to notify about the status of the new capture session.
695 * @param handler The handler on which the callback should be invoked, or {@code null} to use
696 * the current thread's {@link android.os.Looper looper}.
697 *
698 * @throws IllegalArgumentException if the set of output Surfaces do not meet the requirements,
699 * the callback is null, or the handler is null but the current
700 * thread has no looper, or the camera device doesn't support
701 * high speed video capability.
702 * @throws CameraAccessException if the camera device is no longer connected or has
703 * encountered a fatal error
704 * @throws IllegalStateException if the camera device has been closed
705 *
706 * @see #createCaptureSession
707 * @see CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE
708 * @see StreamConfigurationMap#getHighSpeedVideoSizes
709 * @see StreamConfigurationMap#getHighSpeedVideoFpsRangesFor
710 * @see CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES
711 * @see CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO
712 * @see CameraCaptureSession#captureBurst
713 * @see CameraCaptureSession#setRepeatingBurst
Eino-Ville Talvala639fffe2015-06-30 10:34:48 -0700714 * @see CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList
Zhijun Heb1300e32015-05-28 12:51:52 -0700715 */
716 public abstract void createConstrainedHighSpeedCaptureSession(@NonNull List<Surface> outputs,
717 @NonNull CameraCaptureSession.StateCallback callback,
718 @Nullable Handler handler)
719 throws CameraAccessException;
720
Zhijun Heb1300e32015-05-28 12:51:52 -0700721 /**
Eino-Ville Talvala70c22072013-08-27 12:09:04 -0700722 * <p>Create a {@link CaptureRequest.Builder} for new capture requests,
723 * initialized with template for a target use case. The settings are chosen
724 * to be the best options for the specific camera device, so it is not
725 * recommended to reuse the same request for a different camera device;
726 * create a builder specific for that device and template and override the
727 * settings as desired, instead.</p>
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800728 *
729 * @param templateType An enumeration selecting the use case for this
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -0700730 * request; one of the CameraDevice.TEMPLATE_ values. Not all template
731 * types are supported on every device. See the documentation for each
732 * template type for details.
Eino-Ville Talvala70c22072013-08-27 12:09:04 -0700733 * @return a builder for a capture request, initialized with default
734 * settings for that template, and no output streams
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800735 *
Yin-Chia Yeh0cd24f22015-04-24 17:48:04 -0700736 * @throws IllegalArgumentException if the templateType is not supported by
737 * this device.
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700738 * @throws CameraAccessException if the camera device is no longer connected or has
739 * encountered a fatal error
740 * @throws IllegalStateException if the camera device has been closed
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800741 *
742 * @see #TEMPLATE_PREVIEW
743 * @see #TEMPLATE_RECORD
744 * @see #TEMPLATE_STILL_CAPTURE
745 * @see #TEMPLATE_VIDEO_SNAPSHOT
746 * @see #TEMPLATE_MANUAL
747 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700748 @NonNull
749 public abstract CaptureRequest.Builder createCaptureRequest(@RequestTemplate int templateType)
Igor Murashkin70725502013-06-25 20:27:06 +0000750 throws CameraAccessException;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800751
752 /**
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700753 * <p>Create a {@link CaptureRequest.Builder} for a new reprocess {@link CaptureRequest} from a
754 * {@link TotalCaptureResult}.
755 *
756 * <p>Each reprocess {@link CaptureRequest} processes one buffer from
757 * {@link CameraCaptureSession}'s input {@link Surface} to all output {@link Surface Surfaces}
758 * included in the reprocess capture request. The reprocess input images must be generated from
759 * one or multiple output images captured from the same camera device. The application can
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700760 * provide input images to camera device via {@link android.media.ImageWriter#queueInputImage}.
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700761 * The application must use the capture result of one of those output images to create a
762 * reprocess capture request so that the camera device can use the information to achieve
Chien-Yu Chene90c6d02015-08-25 11:31:58 -0700763 * optimal reprocess image quality. For camera devices that support only 1 output
764 * {@link Surface}, submitting a reprocess {@link CaptureRequest} with multiple
765 * output targets will result in a {@link CaptureFailure}.
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700766 *
767 * @param inputResult The capture result of the output image or one of the output images used
768 * to generate the reprocess input image for this capture request.
769 *
770 * @throws IllegalArgumentException if inputResult is null.
771 * @throws CameraAccessException if the camera device is no longer connected or has
772 * encountered a fatal error
773 * @throws IllegalStateException if the camera device has been closed
774 *
775 * @see CaptureRequest.Builder
776 * @see TotalCaptureResult
Chien-Yu Chen8062d312015-05-12 14:24:10 -0700777 * @see CameraDevice#createReprocessableCaptureSession
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700778 * @see android.media.ImageWriter
779 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700780 @NonNull
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700781 public abstract CaptureRequest.Builder createReprocessCaptureRequest(
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700782 @NonNull TotalCaptureResult inputResult) throws CameraAccessException;
Chien-Yu Chen5398a672015-03-19 14:48:43 -0700783
784 /**
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700785 * Close the connection to this camera device as quickly as possible.
Eino-Ville Talvala868d9042013-10-03 11:15:21 -0700786 *
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700787 * <p>Immediately after this call, all calls to the camera device or active session interface
788 * will throw a {@link IllegalStateException}, except for calls to close(). Once the device has
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700789 * fully shut down, the {@link StateCallback#onClosed} callback will be called, and the camera
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700790 * is free to be re-opened.</p>
Eino-Ville Talvala868d9042013-10-03 11:15:21 -0700791 *
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700792 * <p>Immediately after this call, besides the final {@link StateCallback#onClosed} calls, no
Eino-Ville Talvalacca00c62014-05-14 10:53:20 -0700793 * further callbacks from the device or the active session will occur, and any remaining
794 * submitted capture requests will be discarded, as if
795 * {@link CameraCaptureSession#abortCaptures} had been called, except that no success or failure
796 * callbacks will be invoked.</p>
Eino-Ville Talvala868d9042013-10-03 11:15:21 -0700797 *
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800798 */
Igor Murashkine363fbb2013-06-25 20:26:06 +0000799 @Override
Igor Murashkin21547d62014-06-04 15:21:42 -0700800 public abstract void close();
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800801
802 /**
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700803 * A callback objects for receiving updates about the state of a camera device.
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700804 *
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700805 * <p>A callback instance must be provided to the {@link CameraManager#openCamera} method to
806 * open a camera device.</p>
Eino-Ville Talvala868d9042013-10-03 11:15:21 -0700807 *
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700808 * <p>These state updates include notifications about the device completing startup (
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -0700809 * allowing for {@link #createCaptureSession} to be called), about device
810 * disconnection or closure, and about unexpected device errors.</p>
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700811 *
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -0700812 * <p>Events about the progress of specific {@link CaptureRequest CaptureRequests} are provided
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700813 * through a {@link CameraCaptureSession.CaptureCallback} given to the
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -0700814 * {@link CameraCaptureSession#capture}, {@link CameraCaptureSession#captureBurst},
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700815 * {@link CameraCaptureSession#setRepeatingRequest}, or
816 * {@link CameraCaptureSession#setRepeatingBurst} methods.
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700817 *
Eino-Ville Talvala868d9042013-10-03 11:15:21 -0700818 * @see CameraManager#openCamera
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800819 */
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700820 public static abstract class StateCallback {
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700821 /**
822 * An error code that can be reported by {@link #onError}
823 * indicating that the camera device is in use already.
824 *
825 * <p>
Ruben Brunk0f2be132015-04-17 14:23:40 -0700826 * This error can be produced when opening the camera fails due to the camera
827 * being used by a higher-priority camera API client.
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700828 * </p>
829 *
830 * @see #onError
831 */
832 public static final int ERROR_CAMERA_IN_USE = 1;
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700833
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800834 /**
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700835 * An error code that can be reported by {@link #onError}
836 * indicating that the camera device could not be opened
837 * because there are too many other open camera devices.
838 *
839 * <p>
840 * The system-wide limit for number of open cameras has been reached,
841 * and more camera devices cannot be opened until previous instances are
842 * closed.
843 * </p>
844 *
845 * <p>
846 * This error can be produced when opening the camera fails.
847 * </p>
848 *
849 * @see #onError
850 */
851 public static final int ERROR_MAX_CAMERAS_IN_USE = 2;
852
853 /**
854 * An error code that can be reported by {@link #onError}
855 * indicating that the camera device could not be opened due to a device
856 * policy.
857 *
858 * @see android.app.admin.DevicePolicyManager#setCameraDisabled(android.content.ComponentName, boolean)
859 * @see #onError
860 */
861 public static final int ERROR_CAMERA_DISABLED = 3;
862
863 /**
864 * An error code that can be reported by {@link #onError}
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700865 * indicating that the camera device has encountered a fatal error.
866 *
867 * <p>The camera device needs to be re-opened to be used again.</p>
868 *
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700869 * @see #onError
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700870 */
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700871 public static final int ERROR_CAMERA_DEVICE = 4;
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700872
873 /**
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700874 * An error code that can be reported by {@link #onError}
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700875 * indicating that the camera service has encountered a fatal error.
876 *
877 * <p>The Android device may need to be shut down and restarted to restore
878 * camera function, or there may be a persistent hardware problem.</p>
879 *
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700880 * <p>An attempt at recovery <i>may</i> be possible by closing the
881 * CameraDevice and the CameraManager, and trying to acquire all resources
882 * again from scratch.</p>
883 *
884 * @see #onError
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700885 */
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700886 public static final int ERROR_CAMERA_SERVICE = 5;
887
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700888 /** @hide */
889 @Retention(RetentionPolicy.SOURCE)
890 @IntDef(
891 {ERROR_CAMERA_IN_USE,
892 ERROR_MAX_CAMERAS_IN_USE,
893 ERROR_CAMERA_DISABLED,
894 ERROR_CAMERA_DEVICE,
895 ERROR_CAMERA_SERVICE })
896 public @interface ErrorCode {};
897
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700898 /**
899 * The method called when a camera device has finished opening.
900 *
Eino-Ville Talvalab67a3b32014-06-06 13:07:20 -0700901 * <p>At this point, the camera device is ready to use, and
902 * {@link CameraDevice#createCaptureSession} can be called to set up the first capture
903 * session.</p>
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700904 *
905 * @param camera the camera device that has become opened
906 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700907 public abstract void onOpened(@NonNull CameraDevice camera); // Must implement
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700908
909 /**
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700910 * The method called when a camera device has been closed with
911 * {@link CameraDevice#close}.
912 *
913 * <p>Any attempt to call methods on this CameraDevice in the
914 * future will throw a {@link IllegalStateException}.</p>
915 *
916 * <p>The default implementation of this method does nothing.</p>
917 *
918 * @param camera the camera device that has become closed
919 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700920 public void onClosed(@NonNull CameraDevice camera) {
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700921 // Default empty implementation
922 }
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700923
924 /**
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700925 * The method called when a camera device is no longer available for
926 * use.
927 *
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700928 * <p>This callback may be called instead of {@link #onOpened}
929 * if opening the camera fails.</p>
930 *
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700931 * <p>Any attempt to call methods on this CameraDevice will throw a
932 * {@link CameraAccessException}. The disconnection could be due to a
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800933 * change in security policy or permissions; the physical disconnection
934 * of a removable camera device; or the camera being needed for a
Ruben Brunk0f2be132015-04-17 14:23:40 -0700935 * higher-priority camera API client.</p>
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800936 *
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700937 * <p>There may still be capture callbacks that are invoked
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700938 * after this method is called, or new image buffers that are delivered
939 * to active outputs.</p>
940 *
941 * <p>The default implementation logs a notice to the system log
942 * about the disconnection.</p>
943 *
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700944 * <p>You should clean up the camera with {@link CameraDevice#close} after
Ruben Brunk0f2be132015-04-17 14:23:40 -0700945 * this happens, as it is not recoverable until the camera can be opened
946 * again. For most use cases, this will be when the camera again becomes
947 * {@link CameraManager.AvailabilityCallback#onCameraAvailable available}.
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700948 * </p>
949 *
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700950 * @param camera the device that has been disconnected
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800951 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700952 public abstract void onDisconnected(@NonNull CameraDevice camera); // Must implement
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800953
954 /**
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700955 * The method called when a camera device has encountered a serious error.
956 *
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700957 * <p>This callback may be called instead of {@link #onOpened}
958 * if opening the camera fails.</p>
959 *
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700960 * <p>This indicates a failure of the camera device or camera service in
961 * some way. Any attempt to call methods on this CameraDevice in the
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700962 * future will throw a {@link CameraAccessException} with the
963 * {@link CameraAccessException#CAMERA_ERROR CAMERA_ERROR} reason.
964 * </p>
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800965 *
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700966 * <p>There may still be capture completion or camera stream callbacks
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800967 * that will be called after this error is received.</p>
968 *
Igor Murashkin5c9eaf62013-09-10 19:35:24 -0700969 * <p>You should clean up the camera with {@link CameraDevice#close} after
970 * this happens. Further attempts at recovery are error-code specific.</p>
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800971 *
972 * @param camera The device reporting the error
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700973 * @param error The error code, one of the
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700974 * {@code StateCallback.ERROR_*} values.
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700975 *
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700976 * @see #ERROR_CAMERA_IN_USE
977 * @see #ERROR_MAX_CAMERAS_IN_USE
978 * @see #ERROR_CAMERA_DISABLED
Eino-Ville Talvala4af73c22013-08-14 10:35:46 -0700979 * @see #ERROR_CAMERA_DEVICE
980 * @see #ERROR_CAMERA_SERVICE
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800981 */
Eino-Ville Talvala8b905572015-05-14 15:43:01 -0700982 public abstract void onError(@NonNull CameraDevice camera,
983 @ErrorCode int error); // Must implement
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800984 }
Igor Murashkin21547d62014-06-04 15:21:42 -0700985
986 /**
Eino-Ville Talvalafd887432014-09-04 13:07:40 -0700987 * Temporary for migrating to Callback naming
988 * @hide
989 */
990 public static abstract class StateListener extends StateCallback {
991 }
992
993 /**
Igor Murashkin21547d62014-06-04 15:21:42 -0700994 * To be inherited by android.hardware.camera2.* code only.
995 * @hide
996 */
997 public CameraDevice() {}
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800998}