Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 1 | /* |
| 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 |
| 33 | extern "C" { |
| 34 | #endif |
| 35 | |
| 36 | typedef struct ACameraCaptureSession ACameraCaptureSession; |
| 37 | |
| 38 | typedef void (*ACameraCaptureSession_stateCallback)(void* context, ACameraCaptureSession *session); |
| 39 | |
| 40 | typedef struct ACameraCaptureSession_stateCallbacks { |
| 41 | void* context; |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 42 | ACameraCaptureSession_stateCallback onClosed; // session is unusable after this callback |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 43 | ACameraCaptureSession_stateCallback onReady; |
| 44 | ACameraCaptureSession_stateCallback onActive; |
| 45 | } ACameraCaptureSession_stateCallbacks; |
| 46 | |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 47 | enum { |
| 48 | CAPTURE_FAILURE_REASON_FLUSHED = 0, |
| 49 | CAPTURE_FAILURE_REASON_ERROR |
| 50 | }; |
| 51 | |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 52 | typedef struct ACameraCaptureFailure { |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 53 | int64_t frameNumber; |
| 54 | int reason; |
| 55 | int sequenceId; |
| 56 | bool wasImageCaptured; |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 57 | } ACameraCaptureFailure; |
| 58 | |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 59 | /* 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 Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 61 | typedef void (*ACameraCaptureSession_captureCallback_start)( |
| 62 | void* context, ACameraCaptureSession* session, |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 63 | const ACaptureRequest* request, int64_t timestamp); |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 64 | |
| 65 | typedef void (*ACameraCaptureSession_captureCallback_result)( |
| 66 | void* context, ACameraCaptureSession* session, |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 67 | ACaptureRequest* request, const ACameraMetadata* result); |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 68 | |
| 69 | typedef void (*ACameraCaptureSession_captureCallback_failed)( |
| 70 | void* context, ACameraCaptureSession* session, |
| 71 | ACaptureRequest* request, ACameraCaptureFailure* failure); |
| 72 | |
| 73 | typedef void (*ACameraCaptureSession_captureCallback_sequenceEnd)( |
| 74 | void* context, ACameraCaptureSession* session, |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 75 | int sequenceId, int64_t frameNumber); |
| 76 | |
| 77 | typedef void (*ACameraCaptureSession_captureCallback_sequenceAbort)( |
| 78 | void* context, ACameraCaptureSession* session, |
| 79 | int sequenceId); |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 80 | |
| 81 | typedef struct ACameraCaptureSession_captureCallbacks { |
| 82 | void* context; |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 83 | 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 Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 89 | } ACameraCaptureSession_captureCallbacks; |
| 90 | |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 91 | enum { |
| 92 | CAPTURE_SEQUENCE_ID_NONE = -1 |
| 93 | }; |
| 94 | |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 95 | /* |
| 96 | * Close capture session |
| 97 | */ |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 98 | void ACameraCaptureSession_close(ACameraCaptureSession*); |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 99 | |
| 100 | struct ACameraDevice; |
| 101 | typedef struct ACameraDevice ACameraDevice; |
| 102 | |
| 103 | /** |
| 104 | * Get the camera device associated with this capture session |
| 105 | */ |
| 106 | camera_status_t ACameraCaptureSession_getDevice( |
| 107 | ACameraCaptureSession*, ACameraDevice** device); |
| 108 | |
| 109 | /** |
| 110 | * Send capture request(s) |
| 111 | */ |
| 112 | camera_status_t ACameraCaptureSession_capture( |
| 113 | ACameraCaptureSession*, /*optional*/ACameraCaptureSession_captureCallbacks*, |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 114 | int numRequests, ACaptureRequest** requests, |
| 115 | /*optional*/int* captureSequenceId); |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 116 | |
| 117 | /** |
| 118 | * Send repeating capture request(s) |
| 119 | */ |
| 120 | camera_status_t ACameraCaptureSession_setRepeatingRequest( |
| 121 | ACameraCaptureSession*, /*optional*/ACameraCaptureSession_captureCallbacks*, |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 122 | int numRequests, ACaptureRequest** requests, |
| 123 | /*optional*/int* captureSequenceId); |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 124 | |
| 125 | /** |
| 126 | * Stop repeating capture request(s) |
| 127 | */ |
| 128 | camera_status_t ACameraCaptureSession_stopRepeating(ACameraCaptureSession*); |
| 129 | |
| 130 | /** |
| 131 | * Stop all capture requests as soon as possible |
| 132 | */ |
| 133 | camera_status_t ACameraCaptureSession_abortCaptures(ACameraCaptureSession*); |
| 134 | |
| 135 | |
| 136 | #ifdef __cplusplus |
| 137 | } // extern "C" |
| 138 | #endif |
| 139 | |
| 140 | #endif // _NDK_CAMERA_CAPTURE_SESSION_H |