blob: 085b6146873b221dec6049a8f171d35f5dcd3797 [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
17/*
18 * This file defines an NDK API.
19 * Do not remove methods.
20 * Do not change method signatures.
21 * Do not change the value of constants.
22 * Do not change the size of any of the classes defined in here.
23 * Do not reference types that are not part of the NDK.
24 * Do not #include files that aren't part of the NDK.
25 */
Yin-Chia Yehe081c592016-03-29 18:26:44 -070026#include <android/native_window.h>
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080027#include "NdkCameraError.h"
28#include "NdkCameraMetadata.h"
29
30#ifndef _NDK_CAMERA_CAPTURE_SESSION_H
31#define _NDK_CAMERA_CAPTURE_SESSION_H
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37typedef struct ACameraCaptureSession ACameraCaptureSession;
38
39typedef void (*ACameraCaptureSession_stateCallback)(void* context, ACameraCaptureSession *session);
40
41typedef struct ACameraCaptureSession_stateCallbacks {
42 void* context;
Yin-Chia Yehead91462016-01-06 16:45:08 -080043 ACameraCaptureSession_stateCallback onClosed; // session is unusable after this callback
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080044 ACameraCaptureSession_stateCallback onReady;
45 ACameraCaptureSession_stateCallback onActive;
46} ACameraCaptureSession_stateCallbacks;
47
Yin-Chia Yehead91462016-01-06 16:45:08 -080048enum {
49 CAPTURE_FAILURE_REASON_FLUSHED = 0,
50 CAPTURE_FAILURE_REASON_ERROR
51};
52
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080053typedef struct ACameraCaptureFailure {
Yin-Chia Yehead91462016-01-06 16:45:08 -080054 int64_t frameNumber;
55 int reason;
56 int sequenceId;
57 bool wasImageCaptured;
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080058} ACameraCaptureFailure;
59
Yin-Chia Yehead91462016-01-06 16:45:08 -080060/* Note that the ACaptureRequest* in the callback will be different to what app has submitted,
61 but the contents will still be the same as what app submitted */
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080062typedef void (*ACameraCaptureSession_captureCallback_start)(
63 void* context, ACameraCaptureSession* session,
Yin-Chia Yehead91462016-01-06 16:45:08 -080064 const ACaptureRequest* request, int64_t timestamp);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080065
66typedef void (*ACameraCaptureSession_captureCallback_result)(
67 void* context, ACameraCaptureSession* session,
Yin-Chia Yehead91462016-01-06 16:45:08 -080068 ACaptureRequest* request, const ACameraMetadata* result);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080069
70typedef void (*ACameraCaptureSession_captureCallback_failed)(
71 void* context, ACameraCaptureSession* session,
72 ACaptureRequest* request, ACameraCaptureFailure* failure);
73
74typedef void (*ACameraCaptureSession_captureCallback_sequenceEnd)(
75 void* context, ACameraCaptureSession* session,
Yin-Chia Yehead91462016-01-06 16:45:08 -080076 int sequenceId, int64_t frameNumber);
77
78typedef void (*ACameraCaptureSession_captureCallback_sequenceAbort)(
79 void* context, ACameraCaptureSession* session,
80 int sequenceId);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080081
Yin-Chia Yehe081c592016-03-29 18:26:44 -070082typedef void (*ACameraCaptureSession_captureCallback_bufferLost)(
83 void* context, ACameraCaptureSession* session,
84 ACaptureRequest* request, ANativeWindow* window, int64_t frameNumber);
85
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080086typedef struct ACameraCaptureSession_captureCallbacks {
87 void* context;
Yin-Chia Yehead91462016-01-06 16:45:08 -080088 ACameraCaptureSession_captureCallback_start onCaptureStarted;
89 ACameraCaptureSession_captureCallback_result onCaptureProgressed;
90 ACameraCaptureSession_captureCallback_result onCaptureCompleted;
91 ACameraCaptureSession_captureCallback_failed onCaptureFailed;
92 ACameraCaptureSession_captureCallback_sequenceEnd onCaptureSequenceCompleted;
93 ACameraCaptureSession_captureCallback_sequenceAbort onCaptureSequenceAborted;
Yin-Chia Yehe081c592016-03-29 18:26:44 -070094 ACameraCaptureSession_captureCallback_bufferLost onCaptureBufferLost;
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080095} ACameraCaptureSession_captureCallbacks;
96
Yin-Chia Yehead91462016-01-06 16:45:08 -080097enum {
98 CAPTURE_SEQUENCE_ID_NONE = -1
99};
100
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -0800101/*
102 * Close capture session
103 */
Yin-Chia Yehead91462016-01-06 16:45:08 -0800104void ACameraCaptureSession_close(ACameraCaptureSession*);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -0800105
106struct ACameraDevice;
107typedef struct ACameraDevice ACameraDevice;
108
109/**
110 * Get the camera device associated with this capture session
111 */
112camera_status_t ACameraCaptureSession_getDevice(
113 ACameraCaptureSession*, ACameraDevice** device);
114
115/**
116 * Send capture request(s)
117 */
118camera_status_t ACameraCaptureSession_capture(
119 ACameraCaptureSession*, /*optional*/ACameraCaptureSession_captureCallbacks*,
Yin-Chia Yehead91462016-01-06 16:45:08 -0800120 int numRequests, ACaptureRequest** requests,
121 /*optional*/int* captureSequenceId);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -0800122
123/**
124 * Send repeating capture request(s)
125 */
126camera_status_t ACameraCaptureSession_setRepeatingRequest(
127 ACameraCaptureSession*, /*optional*/ACameraCaptureSession_captureCallbacks*,
Yin-Chia Yehead91462016-01-06 16:45:08 -0800128 int numRequests, ACaptureRequest** requests,
129 /*optional*/int* captureSequenceId);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -0800130
131/**
132 * Stop repeating capture request(s)
133 */
134camera_status_t ACameraCaptureSession_stopRepeating(ACameraCaptureSession*);
135
136/**
137 * Stop all capture requests as soon as possible
138 */
139camera_status_t ACameraCaptureSession_abortCaptures(ACameraCaptureSession*);
140
141
142#ifdef __cplusplus
143} // extern "C"
144#endif
145
146#endif // _NDK_CAMERA_CAPTURE_SESSION_H