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 | |
| 27 | #include <android/native_window.h> |
| 28 | #include "NdkCameraError.h" |
| 29 | #include "NdkCaptureRequest.h" |
| 30 | #include "NdkCameraCaptureSession.h" |
| 31 | |
| 32 | #ifndef _NDK_CAMERA_DEVICE_H |
| 33 | #define _NDK_CAMERA_DEVICE_H |
| 34 | |
| 35 | #ifdef __cplusplus |
| 36 | extern "C" { |
| 37 | #endif |
| 38 | |
| 39 | typedef struct ACameraDevice ACameraDevice; |
| 40 | |
| 41 | // Struct to hold camera state callbacks |
| 42 | typedef void (*ACameraDevice_StateCallback)(void* context, ACameraDevice* device); |
| 43 | typedef void (*ACameraDevice_ErrorStateCallback)(void* context, ACameraDevice* device, int error); |
| 44 | |
| 45 | typedef struct ACameraDevice_StateCallbacks { |
| 46 | void* context; |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 47 | ACameraDevice_StateCallback onDisconnected; // Device is unusable after this callback |
| 48 | ACameraDevice_ErrorStateCallback onError; // Device is unusable after this callback |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 49 | } ACameraDevice_stateCallbacks; |
| 50 | |
| 51 | /** |
| 52 | * Close the camera device synchronously. Open is done in ACameraManager_openCamera |
| 53 | */ |
| 54 | camera_status_t ACameraDevice_close(ACameraDevice*); |
| 55 | |
| 56 | /** |
| 57 | * Return the camera id associated with this camera device |
| 58 | * The returned pointer is still owned by framework and should not be delete/free by app |
| 59 | * The returned pointer should not be used after the device has been closed |
| 60 | */ |
| 61 | const char* ACameraDevice_getId(const ACameraDevice*); |
| 62 | |
| 63 | typedef enum { |
| 64 | TEMPLATE_PREVIEW = 1, |
| 65 | TEMPLATE_STILL_CAPTURE, |
| 66 | TEMPLATE_RECORD, |
| 67 | TEMPLATE_VIDEO_SNAPSHOT, |
| 68 | TEMPLATE_ZERO_SHUTTER_LAG, |
| 69 | TEMPLATE_MANUAL, |
| 70 | } ACameraDevice_request_template; |
| 71 | |
| 72 | /** |
| 73 | * Create/free a default capture request for input template |
| 74 | */ |
| 75 | camera_status_t ACameraDevice_createCaptureRequest( |
| 76 | const ACameraDevice*, ACameraDevice_request_template, /*out*/ACaptureRequest** request); |
| 77 | |
| 78 | /** |
| 79 | * APIs for createing capture session |
| 80 | */ |
| 81 | typedef struct ACaptureSessionOutputContainer ACaptureSessionOutputContainer; |
| 82 | |
| 83 | typedef struct ACaptureSessionOutput ACaptureSessionOutput; |
| 84 | |
| 85 | camera_status_t ACaptureSessionOutputContainer_create(/*out*/ACaptureSessionOutputContainer**); |
| 86 | void ACaptureSessionOutputContainer_free(ACaptureSessionOutputContainer*); |
| 87 | |
| 88 | camera_status_t ACaptureSessionOutput_create(ANativeWindow*, /*out*/ACaptureSessionOutput**); |
| 89 | void ACaptureSessionOutput_free(ACaptureSessionOutput*); |
| 90 | |
| 91 | camera_status_t ACaptureSessionOutputContainer_add( |
| 92 | ACaptureSessionOutputContainer*, const ACaptureSessionOutput*); |
| 93 | camera_status_t ACaptureSessionOutputContainer_remove( |
| 94 | ACaptureSessionOutputContainer*, const ACaptureSessionOutput*); |
| 95 | |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 96 | /* |
| 97 | * Create a new capture session. |
| 98 | * If there is a preexisting session, the previous session will be closed automatically. |
| 99 | * However, app still needs to call ACameraCaptureSession_close on previous session. |
| 100 | * Otherwise the resources hold by previous session won't be freed |
| 101 | */ |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 102 | camera_status_t ACameraDevice_createCaptureSession( |
| 103 | ACameraDevice*, |
| 104 | const ACaptureSessionOutputContainer* outputs, |
Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame^] | 105 | const ACameraCaptureSession_stateCallbacks* callbacks, |
| 106 | /*out*/ACameraCaptureSession** session); |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 107 | |
| 108 | #ifdef __cplusplus |
| 109 | } // extern "C" |
| 110 | #endif |
| 111 | |
| 112 | #endif // _NDK_CAMERA_DEVICE_H |