CameraProperties.h revision 88c6149db74482ac32c93e41d4d8bc0b77a73836
1/*
2 * Copyright (C) Texas Instruments - http://www.ti.com/
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#define MAX_CAMERAS_SUPPORTED 2
36#define MAX_PROP_NAME_LENGTH 50
37#define MAX_PROP_VALUE_LENGTH 2048
38
39#define EXIF_MAKE_DEFAULT "default_make"
40#define EXIF_MODEL_DEFAULT "default_model"
41
42// Class that handles the Camera Properties
43class CameraProperties
44{
45public:
46    static const char INVALID[];
47    static const char CAMERA_NAME[];
48    static const char CAMERA_SENSOR_INDEX[];
49    static const char ORIENTATION_INDEX[];
50    static const char FACING_INDEX[];
51    static const char S3D_SUPPORTED[];
52    static const char SUPPORTED_PREVIEW_SIZES[];
53    static const char SUPPORTED_PREVIEW_FORMATS[];
54    static const char SUPPORTED_PREVIEW_FRAME_RATES[];
55    static const char SUPPORTED_PICTURE_SIZES[];
56    static const char SUPPORTED_PICTURE_FORMATS[];
57    static const char SUPPORTED_THUMBNAIL_SIZES[];
58    static const char SUPPORTED_WHITE_BALANCE[];
59    static const char SUPPORTED_EFFECTS[];
60    static const char SUPPORTED_ANTIBANDING[];
61    static const char SUPPORTED_EXPOSURE_MODES[];
62    static const char SUPPORTED_EV_MIN[];
63    static const char SUPPORTED_EV_MAX[];
64    static const char SUPPORTED_EV_STEP[];
65    static const char SUPPORTED_ISO_VALUES[];
66    static const char SUPPORTED_SCENE_MODES[];
67    static const char SUPPORTED_FLASH_MODES[];
68    static const char SUPPORTED_FOCUS_MODES[];
69    static const char REQUIRED_PREVIEW_BUFS[];
70    static const char REQUIRED_IMAGE_BUFS[];
71    static const char SUPPORTED_ZOOM_RATIOS[];
72    static const char SUPPORTED_ZOOM_STAGES[];
73    static const char SUPPORTED_IPP_MODES[];
74    static const char SMOOTH_ZOOM_SUPPORTED[];
75    static const char ZOOM_SUPPORTED[];
76    static const char PREVIEW_SIZE[];
77    static const char PREVIEW_FORMAT[];
78    static const char PREVIEW_FRAME_RATE[];
79    static const char ZOOM[];
80    static const char PICTURE_SIZE[];
81    static const char PICTURE_FORMAT[];
82    static const char JPEG_THUMBNAIL_SIZE[];
83    static const char WHITEBALANCE[];
84    static const char EFFECT[];
85    static const char ANTIBANDING[];
86    static const char EXPOSURE_MODE[];
87    static const char EV_COMPENSATION[];
88    static const char ISO_MODE[];
89    static const char FOCUS_MODE[];
90    static const char SCENE_MODE[];
91    static const char FLASH_MODE[];
92    static const char JPEG_QUALITY[];
93    static const char BRIGHTNESS[];
94    static const char SATURATION[];
95    static const char SHARPNESS[];
96    static const char CONTRAST[];
97    static const char IPP[];
98    static const char GBCE[];
99    static const char AUTOCONVERGENCE[];
100    static const char AUTOCONVERGENCE_MODE[];
101    static const char MANUALCONVERGENCE_VALUES[];
102    static const char SENSOR_ORIENTATION[];
103    static const char SENSOR_ORIENTATION_VALUES[];
104    static const char REVISION[];
105    static const char FOCAL_LENGTH[];
106    static const char HOR_ANGLE[];
107    static const char VER_ANGLE[];
108    static const char EXIF_MAKE[];
109    static const char EXIF_MODEL[];
110    static const char JPEG_THUMBNAIL_QUALITY[];
111    static const char MAX_FOCUS_AREAS[];
112    static const char MAX_FD_HW_FACES[];
113    static const char MAX_FD_SW_FACES[];
114
115    static const char PARAMS_DELIMITER [];
116
117    static const char S3D2D_PREVIEW[];
118    static const char S3D2D_PREVIEW_MODES[];
119    static const char VSTAB[];
120    static const char VSTAB_VALUES[];
121    static const char FRAMERATE_RANGE[];
122    static const char FRAMERATE_RANGE_IMAGE[];
123    static const char FRAMERATE_RANGE_VIDEO[];
124    static const char FRAMERATE_RANGE_SUPPORTED[];
125
126    static const char DEFAULT_VALUE[];
127
128    static const char AUTO_EXPOSURE_LOCK[];
129    static const char AUTO_EXPOSURE_LOCK_SUPPORTED[];
130    static const char AUTO_WHITEBALANCE_LOCK[];
131    static const char AUTO_WHITEBALANCE_LOCK_SUPPORTED[];
132    static const char MAX_NUM_METERING_AREAS[];
133    static const char METERING_AREAS[];
134    static const char MAX_NUM_FOCUS_AREAS[];
135
136    static const char VIDEO_SNAPSHOT_SUPPORTED[];
137
138    CameraProperties();
139    ~CameraProperties();
140
141    // container class passed around for accessing properties
142    class Properties
143    {
144        public:
145            Properties()
146            {
147                mProperties = new DefaultKeyedVector<String8, String8>(String8(DEFAULT_VALUE));
148                char property[PROPERTY_VALUE_MAX];
149                property_get("ro.product.manufacturer", property, EXIF_MAKE_DEFAULT);
150                property[0] = toupper(property[0]);
151                set(EXIF_MAKE, property);
152                property_get("ro.product.model", property, EXIF_MODEL_DEFAULT);
153                property[0] = toupper(property[0]);
154                set(EXIF_MODEL, property);
155            }
156            ~Properties()
157            {
158                delete mProperties;
159            }
160            ssize_t set(const char *prop, const char *value);
161            ssize_t set(const char *prop, int value);
162            const char* get(const char * prop);
163            void dump();
164
165        protected:
166            const char* keyAt(unsigned int);
167            const char* valueAt(unsigned int);
168
169        private:
170            DefaultKeyedVector<String8, String8>* mProperties;
171
172    };
173
174    ///Initializes the CameraProperties class
175    status_t initialize();
176    status_t loadProperties();
177    int camerasSupported();
178    int getProperties(int cameraIndex, Properties** properties);
179
180private:
181
182    uint32_t mCamerasSupported;
183    int mInitialized;
184
185    Properties mCameraProps[MAX_CAMERAS_SUPPORTED];
186
187};
188
189};
190
191#endif //CAMERA_PROPERTIES_H
192
193