blob: adef6ed0e47d2737a03fac4c5a5f4a6cc9304d6e [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#ifndef _NDK_CAMERA_MANAGER_H
28#define _NDK_CAMERA_MANAGER_H
29
30#include "NdkCameraError.h"
31#include "NdkCameraMetadata.h"
32#include "NdkCameraDevice.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38typedef struct ACameraManager ACameraManager;
39
40/**
41 * Create CameraManager instance.
42 * The caller must call ACameraManager_delete to free the resources
43 */
44ACameraManager* ACameraManager_create();
45
46/**
47 * delete the ACameraManager and free its resources
48 */
49void ACameraManager_delete(ACameraManager*);
50
51// Struct to hold list of camera devices
52typedef struct ACameraIdList {
53 int numCameras;
54 const char** cameraIds;
55} ACameraIdList;
56
57/**
58 * Create/delete a list of camera devices.
59 * ACameraManager_getCameraIdList will allocate and return an ACameraIdList.
60 * The caller must call ACameraManager_deleteCameraIdList to free the memory
61 */
62camera_status_t ACameraManager_getCameraIdList(ACameraManager*,
63 /*out*/ACameraIdList** cameraIdList);
64void ACameraManager_deleteCameraIdList(ACameraIdList* cameraIdList);
65
66
67// Struct to hold camera availability callbacks
68typedef void (*ACameraManager_AvailabilityCallback)(void* context, const char* cameraId);
69
70typedef struct ACameraManager_AvailabilityListener {
71 void* context; // optional application context.
72 ACameraManager_AvailabilityCallback onCameraAvailable;
73 ACameraManager_AvailabilityCallback onCameraUnavailable;
74} ACameraManager_AvailabilityCallbacks;
75
76/**
77 * register/unregister camera availability callbacks
78 */
79camera_status_t ACameraManager_registerAvailabilityCallback(
80 ACameraManager*, const ACameraManager_AvailabilityCallbacks *callback);
81camera_status_t ACameraManager_unregisterAvailabilityCallback(
82 ACameraManager*, const ACameraManager_AvailabilityCallbacks *callback);
83
84/**
85 * Query the characteristics of a camera.
86 * The caller must call ACameraMetadata_free to free the memory of the output characteristics.
87 */
88camera_status_t ACameraManager_getCameraCharacteristics(
89 ACameraManager*, const char *cameraId,
90 /*out*/ACameraMetadata **characteristics);
91
92/**
93 * Open a camera device synchronously.
94 * The opened camera device will be returned in
95 */
96camera_status_t ACameraManager_openCamera(
97 ACameraManager*, const char* cameraId,
98 ACameraDevice_StateCallbacks* callback,
99 /*out*/ACameraDevice** device);
100
101#ifdef __cplusplus
102} // extern "C"
103#endif
104
105#endif //_NDK_CAMERA_MANAGER_H