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