summaryrefslogtreecommitdiff
path: root/inc/CameraProperties.h (plain)
blob: 44ef80369fa4e2abe025ada8ad96cf538b42b002
1/*
2 * Copyright (C) 2011 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
19
20#ifndef CAMERA_PROPERTIES_H
21#define CAMERA_PROPERTIES_H
22
23#include <utils/KeyedVector.h>
24#include <utils/String8.h>
25#include <stdio.h>
26#include <dirent.h>
27#include <errno.h>
28#include <stdio.h>
29#include <string.h>
30#include <ctype.h>
31#include "cutils/properties.h"
32
33namespace android {
34
35#if defined(AMLOGIC_FRONT_CAMERA_SUPPORT) && defined(AMLOGIC_BACK_CAMERA_SUPPORT)
36 #define MAX_CAMERAS_SUPPORTED 2
37#elif defined(AMLOGIC_FRONT_CAMERA_SUPPORT) || defined(AMLOGIC_BACK_CAMERA_SUPPORT) ||defined(AMLOGIC_USB_CAMERA_SUPPORT)
38 #define MAX_CAMERAS_SUPPORTED 1
39#elif defined (AMLOGIC_VIRTUAL_CAMERA_SUPPORT)
40 #define MAX_CAMERAS_SUPPORTED 0
41#else
42 //if didn't define AMLOGIC_FRONT_CAMERA_SUPPORT nor AMLOGIC_BACK_CAMERA_SUPPORT,
43 //we set the MAX_CAMERAS_SUPPORTED to the max nums we may support ,and
44 //will dectect the camera number in function CameraAdapter_CameraNum();
45 #define MAX_CAMERAS_SUPPORTED 2
46#endif
47#ifdef AMLOGIC_VIRTUAL_CAMERA_SUPPORT
48#define MAX_CAM_NUM_ADD_VCAM (MAX_CAMERAS_SUPPORTED+1)
49#endif
50
51#define MAX_SIMUL_CAMERAS_SUPPORTED 1
52#define MAX_PROP_NAME_LENGTH 50
53#define MAX_PROP_VALUE_LENGTH 2048
54
55#define EXIF_MAKE_DEFAULT "default_make"
56#define EXIF_MODEL_DEFAULT "default_model"
57
58// Class that handles the Camera Properties
59class CameraProperties
60{
61public:
62 static const char INVALID[];
63 static const char CAMERA_NAME[];
64 static const char CAMERA_SENSOR_INDEX[];
65 static const char ORIENTATION_INDEX[];
66 static const char FACING_INDEX[];
67 static const char S3D_SUPPORTED[];
68 static const char SUPPORTED_PREVIEW_SIZES[];
69 static const char SUPPORTED_PREVIEW_FORMATS[];
70 static const char SUPPORTED_PREVIEW_FRAME_RATES[];
71 static const char SUPPORTED_PICTURE_SIZES[];
72 static const char SUPPORTED_PICTURE_FORMATS[];
73 static const char SUPPORTED_THUMBNAIL_SIZES[];
74 static const char SUPPORTED_WHITE_BALANCE[];
75 static const char SUPPORTED_EFFECTS[];
76 static const char SUPPORTED_ANTIBANDING[];
77 static const char SUPPORTED_EXPOSURE_MODES[];
78 static const char SUPPORTED_EV_MIN[];
79 static const char SUPPORTED_EV_MAX[];
80 static const char SUPPORTED_EV_STEP[];
81 static const char SUPPORTED_ISO_VALUES[];
82 static const char SUPPORTED_SCENE_MODES[];
83 static const char SUPPORTED_FLASH_MODES[];
84 static const char SUPPORTED_FOCUS_MODES[];
85 static const char REQUIRED_PREVIEW_BUFS[];
86 static const char REQUIRED_IMAGE_BUFS[];
87 static const char SUPPORTED_ZOOM_RATIOS[];
88 static const char SUPPORTED_ZOOM_STAGES[];
89 static const char SUPPORTED_IPP_MODES[];
90 static const char SMOOTH_ZOOM_SUPPORTED[];
91 static const char ZOOM_SUPPORTED[];
92 static const char PREVIEW_SIZE[];
93 static const char PREVIEW_FORMAT[];
94 static const char PREVIEW_FRAME_RATE[];
95 static const char ZOOM[];
96 static const char PICTURE_SIZE[];
97 static const char PICTURE_FORMAT[];
98 static const char JPEG_THUMBNAIL_SIZE[];
99 static const char WHITEBALANCE[];
100 static const char EFFECT[];
101 static const char ANTIBANDING[];
102 static const char EXPOSURE_MODE[];
103 static const char EV_COMPENSATION[];
104 static const char ISO_MODE[];
105 static const char FOCUS_MODE[];
106 static const char SCENE_MODE[];
107 static const char FLASH_MODE[];
108 static const char JPEG_QUALITY[];
109 static const char BRIGHTNESS[];
110 static const char SATURATION[];
111 static const char SHARPNESS[];
112 static const char CONTRAST[];
113 static const char IPP[];
114 static const char GBCE[];
115 static const char AUTOCONVERGENCE[];
116 static const char AUTOCONVERGENCE_MODE[];
117 static const char MANUALCONVERGENCE_VALUES[];
118 static const char SENSOR_ORIENTATION[];
119 static const char SENSOR_ORIENTATION_VALUES[];
120 static const char REVISION[];
121 static const char FOCAL_LENGTH[];
122 static const char HOR_ANGLE[];
123 static const char VER_ANGLE[];
124 static const char EXIF_MAKE[];
125 static const char EXIF_MODEL[];
126 static const char JPEG_THUMBNAIL_QUALITY[];
127 static const char MAX_FOCUS_AREAS[];
128 static const char MAX_FD_HW_FACES[];
129 static const char MAX_FD_SW_FACES[];
130
131 static const char PARAMS_DELIMITER [];
132
133 static const char S3D2D_PREVIEW[];
134 static const char S3D2D_PREVIEW_MODES[];
135 static const char VSTAB[];
136 static const char VSTAB_SUPPORTED[];
137 static const char FRAMERATE_RANGE[];
138 static const char FRAMERATE_RANGE_IMAGE[];
139 static const char FRAMERATE_RANGE_VIDEO[];
140 static const char FRAMERATE_RANGE_SUPPORTED[];
141
142 static const char DEFAULT_VALUE[];
143
144 static const char AUTO_EXPOSURE_LOCK[];
145 static const char AUTO_EXPOSURE_LOCK_SUPPORTED[];
146 static const char AUTO_WHITEBALANCE_LOCK[];
147 static const char AUTO_WHITEBALANCE_LOCK_SUPPORTED[];
148 static const char MAX_NUM_METERING_AREAS[];
149 static const char METERING_AREAS[];
150 static const char MAX_NUM_FOCUS_AREAS[];
151
152 static const char VIDEO_SNAPSHOT_SUPPORTED[];
153
154 static const char VIDEO_SIZE[];
155 static const char SUPPORTED_VIDEO_SIZES[];
156 static const char PREFERRED_PREVIEW_SIZE_FOR_VIDEO[];
157
158 static const char PIXEL_FORMAT_RGB24[];
159 static const char RELOAD_WHEN_OPEN[];
160 static const char DEVICE_NAME[];
161
162 CameraProperties();
163 ~CameraProperties();
164
165 // container class passed around for accessing properties
166 class Properties
167 {
168 public:
169 Properties()
170 {
171 mProperties = new DefaultKeyedVector<String8, String8>(String8(DEFAULT_VALUE));
172 char property[PROPERTY_VALUE_MAX];
173 property_get("ro.product.manufacturer", property, EXIF_MAKE_DEFAULT);
174 property[0] = toupper(property[0]);
175 set(EXIF_MAKE, property);
176 property_get("ro.product.model", property, EXIF_MODEL_DEFAULT);
177 property[0] = toupper(property[0]);
178 set(EXIF_MODEL, property);
179 }
180 ~Properties()
181 {
182 delete mProperties;
183 }
184 ssize_t set(const char *prop, const char *value);
185 ssize_t set(const char *prop, int value);
186 const char* get(const char * prop);
187 void dump();
188
189 protected:
190 const char* keyAt(unsigned int);
191 const char* valueAt(unsigned int);
192
193 private:
194 DefaultKeyedVector<String8, String8>* mProperties;
195
196 };
197
198 ///Initializes the CameraProperties class
199 status_t initialize(int cameraid);
200 status_t loadProperties();
201 int camerasSupported();
202 int getProperties(int cameraIndex, Properties** properties);
203
204private:
205
206 uint32_t mCamerasSupported;
207 int mInitialized;
208 mutable Mutex mLock;
209
210#ifdef AMLOGIC_VIRTUAL_CAMERA_SUPPORT
211 Properties mCameraProps[MAX_CAM_NUM_ADD_VCAM];
212#else
213 Properties mCameraProps[MAX_CAMERAS_SUPPORTED];
214#endif
215
216};
217
218};
219
220#endif //CAMERA_PROPERTIES_H
221
222