blob: 5d5cae21389c8145206a9b2db717c2f16245261b [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 */
26#include "NdkCameraError.h"
27#include "NdkCameraMetadata.h"
28
29#ifndef _NDK_CAMERA_CAPTURE_SESSION_H
30#define _NDK_CAMERA_CAPTURE_SESSION_H
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36typedef struct ACameraCaptureSession ACameraCaptureSession;
37
38typedef void (*ACameraCaptureSession_stateCallback)(void* context, ACameraCaptureSession *session);
39
40typedef struct ACameraCaptureSession_stateCallbacks {
41 void* context;
Yin-Chia Yehead91462016-01-06 16:45:08 -080042 ACameraCaptureSession_stateCallback onClosed; // session is unusable after this callback
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080043 ACameraCaptureSession_stateCallback onReady;
44 ACameraCaptureSession_stateCallback onActive;
45} ACameraCaptureSession_stateCallbacks;
46
Yin-Chia Yehead91462016-01-06 16:45:08 -080047enum {
48 CAPTURE_FAILURE_REASON_FLUSHED = 0,
49 CAPTURE_FAILURE_REASON_ERROR
50};
51
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080052typedef struct ACameraCaptureFailure {
Yin-Chia Yehead91462016-01-06 16:45:08 -080053 int64_t frameNumber;
54 int reason;
55 int sequenceId;
56 bool wasImageCaptured;
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080057} ACameraCaptureFailure;
58
Yin-Chia Yehead91462016-01-06 16:45:08 -080059/* Note that the ACaptureRequest* in the callback will be different to what app has submitted,
60 but the contents will still be the same as what app submitted */
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080061typedef void (*ACameraCaptureSession_captureCallback_start)(
62 void* context, ACameraCaptureSession* session,
Yin-Chia Yehead91462016-01-06 16:45:08 -080063 const ACaptureRequest* request, int64_t timestamp);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080064
65typedef void (*ACameraCaptureSession_captureCallback_result)(
66 void* context, ACameraCaptureSession* session,
Yin-Chia Yehead91462016-01-06 16:45:08 -080067 ACaptureRequest* request, const ACameraMetadata* result);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080068
69typedef void (*ACameraCaptureSession_captureCallback_failed)(
70 void* context, ACameraCaptureSession* session,
71 ACaptureRequest* request, ACameraCaptureFailure* failure);
72
73typedef void (*ACameraCaptureSession_captureCallback_sequenceEnd)(
74 void* context, ACameraCaptureSession* session,
Yin-Chia Yehead91462016-01-06 16:45:08 -080075 int sequenceId, int64_t frameNumber);
76
77typedef void (*ACameraCaptureSession_captureCallback_sequenceAbort)(
78 void* context, ACameraCaptureSession* session,
79 int sequenceId);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080080
81typedef struct ACameraCaptureSession_captureCallbacks {
82 void* context;
Yin-Chia Yehead91462016-01-06 16:45:08 -080083 ACameraCaptureSession_captureCallback_start onCaptureStarted;
84 ACameraCaptureSession_captureCallback_result onCaptureProgressed;
85 ACameraCaptureSession_captureCallback_result onCaptureCompleted;
86 ACameraCaptureSession_captureCallback_failed onCaptureFailed;
87 ACameraCaptureSession_captureCallback_sequenceEnd onCaptureSequenceCompleted;
88 ACameraCaptureSession_captureCallback_sequenceAbort onCaptureSequenceAborted;
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080089} ACameraCaptureSession_captureCallbacks;
90
Yin-Chia Yehead91462016-01-06 16:45:08 -080091enum {
92 CAPTURE_SEQUENCE_ID_NONE = -1
93};
94
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080095/*
96 * Close capture session
97 */
Yin-Chia Yehead91462016-01-06 16:45:08 -080098void ACameraCaptureSession_close(ACameraCaptureSession*);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080099
100struct ACameraDevice;
101typedef struct ACameraDevice ACameraDevice;
102
103/**
104 * Get the camera device associated with this capture session
105 */
106camera_status_t ACameraCaptureSession_getDevice(
107 ACameraCaptureSession*, ACameraDevice** device);
108
109/**
110 * Send capture request(s)
111 */
112camera_status_t ACameraCaptureSession_capture(
113 ACameraCaptureSession*, /*optional*/ACameraCaptureSession_captureCallbacks*,
Yin-Chia Yehead91462016-01-06 16:45:08 -0800114 int numRequests, ACaptureRequest** requests,
115 /*optional*/int* captureSequenceId);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -0800116
117/**
118 * Send repeating capture request(s)
119 */
120camera_status_t ACameraCaptureSession_setRepeatingRequest(
121 ACameraCaptureSession*, /*optional*/ACameraCaptureSession_captureCallbacks*,
Yin-Chia Yehead91462016-01-06 16:45:08 -0800122 int numRequests, ACaptureRequest** requests,
123 /*optional*/int* captureSequenceId);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -0800124
125/**
126 * Stop repeating capture request(s)
127 */
128camera_status_t ACameraCaptureSession_stopRepeating(ACameraCaptureSession*);
129
130/**
131 * Stop all capture requests as soon as possible
132 */
133camera_status_t ACameraCaptureSession_abortCaptures(ACameraCaptureSession*);
134
135
136#ifdef __cplusplus
137} // extern "C"
138#endif
139
140#endif // _NDK_CAMERA_CAPTURE_SESSION_H