CameraProperties.h revision 9a412956d5327ec851ff8adc3e9804640fa30c7f
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_VALUES[]; 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 CameraProperties(); 140 ~CameraProperties(); 141 142 // container class passed around for accessing properties 143 class Properties 144 { 145 public: 146 Properties() 147 { 148 mProperties = new DefaultKeyedVector<String8, String8>(String8(DEFAULT_VALUE)); 149 char property[PROPERTY_VALUE_MAX]; 150 property_get("ro.product.manufacturer", property, EXIF_MAKE_DEFAULT); 151 property[0] = toupper(property[0]); 152 set(EXIF_MAKE, property); 153 property_get("ro.product.model", property, EXIF_MODEL_DEFAULT); 154 property[0] = toupper(property[0]); 155 set(EXIF_MODEL, property); 156 } 157 ~Properties() 158 { 159 delete mProperties; 160 } 161 ssize_t set(const char *prop, const char *value); 162 ssize_t set(const char *prop, int value); 163 const char* get(const char * prop); 164 void dump(); 165 166 protected: 167 const char* keyAt(unsigned int); 168 const char* valueAt(unsigned int); 169 170 private: 171 DefaultKeyedVector<String8, String8>* mProperties; 172 173 }; 174 175 ///Initializes the CameraProperties class 176 status_t initialize(); 177 status_t loadProperties(); 178 int camerasSupported(); 179 int getProperties(int cameraIndex, Properties** properties); 180 181private: 182 183 uint32_t mCamerasSupported; 184 int mInitialized; 185 mutable Mutex mLock; 186 187 Properties mCameraProps[MAX_CAMERAS_SUPPORTED]; 188 189}; 190 191}; 192 193#endif //CAMERA_PROPERTIES_H 194 195