summaryrefslogtreecommitdiffstats
path: root/include/camera
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2014-03-18 18:15:23 -0700
committerIgor Murashkin <iam@google.com>2014-03-20 00:21:25 +0000
commit9078a1b3b9f9c0c48046ade0e8e18b0d79a659db (patch)
treeb621ec3b2db6b4dcb12df7d201eb474a09183386 /include/camera
parentb4a7a2df4c28c3f32b5d877b54831d2cc5d78f81 (diff)
downloadframeworks_av-9078a1b3b9f9c0c48046ade0e8e18b0d79a659db.zip
frameworks_av-9078a1b3b9f9c0c48046ade0e8e18b0d79a659db.tar.gz
frameworks_av-9078a1b3b9f9c0c48046ade0e8e18b0d79a659db.tar.bz2
camera: Fix setParameters for Preview FPS single/range values
Bug: 12609188 Change-Id: I82ea6f5de2183dd046d4bf5683600c97f37ab4db
Diffstat (limited to 'include/camera')
-rw-r--r--include/camera/CameraParameters.h104
1 files changed, 103 insertions, 1 deletions
diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index d521543..833ba76 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -18,6 +18,7 @@
#define ANDROID_HARDWARE_CAMERA_PARAMETERS_H
#include <utils/KeyedVector.h>
+#include <utils/Vector.h>
#include <utils/String8.h>
namespace android {
@@ -50,10 +51,26 @@ public:
void set(const char *key, const char *value);
void set(const char *key, int value);
void setFloat(const char *key, float value);
+ // Look up string value by key.
+ // -- The string remains valid until the next set/remove of the same key,
+ // or until the map gets cleared.
const char *get(const char *key) const;
int getInt(const char *key) const;
float getFloat(const char *key) const;
+ // Compare the order that key1 was set vs the order that key2 was set.
+ //
+ // Sets the order parameter to an integer less than, equal to, or greater
+ // than zero if key1's set order was respectively, to be less than, to
+ // match, or to be greater than key2's set order.
+ //
+ // Error codes:
+ // * NAME_NOT_FOUND - if either key has not been set previously
+ // * BAD_VALUE - if any of the parameters are NULL
+ status_t compareSetOrder(const char *key1, const char *key2,
+ /*out*/
+ int *order) const;
+
void remove(const char *key);
void setPreviewSize(int width, int height);
@@ -91,6 +108,7 @@ public:
void setPreviewFrameRate(int fps);
int getPreviewFrameRate() const;
void getPreviewFpsRange(int *min_fps, int *max_fps) const;
+ void setPreviewFpsRange(int min_fps, int max_fps);
void setPreviewFormat(const char *format);
const char *getPreviewFormat() const;
void setPictureSize(int width, int height);
@@ -675,7 +693,91 @@ public:
static const char LIGHTFX_HDR[];
private:
- DefaultKeyedVector<String8,String8> mMap;
+
+ // Quick and dirty map that maintains insertion order
+ template <typename KeyT, typename ValueT>
+ struct OrderedKeyedVector {
+
+ ssize_t add(const KeyT& key, const ValueT& value) {
+ return mList.add(Pair(key, value));
+ }
+
+ size_t size() const {
+ return mList.size();
+ }
+
+ const KeyT& keyAt(size_t idx) const {
+ return mList[idx].mKey;
+ }
+
+ const ValueT& valueAt(size_t idx) const {
+ return mList[idx].mValue;
+ }
+
+ const ValueT& valueFor(const KeyT& key) const {
+ ssize_t i = indexOfKey(key);
+ LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__);
+
+ return valueAt(i);
+ }
+
+ ssize_t indexOfKey(const KeyT& key) const {
+ size_t vectorIdx = 0;
+ for (; vectorIdx < mList.size(); ++vectorIdx) {
+ if (mList[vectorIdx].mKey == key) {
+ return (ssize_t) vectorIdx;
+ }
+ }
+
+ return NAME_NOT_FOUND;
+ }
+
+ ssize_t removeItem(const KeyT& key) {
+ size_t vectorIdx = (size_t) indexOfKey(key);
+
+ if (vectorIdx < 0) {
+ return vectorIdx;
+ }
+
+ return mList.removeAt(vectorIdx);
+ }
+
+ void clear() {
+ mList.clear();
+ }
+
+ // Same as removing and re-adding. The key's index changes to max.
+ ssize_t replaceValueFor(const KeyT& key, const ValueT& value) {
+ removeItem(key);
+ return add(key, value);
+ }
+
+ private:
+
+ struct Pair {
+ Pair() : mKey(), mValue() {}
+ Pair(const KeyT& key, const ValueT& value) :
+ mKey(key),
+ mValue(value) {}
+ KeyT mKey;
+ ValueT mValue;
+ };
+
+ Vector<Pair> mList;
+ };
+
+ /**
+ * Order matters: Keys that are set() later are stored later in the map.
+ *
+ * If two keys have meaning that conflict, then the later-set key
+ * wins.
+ *
+ * For example, preview FPS and preview FPS range conflict since only
+ * we only want to use the FPS range if that's the last thing that was set.
+ * So in that case, only use preview FPS range if it was set later than
+ * the preview FPS.
+ */
+ OrderedKeyedVector<String8,String8> mMap;
};
}; // namespace android