summaryrefslogtreecommitdiffstats
path: root/camera2/portability/src/com/android/ex/camera2/portability/CameraAgent.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/CameraAgent.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/CameraAgent.java')
-rw-r--r--camera2/portability/src/com/android/ex/camera2/portability/CameraAgent.java29
1 files changed, 22 insertions, 7 deletions
diff --git a/camera2/portability/src/com/android/ex/camera2/portability/CameraAgent.java b/camera2/portability/src/com/android/ex/camera2/portability/CameraAgent.java
index d875cea..dd4f77c 100644
--- a/camera2/portability/src/com/android/ex/camera2/portability/CameraAgent.java
+++ b/camera2/portability/src/com/android/ex/camera2/portability/CameraAgent.java
@@ -618,16 +618,32 @@ public abstract class CameraAgent {
CameraPictureCallback jpeg);
/**
- * Sets the display orientation for camera to adjust the preview orientation.
+ * Sets the display orientation for camera to adjust the preview and JPEG orientation.
*
- * @param degrees The rotation in degrees. Should be 0, 90, 180 or 270.
+ * @param degrees The counterclockwise rotation in degrees, relative to the device's natural
+ * orientation. Should be 0, 90, 180 or 270.
*/
public void setDisplayOrientation(final int degrees) {
+ setDisplayOrientation(degrees, true);
+ }
+
+ /**
+ * Sets the display orientation for camera to adjust the preview&mdash;and, optionally,
+ * JPEG&mdash;orientations.
+ * <p>If capture rotation is not requested, future captures will be returned in the sensor's
+ * physical rotation, which does not necessarily match the device's natural orientation.</p>
+ *
+ * @param degrees The counterclockwise rotation in degrees, relative to the device's natural
+ * orientation. Should be 0, 90, 180 or 270.
+ * @param capture Whether to adjust the JPEG capture orientation as well as the preview one.
+ */
+ public void setDisplayOrientation(final int degrees, final boolean capture) {
getDispatchThread().runJob(new Runnable() {
@Override
public void run() {
getCameraHandler()
- .obtainMessage(CameraActions.SET_DISPLAY_ORIENTATION, degrees, 0)
+ .obtainMessage(CameraActions.SET_DISPLAY_ORIENTATION, degrees,
+ capture ? 1 : 0)
.sendToTarget();
}});
}
@@ -713,7 +729,7 @@ public abstract class CameraAgent {
* @param statesToAwait Bitwise OR of the required camera states.
* @return Whether the settings can be applied.
*/
- protected boolean applySettingsHelper(final CameraSettings settings,
+ protected boolean applySettingsHelper(CameraSettings settings,
final int statesToAwait) {
if (settings == null) {
Log.v(TAG, "null parameters in applySettings()");
@@ -723,15 +739,14 @@ public abstract class CameraAgent {
return false;
}
- final CameraSettings copyOfSettings = new CameraSettings(settings);
+ final CameraSettings copyOfSettings = settings.copy();
getDispatchThread().runJob(new Runnable() {
@Override
public void run() {
getCameraState().waitForStates(statesToAwait);
getCameraHandler().obtainMessage(CameraActions.APPLY_SETTINGS, copyOfSettings)
.sendToTarget();
- }
- });
+ }});
return true;
}