blob: 6eb07075f03a2860a40d7a582705f70415542e77 [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
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
36extern "C" {
37#endif
38
39typedef struct ACameraDevice ACameraDevice;
40
41// Struct to hold camera state callbacks
42typedef void (*ACameraDevice_StateCallback)(void* context, ACameraDevice* device);
43typedef void (*ACameraDevice_ErrorStateCallback)(void* context, ACameraDevice* device, int error);
44
45typedef struct ACameraDevice_StateCallbacks {
46 void* context;
47 ACameraDevice_StateCallback onDisconnected;
48 ACameraDevice_ErrorStateCallback onError;
49} ACameraDevice_stateCallbacks;
50
51/**
52 * Close the camera device synchronously. Open is done in ACameraManager_openCamera
53 */
54camera_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 */
61const char* ACameraDevice_getId(const ACameraDevice*);
62
63typedef 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 */
75camera_status_t ACameraDevice_createCaptureRequest(
76 const ACameraDevice*, ACameraDevice_request_template, /*out*/ACaptureRequest** request);
77
78/**
79 * APIs for createing capture session
80 */
81typedef struct ACaptureSessionOutputContainer ACaptureSessionOutputContainer;
82
83typedef struct ACaptureSessionOutput ACaptureSessionOutput;
84
85camera_status_t ACaptureSessionOutputContainer_create(/*out*/ACaptureSessionOutputContainer**);
86void ACaptureSessionOutputContainer_free(ACaptureSessionOutputContainer*);
87
88camera_status_t ACaptureSessionOutput_create(ANativeWindow*, /*out*/ACaptureSessionOutput**);
89void ACaptureSessionOutput_free(ACaptureSessionOutput*);
90
91camera_status_t ACaptureSessionOutputContainer_add(
92 ACaptureSessionOutputContainer*, const ACaptureSessionOutput*);
93camera_status_t ACaptureSessionOutputContainer_remove(
94 ACaptureSessionOutputContainer*, const ACaptureSessionOutput*);
95
96camera_status_t ACameraDevice_createCaptureSession(
97 ACameraDevice*,
98 const ACaptureSessionOutputContainer* outputs,
99 const ACameraCaptureSession_stateCallbacks* callbacks);
100
101#ifdef __cplusplus
102} // extern "C"
103#endif
104
105#endif // _NDK_CAMERA_DEVICE_H