blob: 5340e7604441c0e4ef2feb027e93a2aef014686a [file] [log] [blame]
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -08001/*
2 * Copyright (C) 2015 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
Yin-Chia Yeh3e49be12016-04-12 16:00:33 -070017/**
18 * @addtogroup Camera
19 * @{
20 */
21
22/**
23 * @file NdkCaptureRequest.h
24 */
25
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080026/*
27 * This file defines an NDK API.
28 * Do not remove methods.
29 * Do not change method signatures.
30 * Do not change the value of constants.
31 * Do not change the size of any of the classes defined in here.
32 * Do not reference types that are not part of the NDK.
33 * Do not #include files that aren't part of the NDK.
34 */
Dan Albertd7973ba2016-09-14 12:35:50 -070035
36#include <sys/cdefs.h>
37
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080038#include <android/native_window.h>
39#include "NdkCameraError.h"
40#include "NdkCameraMetadata.h"
41
42#ifndef _NDK_CAPTURE_REQUEST_H
43#define _NDK_CAPTURE_REQUEST_H
44
Dan Albertd7973ba2016-09-14 12:35:50 -070045__BEGIN_DECLS
46
Ryan Pricharda5249752018-07-19 18:03:48 -070047#if __ANDROID_API__ >= 24
48
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080049// Container for output targets
50typedef struct ACameraOutputTargets ACameraOutputTargets;
51
52// Container for a single output target
53typedef struct ACameraOutputTarget ACameraOutputTarget;
54
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -070055/**
56 * ACaptureRequest is an opaque type that contains settings and output targets needed to capture
57 * a single image from camera device.
58 *
59 * <p>ACaptureRequest contains the configuration for the capture hardware (sensor, lens, flash),
60 * the processing pipeline, the control algorithms, and the output buffers. Also
61 * contains the list of target {@link ANativeWindow}s to send image data to for this
62 * capture.</p>
63 *
64 * <p>ACaptureRequest is created by {@link ACameraDevice_createCaptureRequest}.
65 *
66 * <p>ACaptureRequest is given to {@link ACameraCaptureSession_capture} or
67 * {@link ACameraCaptureSession_setRepeatingRequest} to capture images from a camera.</p>
68 *
69 * <p>Each request can specify a different subset of target {@link ANativeWindow}s for the
70 * camera to send the captured data to. All the {@link ANativeWindow}s used in a request must
71 * be part of the {@link ANativeWindow} list given to the last call to
72 * {@link ACameraDevice_createCaptureSession}, when the request is submitted to the
73 * session.</p>
74 *
75 * <p>For example, a request meant for repeating preview might only include the
76 * {@link ANativeWindow} for the preview SurfaceView or SurfaceTexture, while a
77 * high-resolution still capture would also include a {@link ANativeWindow} from a
78 * {@link AImageReader} configured for high-resolution JPEG images.</p>
79 *
80 * @see ACameraDevice_createCaptureRequest
81 * @see ACameraCaptureSession_capture
82 * @see ACameraCaptureSession_setRepeatingRequest
83 */
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080084typedef struct ACaptureRequest ACaptureRequest;
85
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -070086/**
87 * Create a ACameraOutputTarget object.
88 *
89 * <p>The ACameraOutputTarget is used in {@link ACaptureRequest_addTarget} method to add an output
90 * {@link ANativeWindow} to ACaptureRequest. Use {@link ACameraOutputTarget_free} to free the object
91 * and its memory after application no longer needs the {@link ACameraOutputTarget}.</p>
92 *
93 * @param window the {@link ANativeWindow} to be associated with the {@link ACameraOutputTarget}
94 * @param output the output {@link ACameraOutputTarget} will be stored here if the
95 * method call succeeds.
96 *
97 * @return <ul>
98 * <li>{@link ACAMERA_OK} if the method call succeeds. The created ACameraOutputTarget will
99 * be filled in the output argument.</li>
100 * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if window or output is NULL.</li></ul>
101 *
102 * @see ACaptureRequest_addTarget
103 */
Elliott Hughes4280e862018-06-18 13:17:24 -0700104camera_status_t ACameraOutputTarget_create(ANativeWindow* window,
105 ACameraOutputTarget** output) __INTRODUCED_IN(24);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -0800106
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700107/**
108 * Free a ACameraOutputTarget object.
109 *
110 * @param output the {@link ACameraOutputTarget} to be freed.
111 *
112 * @see ACameraOutputTarget_create
113 */
Elliott Hughes4280e862018-06-18 13:17:24 -0700114void ACameraOutputTarget_free(ACameraOutputTarget* output) __INTRODUCED_IN(24);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -0800115
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700116/**
117 * Add an {@link ACameraOutputTarget} object to {@link ACaptureRequest}.
118 *
119 * @param request the {@link ACaptureRequest} of interest.
120 * @param output the output {@link ACameraOutputTarget} to be added to capture request.
121 *
122 * @return <ul>
123 * <li>{@link ACAMERA_OK} if the method call succeeds.</li>
124 * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request or output is NULL.</li></ul>
125 */
126camera_status_t ACaptureRequest_addTarget(ACaptureRequest* request,
Elliott Hughes4280e862018-06-18 13:17:24 -0700127 const ACameraOutputTarget* output) __INTRODUCED_IN(24);
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700128
129/**
130 * Remove an {@link ACameraOutputTarget} object from {@link ACaptureRequest}.
131 *
132 * <p>This method has no effect if the ACameraOutputTarget does not exist in ACaptureRequest.</p>
133 *
134 * @param request the {@link ACaptureRequest} of interest.
135 * @param output the output {@link ACameraOutputTarget} to be removed from capture request.
136 *
137 * @return <ul>
138 * <li>{@link ACAMERA_OK} if the method call succeeds.</li>
139 * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request or output is NULL.</li></ul>
140 */
141camera_status_t ACaptureRequest_removeTarget(ACaptureRequest* request,
Elliott Hughes4280e862018-06-18 13:17:24 -0700142 const ACameraOutputTarget* output) __INTRODUCED_IN(24);
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700143
144/**
145 * Get a metadata entry from input {@link ACaptureRequest}.
146 *
147 * <p>The memory of the data field in returned entry is managed by camera framework. Do not
148 * attempt to free it.</p>
149 *
150 * @param request the {@link ACaptureRequest} of interest.
151 * @param tag the tag value of the camera metadata entry to be get.
152 * @param entry the output {@link ACameraMetadata_const_entry} will be filled here if the method
153 * call succeeeds.
154 *
155 * @return <ul>
156 * <li>{@link ACAMERA_OK} if the method call succeeds.</li>
157 * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if metadata or entry is NULL.</li>
158 * <li>{@link ACAMERA_ERROR_METADATA_NOT_FOUND} if the capture request does not contain an
159 * entry of input tag value.</li></ul>
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -0800160 */
161camera_status_t ACaptureRequest_getConstEntry(
Elliott Hughes4280e862018-06-18 13:17:24 -0700162 const ACaptureRequest* request, uint32_t tag, ACameraMetadata_const_entry* entry) __INTRODUCED_IN(24);
Yin-Chia Yeh8aac03f2016-03-03 15:45:23 -0800163
164/*
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700165 * List all the entry tags in input {@link ACaptureRequest}.
166 *
167 * @param request the {@link ACaptureRequest} of interest.
168 * @param numEntries number of metadata entries in input {@link ACaptureRequest}
169 * @param tags the tag values of the metadata entries. Length of tags is returned in numEntries
170 * argument. The memory is managed by ACaptureRequest itself and must NOT be free/delete
171 * by application. Calling ACaptureRequest_setEntry_* methods will invalidate previous
172 * output of ACaptureRequest_getAllTags. Do not access tags after calling
173 * ACaptureRequest_setEntry_*. To get new list of tags after updating capture request,
174 * application must call ACaptureRequest_getAllTags again. Do NOT access tags after
175 * calling ACaptureRequest_free.
176 *
177 * @return <ul>
178 * <li>{@link ACAMERA_OK} if the method call succeeds.</li>
179 * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request, numEntries or tags is NULL.</li>
180 * <li>{@link ACAMERA_ERROR_UNKNOWN} if the method fails for some other reasons.</li></ul>
Yin-Chia Yeh8aac03f2016-03-03 15:45:23 -0800181 */
182camera_status_t ACaptureRequest_getAllTags(
Elliott Hughes4280e862018-06-18 13:17:24 -0700183 const ACaptureRequest* request, /*out*/int32_t* numTags, /*out*/const uint32_t** tags) __INTRODUCED_IN(24);
Yin-Chia Yeh8aac03f2016-03-03 15:45:23 -0800184
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700185/**
186 * Set/change a camera capture control entry with unsigned 8 bits data type.
187 *
188 * <p>Set count to 0 and data to NULL to remove a tag from the capture request.</p>
189 *
190 * @param request the {@link ACaptureRequest} of interest.
191 * @param tag the tag value of the camera metadata entry to be set.
192 * @param count number of elements to be set in data argument
193 * @param data the entries to be set/change in the capture request.
194 *
195 * @return <ul>
196 * <li>{@link ACAMERA_OK} if the method call succeeds.</li>
197 * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request is NULL, count is larger than
198 * zero while data is NULL, the data type of the tag is not unsigned 8 bits, or
199 * the tag is not controllable by application.</li></ul>
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -0800200 */
201camera_status_t ACaptureRequest_setEntry_u8(
Elliott Hughes4280e862018-06-18 13:17:24 -0700202 ACaptureRequest* request, uint32_t tag, uint32_t count, const uint8_t* data) __INTRODUCED_IN(24);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -0800203
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700204/**
205 * Set/change a camera capture control entry with signed 32 bits data type.
206 *
207 * <p>Set count to 0 and data to NULL to remove a tag from the capture request.</p>
208 *
209 * @param request the {@link ACaptureRequest} of interest.
210 * @param tag the tag value of the camera metadata entry to be set.
211 * @param count number of elements to be set in data argument
212 * @param data the entries to be set/change in the capture request.
213 *
214 * @return <ul>
215 * <li>{@link ACAMERA_OK} if the method call succeeds.</li>
216 * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request is NULL, count is larger than
217 * zero while data is NULL, the data type of the tag is not signed 32 bits, or
218 * the tag is not controllable by application.</li></ul>
219 */
220camera_status_t ACaptureRequest_setEntry_i32(
Elliott Hughes4280e862018-06-18 13:17:24 -0700221 ACaptureRequest* request, uint32_t tag, uint32_t count, const int32_t* data) __INTRODUCED_IN(24);
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700222
223/**
224 * Set/change a camera capture control entry with float data type.
225 *
226 * <p>Set count to 0 and data to NULL to remove a tag from the capture request.</p>
227 *
228 * @param request the {@link ACaptureRequest} of interest.
229 * @param tag the tag value of the camera metadata entry to be set.
230 * @param count number of elements to be set in data argument
231 * @param data the entries to be set/change in the capture request.
232 *
233 * @return <ul>
234 * <li>{@link ACAMERA_OK} if the method call succeeds.</li>
235 * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request is NULL, count is larger than
236 * zero while data is NULL, the data type of the tag is not float, or
237 * the tag is not controllable by application.</li></ul>
238 */
239camera_status_t ACaptureRequest_setEntry_float(
Elliott Hughes4280e862018-06-18 13:17:24 -0700240 ACaptureRequest* request, uint32_t tag, uint32_t count, const float* data) __INTRODUCED_IN(24);
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700241
242/**
243 * Set/change a camera capture control entry with signed 64 bits data type.
244 *
245 * <p>Set count to 0 and data to NULL to remove a tag from the capture request.</p>
246 *
247 * @param request the {@link ACaptureRequest} of interest.
248 * @param tag the tag value of the camera metadata entry to be set.
249 * @param count number of elements to be set in data argument
250 * @param data the entries to be set/change in the capture request.
251 *
252 * @return <ul>
253 * <li>{@link ACAMERA_OK} if the method call succeeds.</li>
254 * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request is NULL, count is larger than
255 * zero while data is NULL, the data type of the tag is not signed 64 bits, or
256 * the tag is not controllable by application.</li></ul>
257 */
258camera_status_t ACaptureRequest_setEntry_i64(
Elliott Hughes4280e862018-06-18 13:17:24 -0700259 ACaptureRequest* request, uint32_t tag, uint32_t count, const int64_t* data) __INTRODUCED_IN(24);
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700260
261/**
262 * Set/change a camera capture control entry with double data type.
263 *
264 * <p>Set count to 0 and data to NULL to remove a tag from the capture request.</p>
265 *
266 * @param request the {@link ACaptureRequest} of interest.
267 * @param tag the tag value of the camera metadata entry to be set.
268 * @param count number of elements to be set in data argument
269 * @param data the entries to be set/change in the capture request.
270 *
271 * @return <ul>
272 * <li>{@link ACAMERA_OK} if the method call succeeds.</li>
273 * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request is NULL, count is larger than
274 * zero while data is NULL, the data type of the tag is not double, or
275 * the tag is not controllable by application.</li></ul>
276 */
277camera_status_t ACaptureRequest_setEntry_double(
Elliott Hughes4280e862018-06-18 13:17:24 -0700278 ACaptureRequest* request, uint32_t tag, uint32_t count, const double* data) __INTRODUCED_IN(24);
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700279
280/**
281 * Set/change a camera capture control entry with rational data type.
282 *
283 * <p>Set count to 0 and data to NULL to remove a tag from the capture request.</p>
284 *
285 * @param request the {@link ACaptureRequest} of interest.
286 * @param tag the tag value of the camera metadata entry to be set.
287 * @param count number of elements to be set in data argument
288 * @param data the entries to be set/change in the capture request.
289 *
290 * @return <ul>
291 * <li>{@link ACAMERA_OK} if the method call succeeds.</li>
292 * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request is NULL, count is larger than
293 * zero while data is NULL, the data type of the tag is not rational, or
294 * the tag is not controllable by application.</li></ul>
295 */
296camera_status_t ACaptureRequest_setEntry_rational(
297 ACaptureRequest* request, uint32_t tag, uint32_t count,
Elliott Hughes4280e862018-06-18 13:17:24 -0700298 const ACameraMetadata_rational* data) __INTRODUCED_IN(24);
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700299
300/**
301 * Free a {@link ACaptureRequest} structure.
302 *
303 * @param request the {@link ACaptureRequest} to be freed.
304 */
Elliott Hughes4280e862018-06-18 13:17:24 -0700305void ACaptureRequest_free(ACaptureRequest* request) __INTRODUCED_IN(24);
Yin-Chia Yehd39b9e32017-10-30 17:39:23 -0700306
Ryan Pricharda5249752018-07-19 18:03:48 -0700307#endif /* __ANDROID_API__ >= 24 */
308
309#if __ANDROID_API__ >= 28
310
Yin-Chia Yehd39b9e32017-10-30 17:39:23 -0700311/**
312 * Associate an arbitrary user context pointer to the {@link ACaptureRequest}
313 *
314 * This method is useful for user to identify the capture request in capture session callbacks.
315 * The context is NULL for newly created request.
316 * {@link ACameraOutputTarget_free} will not free the context. Also calling this method twice
317 * will not cause the previous context be freed.
318 * Also note that calling this method after the request has been sent to capture session will not
319 * change the context pointer in the capture callbacks.
320 *
321 * @param request the {@link ACaptureRequest} of interest.
322 * @param context the user context pointer to be associated with this capture request.
323 *
324 * @return <ul>
325 * <li>{@link ACAMERA_OK} if the method call succeeds.</li>
326 * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request is NULL.</li></ul>
327 */
328camera_status_t ACaptureRequest_setUserContext(
Elliott Hughes4280e862018-06-18 13:17:24 -0700329 ACaptureRequest* request, void* context) __INTRODUCED_IN(28);
Yin-Chia Yehd39b9e32017-10-30 17:39:23 -0700330
331/**
332 * Get the user context pointer of the {@link ACaptureRequest}
333 *
334 * This method is useful for user to identify the capture request in capture session callbacks.
335 * The context is NULL for newly created request.
336 *
337 * @param request the {@link ACaptureRequest} of interest.
338 * @param context the user context pointer of this capture request.
339 *
340 * @return <ul>
341 * <li>{@link ACAMERA_OK} if the method call succeeds.</li>
342 * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request is NULL.</li></ul>
343 */
344camera_status_t ACaptureRequest_getUserContext(
Elliott Hughes4280e862018-06-18 13:17:24 -0700345 const ACaptureRequest* request, /*out*/void** context) __INTRODUCED_IN(28);
Yin-Chia Yehd39b9e32017-10-30 17:39:23 -0700346
347/**
348 * Create a copy of input {@link ACaptureRequest}.
349 *
350 * <p>The returned ACaptureRequest must be freed by the application by {@link ACaptureRequest_free}
351 * after application is done using it.</p>
352 *
353 * @param src the input {@link ACaptureRequest} to be copied.
354 *
355 * @return a valid ACaptureRequest pointer or NULL if the input request cannot be copied.
356 */
Elliott Hughes4280e862018-06-18 13:17:24 -0700357ACaptureRequest* ACaptureRequest_copy(const ACaptureRequest* src) __INTRODUCED_IN(28);
Yin-Chia Yehd39b9e32017-10-30 17:39:23 -0700358
Ryan Pricharda5249752018-07-19 18:03:48 -0700359#endif /* __ANDROID_API__ >= 28 */
360
Dan Albertd7973ba2016-09-14 12:35:50 -0700361__END_DECLS
362
363#endif /* _NDK_CAPTURE_REQUEST_H */
Yin-Chia Yeh3e49be12016-04-12 16:00:33 -0700364
365/** @} */