summaryrefslogtreecommitdiffstats
path: root/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java
diff options
context:
space:
mode:
authorSol Boucher <solb@google.com>2014-07-22 18:39:32 -0700
committerSol Boucher <solb@google.com>2014-08-07 15:02:05 -0700
commitde48004068f8c16f9a56c60b0ed2485a67687b4b (patch)
treecc584bbc1756d0f5f00367f39565288679728809 /camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java
parentd4e5286bb4145e0371b783158fc8411565429c9b (diff)
downloadandroid_frameworks_ex-de48004068f8c16f9a56c60b0ed2485a67687b4b.tar.gz
android_frameworks_ex-de48004068f8c16f9a56c60b0ed2485a67687b4b.tar.bz2
android_frameworks_ex-de48004068f8c16f9a56c60b0ed2485a67687b4b.zip
camera2-portability: Support photo capture using camera2 API
This implements JPEG capture, including an autoexposure precapture sequence. There are many changes to AndroidCamera2Capabilities and AndroidCamera2Settings to support the representation of modes (e.g. flash modes) whose flags do not map trivially between the API implementations. Part of this work is the conversion of AndroidCamera2AgentImpl to use and store a Camera2RequestSettingsSet instead of a bare API 2 CaptureRequest.Builder. Change-Id: I03f9f98c954a7b0c140ac8d80161878c92ef65d2
Diffstat (limited to 'camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java')
-rw-r--r--camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java40
1 files changed, 24 insertions, 16 deletions
diff --git a/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java b/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java
index 3948b2e..26d0f85 100644
--- a/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java
+++ b/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java
@@ -18,6 +18,8 @@ package com.android.ex.camera2.portability;
import android.hardware.Camera;
+import com.android.ex.camera2.portability.debug.Log;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -26,7 +28,12 @@ import java.util.TreeMap;
/**
* A class which stores the camera settings.
*/
-public class CameraSettings {
+public abstract class CameraSettings {
+ private static final Log.Tag TAG = new Log.Tag("CamSet");
+
+ // Attempts to provide a value outside this range will be ignored.
+ private static final int MIN_JPEG_COMPRESSION_QUALITY = 1;
+ private static final int MAX_JPEG_COMPRESSION_QUALITY = 100;
protected final Map<String, String> mGeneralSetting = new TreeMap<>();
protected final List<Camera.Area> mMeteringAreas = new ArrayList<>();
@@ -37,11 +44,10 @@ public class CameraSettings {
protected Size mCurrentPreviewSize;
private int mCurrentPreviewFormat;
protected Size mCurrentPhotoSize;
- protected int mJpegCompressQuality;
+ protected byte mJpegCompressQuality;
protected int mCurrentPhotoFormat;
protected float mCurrentZoomRatio;
protected int mCurrentZoomIndex;
- protected float mPhotoRotationDegrees;
protected int mExposureCompensationIndex;
protected CameraCapabilities.FlashMode mCurrentFlashMode;
protected CameraCapabilities.FocusMode mCurrentFocusMode;
@@ -96,7 +102,7 @@ public class CameraSettings {
* @param src The source settings.
* @return The copy of the source.
*/
- public CameraSettings(CameraSettings src) {
+ protected CameraSettings(CameraSettings src) {
mGeneralSetting.putAll(src.mGeneralSetting);
mMeteringAreas.addAll(src.mMeteringAreas);
mFocusAreas.addAll(src.mFocusAreas);
@@ -112,7 +118,6 @@ public class CameraSettings {
mCurrentPhotoFormat = src.mCurrentPhotoFormat;
mCurrentZoomRatio = src.mCurrentZoomRatio;
mCurrentZoomIndex = src.mCurrentZoomIndex;
- mPhotoRotationDegrees = src.mPhotoRotationDegrees;
mExposureCompensationIndex = src.mExposureCompensationIndex;
mCurrentFlashMode = src.mCurrentFlashMode;
mCurrentFocusMode = src.mCurrentFocusMode;
@@ -126,6 +131,11 @@ public class CameraSettings {
mExifThumbnailSize = src.mExifThumbnailSize;
}
+ /**
+ * @return A copy of this object, as an instance of the implementing class.
+ */
+ public abstract CameraSettings copy();
+
/** General setting **/
@Deprecated
public void setSetting(String key, String value) {
@@ -258,7 +268,12 @@ public class CameraSettings {
* @param quality The quality for JPEG.
*/
public void setPhotoJpegCompressionQuality(int quality) {
- mJpegCompressQuality = quality;
+ if (quality < MIN_JPEG_COMPRESSION_QUALITY || quality > MAX_JPEG_COMPRESSION_QUALITY) {
+ Log.w(TAG, "Ignoring JPEG quality that falls outside the expected range");
+ return;
+ }
+ // This is safe because the positive numbers go up to 127.
+ mJpegCompressQuality = (byte) quality;
}
public int getPhotoJpegCompressionQuality() {
@@ -296,22 +311,15 @@ public class CameraSettings {
mCurrentZoomIndex = index;
}
- /** Transformation **/
-
- public void setPhotoRotationDegrees(float photoRotationDegrees) {
- mPhotoRotationDegrees = photoRotationDegrees;
- }
-
- public float getCurrentPhotoRotationDegrees() {
- return mPhotoRotationDegrees;
- }
-
/** Exposure **/
public void setExposureCompensationIndex(int index) {
mExposureCompensationIndex = index;
}
+ /**
+ * @return The exposure compensation, with 0 meaning unadjusted.
+ */
public int getExposureCompensationIndex() {
return mExposureCompensationIndex;
}