CameraParameters.h revision 2b8aba228e6ebd45fe29714baa477f3ea2320095
1/* 2 * Copyright (C) 2008 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#ifndef ANDROID_HARDWARE_CAMERA_PARAMETERS_H 18#define ANDROID_HARDWARE_CAMERA_PARAMETERS_H 19 20#include <utils/KeyedVector.h> 21#include <utils/String8.h> 22 23namespace android { 24 25class CameraParameters 26{ 27public: 28 CameraParameters(); 29 CameraParameters(const String8 ¶ms) { unflatten(params); } 30 ~CameraParameters(); 31 32 String8 flatten() const; 33 void unflatten(const String8 ¶ms); 34 35 void set(const char *key, const char *value); 36 void set(const char *key, int value); 37 void setFloat(const char *key, float value); 38 const char *get(const char *key) const; 39 int getInt(const char *key) const; 40 float getFloat(const char *key) const; 41 42 void remove(const char *key); 43 44 void setPreviewSize(int width, int height); 45 void getPreviewSize(int *width, int *height) const; 46 void setPreviewFrameRate(int fps); 47 int getPreviewFrameRate() const; 48 void setPreviewFormat(const char *format); 49 const char *getPreviewFormat() const; 50 void setPictureSize(int width, int height); 51 void getPictureSize(int *width, int *height) const; 52 void setPictureFormat(const char *format); 53 const char *getPictureFormat() const; 54 55 void dump() const; 56 status_t dump(int fd, const Vector<String16>& args) const; 57 58 // Parameter keys to communicate between camera application and driver. 59 // The access (read/write, read only, or write only) is viewed from the 60 // perspective of applications, not driver. 61 62 // Preview frame size in pixels (width x height). 63 // Example value: "480x320". Read/Write. 64 static const char KEY_PREVIEW_SIZE[]; 65 // Supported preview frame sizes in pixels. 66 // Example value: "800x600,480x320". Read only. 67 static const char KEY_SUPPORTED_PREVIEW_SIZES[]; 68 // The image format for preview frames. See CAMERA_MSG_PREVIEW_FRAME in 69 // frameworks/base/include/camera/Camera.h. 70 // Example value: "yuv420sp" or PIXEL_FORMAT_XXX constants. Read/write. 71 static const char KEY_PREVIEW_FORMAT[]; 72 // Supported image formats for preview frames. 73 // Example value: "yuv420sp,yuv422i-yuyv". Read only. 74 static const char KEY_SUPPORTED_PREVIEW_FORMATS[]; 75 // Number of preview frames per second. This is the target frame rate. The 76 // actual frame rate depends on the driver. 77 // Example value: "15". Read/write. 78 static const char KEY_PREVIEW_FRAME_RATE[]; 79 // Supported number of preview frames per second. 80 // Example value: "24,15,10". Read. 81 static const char KEY_SUPPORTED_PREVIEW_FRAME_RATES[]; 82 // The dimensions for captured pictures in pixels (width x height). 83 // Example value: "1024x768". Read/write. 84 static const char KEY_PICTURE_SIZE[]; 85 // Supported dimensions for captured pictures in pixels. 86 // Example value: "2048x1536,1024x768". Read only. 87 static const char KEY_SUPPORTED_PICTURE_SIZES[]; 88 // The image format for captured pictures. See CAMERA_MSG_COMPRESSED_IMAGE 89 // in frameworks/base/include/camera/Camera.h. 90 // Example value: "jpeg" or PIXEL_FORMAT_XXX constants. Read/write. 91 static const char KEY_PICTURE_FORMAT[]; 92 // Supported image formats for captured pictures. 93 // Example value: "jpeg,rgb565". Read only. 94 static const char KEY_SUPPORTED_PICTURE_FORMATS[]; 95 // The width (in pixels) of EXIF thumbnail in Jpeg picture. 96 // Example value: "512". Read/write. 97 static const char KEY_JPEG_THUMBNAIL_WIDTH[]; 98 // The height (in pixels) of EXIF thumbnail in Jpeg picture. 99 // Example value: "384". Read/write. 100 static const char KEY_JPEG_THUMBNAIL_HEIGHT[]; 101 // Supported EXIF thumbnail sizes (width x height). 0x0 means not thumbnail 102 // in EXIF. 103 // Example value: "512x384,320x240,0x0". Read only. 104 static const char KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[]; 105 // The quality of the EXIF thumbnail in Jpeg picture. The range is 1 to 100, 106 // with 100 being the best. 107 // Example value: "90". Read/write. 108 static const char KEY_JPEG_THUMBNAIL_QUALITY[]; 109 // Jpeg quality of captured picture. The range is 1 to 100, with 100 being 110 // the best. 111 // Example value: "90". Read/write. 112 static const char KEY_JPEG_QUALITY[]; 113 // The orientation of the device in degrees. For example, suppose the 114 // natural position of the device is landscape. If the user takes a picture 115 // in landscape mode in 2048x1536 resolution, the rotation will be set to 116 // "0". If the user rotates the phone 90 degrees clockwise, the rotation 117 // should be set to "90". 118 // The camera driver can set orientation in the EXIF header without rotating 119 // the picture. Or the driver can rotate the picture and the EXIF thumbnail. 120 // If the Jpeg picture is rotated, the orientation in the EXIF header should 121 // be missing or 1 (row #0 is top and column #0 is left side). The driver 122 // should not set default value for this parameter. 123 // Example value: "0" or "90" or "180" or "270". Write only. 124 static const char KEY_ROTATION[]; 125 // GPS latitude coordinate. GPSLatitude and GPSLatitudeRef will be stored in 126 // JPEG EXIF header. 127 // Example value: "25.032146" or "-33.462809". Write only. 128 static const char KEY_GPS_LATITUDE[]; 129 // GPS longitude coordinate. GPSLongitude and GPSLongitudeRef will be stored 130 // in JPEG EXIF header. 131 // Example value: "121.564448" or "-70.660286". Write only. 132 static const char KEY_GPS_LONGITUDE[]; 133 // GPS altitude. GPSAltitude and GPSAltitudeRef will be stored in JPEG EXIF 134 // header. 135 // Example value: "21.0" or "-5". Write only. 136 static const char KEY_GPS_ALTITUDE[]; 137 // GPS timestamp (UTC in seconds since January 1, 1970). This should be 138 // stored in JPEG EXIF header. 139 // Example value: "1251192757". Write only. 140 static const char KEY_GPS_TIMESTAMP[]; 141 // GPS Processing Method 142 // Example value: "GPS" or "NETWORK". Write only. 143 static const char KEY_GPS_PROCESSING_METHOD[]; 144 // Current white balance setting. 145 // Example value: "auto" or WHITE_BALANCE_XXX constants. Read/write. 146 static const char KEY_WHITE_BALANCE[]; 147 // Supported white balance settings. 148 // Example value: "auto,incandescent,daylight". Read only. 149 static const char KEY_SUPPORTED_WHITE_BALANCE[]; 150 // Current color effect setting. 151 // Example value: "none" or EFFECT_XXX constants. Read/write. 152 static const char KEY_EFFECT[]; 153 // Supported color effect settings. 154 // Example value: "none,mono,sepia". Read only. 155 static const char KEY_SUPPORTED_EFFECTS[]; 156 // Current antibanding setting. 157 // Example value: "auto" or ANTIBANDING_XXX constants. Read/write. 158 static const char KEY_ANTIBANDING[]; 159 // Supported antibanding settings. 160 // Example value: "auto,50hz,60hz,off". Read only. 161 static const char KEY_SUPPORTED_ANTIBANDING[]; 162 // Current scene mode. 163 // Example value: "auto" or SCENE_MODE_XXX constants. Read/write. 164 static const char KEY_SCENE_MODE[]; 165 // Supported scene mode settings. 166 // Example value: "auto,night,fireworks". Read only. 167 static const char KEY_SUPPORTED_SCENE_MODES[]; 168 // Current flash mode. 169 // Example value: "auto" or FLASH_MODE_XXX constants. Read/write. 170 static const char KEY_FLASH_MODE[]; 171 // Supported flash modes. 172 // Example value: "auto,on,off". Read only. 173 static const char KEY_SUPPORTED_FLASH_MODES[]; 174 // Current focus mode. If the camera does not support auto-focus, the value 175 // should be FOCUS_MODE_FIXED. If the focus mode is not FOCUS_MODE_FIXED or 176 // or FOCUS_MODE_INFINITY, applications should call 177 // CameraHardwareInterface.autoFocus to start the focus. 178 // Example value: "auto" or FOCUS_MODE_XXX constants. Read/write. 179 static const char KEY_FOCUS_MODE[]; 180 // Supported focus modes. 181 // Example value: "auto,macro,fixed". Read only. 182 static const char KEY_SUPPORTED_FOCUS_MODES[]; 183 // Focal length in millimeter. 184 // Example value: "4.31". Read only. 185 static const char KEY_FOCAL_LENGTH[]; 186 // Horizontal angle of view in degrees. 187 // Example value: "54.8". Read only. 188 static const char KEY_HORIZONTAL_VIEW_ANGLE[]; 189 // Vertical angle of view in degrees. 190 // Example value: "42.5". Read only. 191 static const char KEY_VERTICAL_VIEW_ANGLE[]; 192 // Exposure compensation index. 0 means exposure is not adjusted. 193 // Example value: "0" or "5". Read/write. 194 static const char KEY_EXPOSURE_COMPENSATION[]; 195 // The maximum exposure compensation index (>=0). 196 // Example value: "6". Read only. 197 static const char KEY_MAX_EXPOSURE_COMPENSATION[]; 198 // The minimum exposure compensation index (<=0). 199 // Example value: "-6". Read only. 200 static const char KEY_MIN_EXPOSURE_COMPENSATION[]; 201 // The exposure compensation step. Exposure compensation index multiply by 202 // step eqals to EV. Ex: if exposure compensation index is 6 and step is 203 // 0.3333, EV is -2. 204 // Example value: "0.333333333" or "0.5". Read only. 205 static const char KEY_EXPOSURE_COMPENSATION_STEP[]; 206 // Current zoom value. 207 // Example value: "0" or "6". Read/write. 208 static const char KEY_ZOOM[]; 209 // Maximum zoom value. 210 // Example value: "6". Read only. 211 static const char KEY_MAX_ZOOM[]; 212 // The zoom ratios of all zoom values. The zoom ratio is in 1/100 213 // increments. Ex: a zoom of 3.2x is returned as 320. The number of list 214 // elements is KEY_MAX_ZOOM + 1. The first element is always 100. The last 215 // element is the zoom ratio of zoom value KEY_MAX_ZOOM. 216 // Example value: "100,150,200,250,300,350,400". Read only. 217 static const char KEY_ZOOM_RATIOS[]; 218 // Whether zoom is supported. Zoom is supported if the value is "true". Zoom 219 // is not supported if the value is not "true" or the key does not exist. 220 // Example value: "true". Read only. 221 static const char KEY_ZOOM_SUPPORTED[]; 222 // Whether if smooth zoom is supported. Smooth zoom is supported if the 223 // value is "true". It is not supported if the value is not "true" or the 224 // key does not exist. 225 // See CAMERA_CMD_START_SMOOTH_ZOOM, CAMERA_CMD_STOP_SMOOTH_ZOOM, and 226 // CAMERA_MSG_ZOOM in frameworks/base/include/camera/Camera.h. 227 // Example value: "true". Read only. 228 static const char KEY_SMOOTH_ZOOM_SUPPORTED[]; 229 230 // The distances (in meters) from the camera to where an object appears to 231 // be in focus. The object is sharpest at the optimal focus distance. The 232 // depth of field is the far focus distance minus near focus distance. 233 // 234 // Applications can read this parameter anytime to get the latest focus 235 // distances. If the focus mode is FOCUS_MODE_EDOF, the values may be all 236 // 0, which means focus distance is not applicable. If the focus mode is 237 // FOCUS_MODE_CONTINUOUS and autofocus has started, focus distances may 238 // change from time to time. 239 // 240 // Far focus distance > optimal focus distance > near focus distance. If 241 // the far focus distance is infinity, the value should be "Infinity" (case 242 // sensitive). The format is three float values separated by commas. The 243 // first is near focus distance. The second is optimal focus distance. The 244 // third is far focus distance. 245 // Example value: "0.95,1.9,Infinity" or "0.049,0.05,0.051". Read only. 246 static const char KEY_FOCUS_DISTANCES[]; 247 248 // The image format for video frames. See CAMERA_MSG_VIDEO_FRAME in 249 // frameworks/base/include/camera/Camera.h. 250 // Example value: "yuv420sp" or PIXEL_FORMAT_XXX constants. Read only. 251 static const char KEY_VIDEO_FRAME_FORMAT[]; 252 253 // Metering mode. This affects how camera determines exposure. 254 // Example value: "spot" or METERING_MODE_XXX constants. Read/write. 255 static const char KEY_METERING_MODE[]; 256 257 // Value for KEY_ZOOM_SUPPORTED or KEY_SMOOTH_ZOOM_SUPPORTED. 258 static const char TRUE[]; 259 260 // Value for KEY_FOCUS_DISTANCES. 261 static const char FOCUS_DISTANCE_INFINITY[]; 262 263 // Values for white balance settings. 264 static const char WHITE_BALANCE_AUTO[]; 265 static const char WHITE_BALANCE_INCANDESCENT[]; 266 static const char WHITE_BALANCE_FLUORESCENT[]; 267 static const char WHITE_BALANCE_WARM_FLUORESCENT[]; 268 static const char WHITE_BALANCE_DAYLIGHT[]; 269 static const char WHITE_BALANCE_CLOUDY_DAYLIGHT[]; 270 static const char WHITE_BALANCE_TWILIGHT[]; 271 static const char WHITE_BALANCE_SHADE[]; 272 273 // Values for effect settings. 274 static const char EFFECT_NONE[]; 275 static const char EFFECT_MONO[]; 276 static const char EFFECT_NEGATIVE[]; 277 static const char EFFECT_SOLARIZE[]; 278 static const char EFFECT_SEPIA[]; 279 static const char EFFECT_POSTERIZE[]; 280 static const char EFFECT_WHITEBOARD[]; 281 static const char EFFECT_BLACKBOARD[]; 282 static const char EFFECT_AQUA[]; 283 284 // Values for antibanding settings. 285 static const char ANTIBANDING_AUTO[]; 286 static const char ANTIBANDING_50HZ[]; 287 static const char ANTIBANDING_60HZ[]; 288 static const char ANTIBANDING_OFF[]; 289 290 // Values for flash mode settings. 291 // Flash will not be fired. 292 static const char FLASH_MODE_OFF[]; 293 // Flash will be fired automatically when required. The flash may be fired 294 // during preview, auto-focus, or snapshot depending on the driver. 295 static const char FLASH_MODE_AUTO[]; 296 // Flash will always be fired during snapshot. The flash may also be 297 // fired during preview or auto-focus depending on the driver. 298 static const char FLASH_MODE_ON[]; 299 // Flash will be fired in red-eye reduction mode. 300 static const char FLASH_MODE_RED_EYE[]; 301 // Constant emission of light during preview, auto-focus and snapshot. 302 // This can also be used for video recording. 303 static const char FLASH_MODE_TORCH[]; 304 305 // Values for scene mode settings. 306 static const char SCENE_MODE_AUTO[]; 307 static const char SCENE_MODE_ACTION[]; 308 static const char SCENE_MODE_PORTRAIT[]; 309 static const char SCENE_MODE_LANDSCAPE[]; 310 static const char SCENE_MODE_NIGHT[]; 311 static const char SCENE_MODE_NIGHT_PORTRAIT[]; 312 static const char SCENE_MODE_THEATRE[]; 313 static const char SCENE_MODE_BEACH[]; 314 static const char SCENE_MODE_SNOW[]; 315 static const char SCENE_MODE_SUNSET[]; 316 static const char SCENE_MODE_STEADYPHOTO[]; 317 static const char SCENE_MODE_FIREWORKS[]; 318 static const char SCENE_MODE_SPORTS[]; 319 static const char SCENE_MODE_PARTY[]; 320 static const char SCENE_MODE_CANDLELIGHT[]; 321 // Applications are looking for a barcode. Camera driver will be optimized 322 // for barcode reading. 323 static const char SCENE_MODE_BARCODE[]; 324 325 // Formats for setPreviewFormat and setPictureFormat. 326 static const char PIXEL_FORMAT_YUV422SP[]; 327 static const char PIXEL_FORMAT_YUV420SP[]; // NV21 328 static const char PIXEL_FORMAT_YUV422I[]; // YUY2 329 static const char PIXEL_FORMAT_RGB565[]; 330 static const char PIXEL_FORMAT_JPEG[]; 331 332 // Values for focus mode settings. 333 // Auto-focus mode. 334 static const char FOCUS_MODE_AUTO[]; 335 // Focus is set at infinity. Applications should not call 336 // CameraHardwareInterface.autoFocus in this mode. 337 static const char FOCUS_MODE_INFINITY[]; 338 static const char FOCUS_MODE_MACRO[]; 339 // Focus is fixed. The camera is always in this mode if the focus is not 340 // adjustable. If the camera has auto-focus, this mode can fix the 341 // focus, which is usually at hyperfocal distance. Applications should 342 // not call CameraHardwareInterface.autoFocus in this mode. 343 static const char FOCUS_MODE_FIXED[]; 344 // Extended depth of field (EDOF). Focusing is done digitally and 345 // continuously. Applications should not call 346 // CameraHardwareInterface.autoFocus in this mode. 347 static const char FOCUS_MODE_EDOF[]; 348 // Continuous focus mode. The camera continuously tries to focus. This is 349 // ideal for shooting video or shooting photo of moving object. Continuous 350 // focus starts when CameraHardwareInterface.autoFocus is called. Focus 351 // callback will be only called once as soon as the picture is in focus. 352 static const char FOCUS_MODE_CONTINUOUS[]; 353 354 // The camera determines the exposure by giving more weight to the 355 // central part of the scene. 356 static const char METERING_MODE_CENTER_WEIGHTED[]; 357 // The camera determines the exposure by averaging the entire scene, 358 // giving no weighting to any particular area. 359 static const char METERING_MODE_FRAME_AVERAGE[]; 360 // The camera determines the exposure by a very small area of the scene, 361 // typically the center. 362 static const char METERING_MODE_SPOT[]; 363 364private: 365 DefaultKeyedVector<String8,String8> mMap; 366}; 367 368}; // namespace android 369 370#endif 371