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