The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
| 23 | namespace android { |
| 24 | |
| 25 | class CameraParameters |
| 26 | { |
| 27 | public: |
| 28 | CameraParameters(); |
| 29 | CameraParameters(const String8 ¶ms) { unflatten(params); } |
| 30 | ~CameraParameters(); |
| 31 | |
| 32 | enum { |
| 33 | CAMERA_ORIENTATION_UNKNOWN = 0, |
| 34 | CAMERA_ORIENTATION_PORTRAIT = 1, |
| 35 | CAMERA_ORIENTATION_LANDSCAPE = 2, |
| 36 | }; |
| 37 | |
| 38 | String8 flatten() const; |
| 39 | void unflatten(const String8 ¶ms); |
| 40 | |
| 41 | void set(const char *key, const char *value); |
| 42 | void set(const char *key, int value); |
| 43 | const char *get(const char *key) const; |
| 44 | int getInt(const char *key) const; |
| 45 | |
| 46 | /* preview-size=176x144 */ |
| 47 | void setPreviewSize(int width, int height); |
| 48 | void getPreviewSize(int *width, int *height) const; |
| 49 | |
| 50 | /* preview-fps=15 */ |
| 51 | void setPreviewFrameRate(int fps); |
| 52 | int getPreviewFrameRate() const; |
| 53 | |
| 54 | /* preview-format=rgb565|yuv422 */ |
| 55 | void setPreviewFormat(const char *format); |
| 56 | const char *getPreviewFormat() const; |
| 57 | |
| 58 | /* picture-size=1024x768 */ |
| 59 | void setPictureSize(int width, int height); |
| 60 | void getPictureSize(int *width, int *height) const; |
| 61 | |
| 62 | /* picture-format=yuv422|jpeg */ |
| 63 | void setPictureFormat(const char *format); |
| 64 | const char *getPictureFormat() const; |
| 65 | |
| 66 | int getOrientation() const; |
| 67 | void setOrientation(int orientation); |
| 68 | |
| 69 | void dump() const; |
| 70 | status_t dump(int fd, const Vector<String16>& args) const; |
| 71 | |
Wu-cheng Li | cc6ce20 | 2009-09-23 14:37:52 -0700 | [diff] [blame] | 72 | // Parameter keys to communicate between camera application and driver. |
| 73 | // The access (read/write, read only, or write only) is viewed from the |
| 74 | // perspective of applications, not driver. |
| 75 | |
| 76 | // Preview frame size in pixels (width x height). |
| 77 | // Example value: "480x320". Read/Write. |
| 78 | static const char KEY_PREVIEW_SIZE[]; |
| 79 | // Supported preview frame sizes in pixels. |
| 80 | // Example value: "800x600,480x320". Read only. |
| 81 | static const char KEY_SUPPORTED_PREVIEW_SIZES[]; |
| 82 | // The image format for preview frames. |
| 83 | // Example value: "yuv420sp" or PIXEL_FORMAT_XXX constants. Read/write. |
| 84 | static const char KEY_PREVIEW_FORMAT[]; |
| 85 | // Supported image formats for preview frames. |
| 86 | // Example value: "yuv420sp,yuv422i-yuyv". Read only. |
| 87 | static const char KEY_SUPPORTED_PREVIEW_FORMATS[]; |
| 88 | // Number of preview frames per second. |
| 89 | // Example value: "15". Read/write. |
| 90 | static const char KEY_PREVIEW_FRAME_RATE[]; |
| 91 | // Supported number of preview frames per second. |
| 92 | // Example value: "24,15,10". Read. |
| 93 | static const char KEY_SUPPORTED_PREVIEW_FRAME_RATES[]; |
| 94 | // The dimensions for captured pictures in pixels (width x height). |
| 95 | // Example value: "1024x768". Read/write. |
| 96 | static const char KEY_PICTURE_SIZE[]; |
| 97 | // Supported dimensions for captured pictures in pixels. |
| 98 | // Example value: "2048x1536,1024x768". Read only. |
| 99 | static const char KEY_SUPPORTED_PICTURE_SIZES[]; |
| 100 | // The image format for captured pictures. |
| 101 | // Example value: "jpeg" or PIXEL_FORMAT_XXX constants. Read/write. |
| 102 | static const char KEY_PICTURE_FORMAT[]; |
| 103 | // Supported image formats for captured pictures. |
| 104 | // Example value: "jpeg,rgb565". Read only. |
| 105 | static const char KEY_SUPPORTED_PICTURE_FORMATS[]; |
| 106 | // The width (in pixels) of EXIF thumbnail in Jpeg picture. |
| 107 | // Example value: "512". Read/write. |
| 108 | static const char KEY_JPEG_THUMBNAIL_WIDTH[]; |
| 109 | // The height (in pixels) of EXIF thumbnail in Jpeg picture. |
| 110 | // Example value: "384". Read/write. |
| 111 | static const char KEY_JPEG_THUMBNAIL_HEIGHT[]; |
| 112 | // Supported EXIF thumbnail sizes (width x height). |
| 113 | // Example value: "512x384,320x240". Read only. |
| 114 | static const char KEY_SUPPORTED_THUMBNAIL_SIZES[]; |
| 115 | // The quality of the EXIF thumbnail in Jpeg picture. The range is 1 to 100, |
| 116 | // with 100 being the best. |
| 117 | // Example value: "90". Read/write. |
| 118 | static const char KEY_JPEG_THUMBNAIL_QUALITY[]; |
| 119 | // Jpeg quality of captured picture. The range is 1 to 100, with 100 being |
| 120 | // the best. |
| 121 | // Example value: "90". Read/write. |
| 122 | static const char KEY_JPEG_QUALITY[]; |
| 123 | // The orientation of the device in degrees. For example, suppose the |
| 124 | // natural position of the device is landscape. If the user takes a picture |
| 125 | // in landscape mode in 2048x1536 resolution, the rotation will be set to |
| 126 | // "0". If the user rotates the phone 90 degrees clockwise, the rotation |
| 127 | // should be set to "90". |
| 128 | // The camera driver can set orientation in the EXIF header without rotating |
| 129 | // the picture. Or the driver can rotate the picture and the EXIF thumbnail. |
| 130 | // If the Jpeg picture is rotated, the orientation in the EXIF header should |
| 131 | // be missing or 1 (row #0 is top and column #0 is left side). The driver |
| 132 | // should not set default value for this parameter. |
| 133 | // Example value: "0" or "90" or "180" or "270". Write only. |
| 134 | static const char KEY_ROTATION[]; |
| 135 | // GPS latitude coordinate. This will be stored in JPEG EXIF header. |
| 136 | // Example value: "25.032146". Write only. |
| 137 | static const char KEY_GPS_LATITUDE[]; |
| 138 | // GPS longitude coordinate. This will be stored in JPEG EXIF header. |
| 139 | // Example value: "121.564448". Write only. |
| 140 | static const char KEY_GPS_LONGITUDE[]; |
| 141 | // GPS altitude. This will be stored in JPEG EXIF header. |
| 142 | // Example value: "21.0". Write only. |
| 143 | static const char KEY_GPS_ALTITUDE[]; |
| 144 | // GPS timestamp (UTC in seconds since January 1, 1970). This should be |
| 145 | // stored in JPEG EXIF header. |
| 146 | // Example value: "1251192757". Write only. |
| 147 | static const char KEY_GPS_TIMESTAMP[]; |
| 148 | // Current white balance setting. |
| 149 | // Example value: "auto" or WHITE_BALANCE_XXX constants. Read/write. |
| 150 | static const char KEY_WHITE_BALANCE[]; |
| 151 | // Supported white balance settings. |
| 152 | // Example value: "auto,incandescent,daylight". Read only. |
| 153 | static const char KEY_SUPPORTED_WHITE_BALANCE[]; |
| 154 | // Current color effect setting. |
| 155 | // Example value: "none" or EFFECT_XXX constants. Read/write. |
| 156 | static const char KEY_EFFECT[]; |
| 157 | // Supported color effect settings. |
| 158 | // Example value: "none,mono,sepia". Read only. |
| 159 | static const char KEY_SUPPORTED_EFFECTS[]; |
| 160 | // Current antibanding setting. |
| 161 | // Example value: "auto" or ANTIBANDING_XXX constants. Read/write. |
| 162 | static const char KEY_ANTIBANDING[]; |
| 163 | // Supported antibanding settings. |
| 164 | // Example value: "auto,50hz,60hz,off". Read only. |
| 165 | static const char KEY_SUPPORTED_ANTIBANDING[]; |
| 166 | // Current scene mode. |
| 167 | // Example value: "auto" or SCENE_MODE_XXX constants. Read/write. |
| 168 | static const char KEY_SCENE_MODE[]; |
| 169 | // Supported scene mode settings. |
| 170 | // Example value: "auto,night,fireworks". Read only. |
| 171 | static const char KEY_SUPPORTED_SCENE_MODES[]; |
| 172 | // Current flash mode. |
| 173 | // Example value: "auto" or FLASH_MODE_XXX constants. Read/write. |
| 174 | static const char KEY_FLASH_MODE[]; |
| 175 | // Supported flash modes. |
| 176 | // Example value: "auto,on,off". Read only. |
| 177 | static const char KEY_SUPPORTED_FLASH_MODES[]; |
| 178 | // Current focus mode. If the camera does not support auto-focus, the value |
| 179 | // should be FOCUS_MODE_FIXED. If the focus mode is not FOCUS_MODE_FIXED or |
| 180 | // or FOCUS_MODE_INFINITY, applications should call |
| 181 | // CameraHardwareInterface.autoFocus to start the focus. |
| 182 | // Example value: "auto" or FOCUS_MODE_XXX constants. Read/write. |
| 183 | static const char KEY_FOCUS_MODE[]; |
| 184 | // Supported focus modes. |
| 185 | // Example value: "auto,macro,fixed". Read only. |
| 186 | static const char KEY_SUPPORTED_FOCUS_MODES[]; |
| 187 | |
| 188 | // Values for white balance settings. |
| 189 | static const char WHITE_BALANCE_AUTO[]; |
| 190 | static const char WHITE_BALANCE_INCANDESCENT[]; |
| 191 | static const char WHITE_BALANCE_FLUORESCENT[]; |
| 192 | static const char WHITE_BALANCE_WARM_FLUORESCENT[]; |
| 193 | static const char WHITE_BALANCE_DAYLIGHT[]; |
| 194 | static const char WHITE_BALANCE_CLOUDY_DAYLIGHT[]; |
| 195 | static const char WHITE_BALANCE_TWILIGHT[]; |
| 196 | static const char WHITE_BALANCE_SHADE[]; |
| 197 | |
| 198 | // Values for effect settings. |
| 199 | static const char EFFECT_NONE[]; |
| 200 | static const char EFFECT_MONO[]; |
| 201 | static const char EFFECT_NEGATIVE[]; |
| 202 | static const char EFFECT_SOLARIZE[]; |
| 203 | static const char EFFECT_SEPIA[]; |
| 204 | static const char EFFECT_POSTERIZE[]; |
| 205 | static const char EFFECT_WHITEBOARD[]; |
| 206 | static const char EFFECT_BLACKBOARD[]; |
| 207 | static const char EFFECT_AQUA[]; |
| 208 | |
| 209 | // Values for antibanding settings. |
| 210 | static const char ANTIBANDING_AUTO[]; |
| 211 | static const char ANTIBANDING_50HZ[]; |
| 212 | static const char ANTIBANDING_60HZ[]; |
| 213 | static const char ANTIBANDING_OFF[]; |
| 214 | |
| 215 | // Values for flash mode settings. |
| 216 | // Flash will not be fired. |
| 217 | static const char FLASH_MODE_OFF[]; |
Wu-cheng Li | eb16a09 | 2009-09-28 13:51:12 -0700 | [diff] [blame] | 218 | // Flash will be fired automatically when required. The flash may be fired |
| 219 | // during preview, auto-focus, or snapshot depending on the driver. |
Wu-cheng Li | cc6ce20 | 2009-09-23 14:37:52 -0700 | [diff] [blame] | 220 | static const char FLASH_MODE_AUTO[]; |
Wu-cheng Li | eb16a09 | 2009-09-28 13:51:12 -0700 | [diff] [blame] | 221 | // Flash will always be fired during snapshot. The flash may also be |
| 222 | // fired during preview or auto-focus depending on the driver. |
Wu-cheng Li | cc6ce20 | 2009-09-23 14:37:52 -0700 | [diff] [blame] | 223 | static const char FLASH_MODE_ON[]; |
| 224 | // Flash will be fired in red-eye reduction mode. |
| 225 | static const char FLASH_MODE_RED_EYE[]; |
Wu-cheng Li | eb16a09 | 2009-09-28 13:51:12 -0700 | [diff] [blame] | 226 | // Constant emission of light during preview, auto-focus and snapshot. |
| 227 | // This can also be used for video recording. |
| 228 | static const char FLASH_MODE_TORCH[]; |
Wu-cheng Li | cc6ce20 | 2009-09-23 14:37:52 -0700 | [diff] [blame] | 229 | |
| 230 | // Values for scene mode settings. |
| 231 | static const char SCENE_MODE_AUTO[]; |
| 232 | static const char SCENE_MODE_ACTION[]; |
| 233 | static const char SCENE_MODE_PORTRAIT[]; |
| 234 | static const char SCENE_MODE_LANDSCAPE[]; |
| 235 | static const char SCENE_MODE_NIGHT[]; |
| 236 | static const char SCENE_MODE_NIGHT_PORTRAIT[]; |
| 237 | static const char SCENE_MODE_THEATRE[]; |
| 238 | static const char SCENE_MODE_BEACH[]; |
| 239 | static const char SCENE_MODE_SNOW[]; |
| 240 | static const char SCENE_MODE_SUNSET[]; |
| 241 | static const char SCENE_MODE_STEADYPHOTO[]; |
| 242 | static const char SCENE_MODE_FIREWORKS[]; |
| 243 | static const char SCENE_MODE_SPORTS[]; |
| 244 | static const char SCENE_MODE_PARTY[]; |
| 245 | static const char SCENE_MODE_CANDLELIGHT[]; |
| 246 | |
| 247 | // Formats for setPreviewFormat and setPictureFormat. |
| 248 | static const char PIXEL_FORMAT_YUV422SP[]; |
| 249 | static const char PIXEL_FORMAT_YUV420SP[]; // NV21 |
| 250 | static const char PIXEL_FORMAT_YUV422I[]; // YUY2 |
| 251 | static const char PIXEL_FORMAT_RGB565[]; |
| 252 | static const char PIXEL_FORMAT_JPEG[]; |
| 253 | |
| 254 | // Values for focus mode settings. |
| 255 | // Auto-focus mode. |
| 256 | static const char FOCUS_MODE_AUTO[]; |
| 257 | // Focus is set at infinity. Applications should not call |
| 258 | // CameraHardwareInterface.autoFocus in this mode. |
| 259 | static const char FOCUS_MODE_INFINITY[]; |
| 260 | static const char FOCUS_MODE_MACRO[]; |
| 261 | // Focus is fixed. The camera is always in this mode if the focus is not |
| 262 | // adjustable. If the camera has auto-focus, this mode can fix the |
| 263 | // focus, which is usually at hyperfocal distance. Applications should |
| 264 | // not call CameraHardwareInterface.autoFocus in this mode. |
| 265 | static const char FOCUS_MODE_FIXED[]; |
| 266 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 267 | private: |
| 268 | DefaultKeyedVector<String8,String8> mMap; |
| 269 | }; |
| 270 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 271 | }; // namespace android |
| 272 | |
| 273 | #endif |