summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2010-06-03 16:34:18 +0800
committerWu-cheng Li <wuchengli@google.com>2010-06-03 16:34:18 +0800
commitf7f6333831e7b991d92abeddfbd46c2884afa405 (patch)
treebbe6fb84932164301709ddde62af18ad95ad405e
parent00e21f8eb57a7ae2c19516aa0290ab4fb5f251c2 (diff)
downloadframeworks_base-f7f6333831e7b991d92abeddfbd46c2884afa405.zip
frameworks_base-f7f6333831e7b991d92abeddfbd46c2884afa405.tar.gz
frameworks_base-f7f6333831e7b991d92abeddfbd46c2884afa405.tar.bz2
Add camera metering mode API.
bug:2737111 Change-Id: Ie986fee56ebeaaed2d2efb757701dfe3ffdec8d8
-rw-r--r--core/java/android/hardware/Camera.java60
-rw-r--r--include/camera/CameraParameters.h13
-rw-r--r--libs/camera/CameraParameters.cpp6
3 files changed, 79 insertions, 0 deletions
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index 54aa363..025db4a 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -763,6 +763,7 @@ public class Camera {
private static final String KEY_ZOOM_SUPPORTED = "zoom-supported";
private static final String KEY_SMOOTH_ZOOM_SUPPORTED = "smooth-zoom-supported";
private static final String KEY_FOCUS_DISTANCES = "focus-distances";
+ private static final String KEY_METERING_MODE = "metering-mode";
// Parameter key suffix for supported values.
private static final String SUPPORTED_VALUES_SUFFIX = "-values";
@@ -965,6 +966,26 @@ public class Camera {
*/
public static final String FOCUS_MODE_CONTINUOUS = "continuous";
+ /**
+ * The camera determines the exposure by giving more weight to the
+ * central part of the scene.
+ * @hide
+ */
+ public static final String METERING_MODE_CENTER_WEIGHTED = "center-weighted";
+
+ /**
+ * The camera determines the exposure by averaging the entire scene,
+ * giving no weighting to any particular area.
+ * @hide
+ */
+ public static final String METERING_MODE_FRAME_AVERAGE = "frame-average";
+
+ /**
+ * The camera determines the exposure by a very small area of the scene,
+ * typically the center.
+ * @hide
+ */
+ public static final String METERING_MODE_SPOT = "spot";
// Formats for setPreviewFormat and setPictureFormat.
private static final String PIXEL_FORMAT_YUV422SP = "yuv422sp";
@@ -1930,6 +1951,45 @@ public class Camera {
output[2] = distances.get(2);
}
+ /**
+ * Gets the supported metering modes.
+ *
+ * @return a list of supported metering modes. null if metering mode
+ * setting is not supported.
+ * @see #getMeteringMode()
+ * @hide
+ */
+ public List<String> getSupportedMeteringModes() {
+ String str = get(KEY_METERING_MODE + SUPPORTED_VALUES_SUFFIX);
+ return split(str);
+ }
+
+ /**
+ * Gets the current metering mode, which affects how camera determines
+ * exposure.
+ *
+ * @return current metering mode. If the camera does not support
+ * metering setting, this should return null.
+ * @see #METERING_MODE_CENTER_WEIGHTED
+ * @see #METERING_MODE_FRAME_AVERAGE
+ * @see #METERING_MODE_SPOT
+ * @hide
+ */
+ public String getMeteringMode() {
+ return get(KEY_METERING_MODE);
+ }
+
+ /**
+ * Sets the metering mode.
+ *
+ * @param value metering mode.
+ * @see #getMeteringMode()
+ * @hide
+ */
+ public void setMeteringMode(String value) {
+ set(KEY_METERING_MODE, value);
+ }
+
// Splits a comma delimited string to an ArrayList of String.
// Return null if the passing string is null or the size is 0.
private ArrayList<String> split(String str) {
diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index 2b7a86eb..4840b40 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -250,6 +250,10 @@ public:
// Example value: "yuv420sp" or PIXEL_FORMAT_XXX constants. Read only.
static const char KEY_VIDEO_FRAME_FORMAT[];
+ // Metering mode. This affects how camera determines exposure.
+ // Example value: "spot" or METERING_MODE_XXX constants. Read/write.
+ static const char KEY_METERING_MODE[];
+
// Value for KEY_ZOOM_SUPPORTED or KEY_SMOOTH_ZOOM_SUPPORTED.
static const char TRUE[];
@@ -347,6 +351,15 @@ public:
// callback will be only called once as soon as the picture is in focus.
static const char FOCUS_MODE_CONTINUOUS[];
+ // The camera determines the exposure by giving more weight to the
+ // central part of the scene.
+ static const char METERING_MODE_CENTER_WEIGHTED[];
+ // The camera determines the exposure by averaging the entire scene,
+ // giving no weighting to any particular area.
+ static const char METERING_MODE_FRAME_AVERAGE[];
+ // The camera determines the exposure by a very small area of the scene,
+ // typically the center.
+ static const char METERING_MODE_SPOT[];
private:
DefaultKeyedVector<String8,String8> mMap;
diff --git a/libs/camera/CameraParameters.cpp b/libs/camera/CameraParameters.cpp
index e4d5bb3..c11d18f 100644
--- a/libs/camera/CameraParameters.cpp
+++ b/libs/camera/CameraParameters.cpp
@@ -71,6 +71,7 @@ const char CameraParameters::KEY_ZOOM_SUPPORTED[] = "zoom-supported";
const char CameraParameters::KEY_SMOOTH_ZOOM_SUPPORTED[] = "smooth-zoom-supported";
const char CameraParameters::KEY_FOCUS_DISTANCES[] = "focus-distances";
const char CameraParameters::KEY_VIDEO_FRAME_FORMAT[] = "video-frame-format";
+const char CameraParameters::KEY_METERING_MODE[] = "metering-mode";
const char CameraParameters::TRUE[] = "true";
const char CameraParameters::FOCUS_DISTANCE_INFINITY[] = "Infinity";
@@ -142,6 +143,11 @@ const char CameraParameters::FOCUS_MODE_FIXED[] = "fixed";
const char CameraParameters::FOCUS_MODE_EDOF[] = "edof";
const char CameraParameters::FOCUS_MODE_CONTINUOUS[] = "continuous";
+// Values for metering mode settings.
+const char METERING_MODE_CENTER_WEIGHTED[] = "center-weighted";
+const char METERING_MODE_FRAME_AVERAGE[] = "frame-average";
+const char METERING_MODE_SPOT[] = "spot";
+
CameraParameters::CameraParameters()
: mMap()
{