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