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