summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/PhotoModule.java
diff options
context:
space:
mode:
authorVijay kumar Tumati <vtumati@codeaurora.org>2015-04-13 15:36:33 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2015-04-24 02:48:13 -0700
commitb7d32e9c5ab36f8a82e6251d9bb8ce269bf3f5c4 (patch)
treea34d2c2f0e4a54bd27b7c350beae0267513767fb /src/com/android/camera/PhotoModule.java
parent74eaa6a18569fd3daba5bd095b528a7a09e69858 (diff)
downloadandroid_packages_apps_Snap-b7d32e9c5ab36f8a82e6251d9bb8ce269bf3f5c4.tar.gz
android_packages_apps_Snap-b7d32e9c5ab36f8a82e6251d9bb8ce269bf3f5c4.tar.bz2
android_packages_apps_Snap-b7d32e9c5ab36f8a82e6251d9bb8ce269bf3f5c4.zip
SnapdragonCamera: Longshot with Burst Functionality.
This is a new Longshot feature where in the snapshot frames captured at ISP is @ 3fps and output JPEG encoded rate is @ 1.2 fps. This can be enabled by setting following setprop with the maximum number of snapshots. adb shell setprop persist.camera.longshot.max <max_number> e.g.:adb shell setprop persist.camera.longshot.max 10 If the number is -1, then the existing Longshot will be used. Main changes: 1) The number of Snapshot/Preview/Metadata buffers are increased to make sure no frames will be dropped @ ISP and to maintain burst fps. e.g.: For max number of 10 snapshots, Snapshot buffers are increased to 9 from existing 6. This buffer numbers are derived considering snapshot YUV frames @ 3 fps and JPEG encoding @ 1.2 fps. 2) Shutter will be played after receiving YUV frame instead of reprocess frame. 3) New Longshot stop command is sent after receiving all the required YUV callbacks or releasing the shutter before reaching Max number. 4) Existing Longshot off command is sent after receiving all JPEG CB.s for the issued TakePictures() and also shutter button will be disabled until all the JPEG callbacks are received. Change-Id: Id0c21aeb67245530768bf3ab859d39dea7e2bc40
Diffstat (limited to 'src/com/android/camera/PhotoModule.java')
-rw-r--r--src/com/android/camera/PhotoModule.java64
1 files changed, 45 insertions, 19 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 906b79c91..273c205f7 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -124,6 +124,7 @@ public class PhotoModule
private int mSnapshotMode;
private int mBurstSnapNum = 1;
private int mReceivedSnapNum = 0;
+ private int mLongshotSnapNum = 0;
public boolean mFaceDetectionEnabled = false;
private DrawAutoHDR mDrawAutoHDR;
/*Histogram variables*/
@@ -212,6 +213,8 @@ public class PhotoModule
private static final String PERSIST_LONG_SAVE = "persist.camera.longshot.save";
private static final String PERSIST_PREVIEW_RESTART = "persist.camera.feature.restart";
private static final String PERSIST_CAPTURE_ANIMATION = "persist.camera.capture.animate";
+ private static final String PERSIST_LONGSHOT_MAX_SNAP = "persist.camera.longshot.max";
+ private static int mLongShotMaxSnap = -1;
private static final int MINIMUM_BRIGHTNESS = 0;
private static final int MAXIMUM_BRIGHTNESS = 6;
@@ -967,8 +970,17 @@ public class PhotoModule
Log.e(TAG, "[KPI Perf] PROFILE_SHUTTER_LAG mShutterLag = " + mShutterLag + "ms");
synchronized(mCameraDevice) {
+ if (++mLongshotSnapNum >= mLongShotMaxSnap &&
+ (mLongShotMaxSnap != -1)) {
+ mLongshotActive = false;
+ mUI.enableShutter(false);
+ mCameraDevice.stopLongshot();
+ return;
+ }
+
if (mCameraState != LONGSHOT ||
!mLongshotActive) {
+ mCameraDevice.stopLongshot();
return;
}
@@ -1170,7 +1182,9 @@ public class PhotoModule
@Override
public void onPictureTaken(final byte [] jpegData, CameraProxy camera) {
- mUI.enableShutter(true);
+ if (mCameraState != LONGSHOT) {
+ mUI.enableShutter(true);
+ }
if (mPaused) {
return;
}
@@ -1209,19 +1223,25 @@ public class PhotoModule
mFocusManager.updateFocusUI(); // Ensure focus indicator is hidden.
+ if (isLongshotDone()) {
+ mCameraDevice.setLongshot(false);
+ }
+
boolean needRestartPreview = !mIsImageCaptureIntent
&& !mPreviewRestartSupport
&& (mCameraState != LONGSHOT)
&& (mSnapshotMode != CameraInfo.CAMERA_SUPPORT_MODE_ZSL)
- && (mReceivedSnapNum == mBurstSnapNum);
+ && ((mReceivedSnapNum == mBurstSnapNum) && (mCameraState != LONGSHOT));
+ needRestartPreview |= (isLongshotDone() && !mFocusManager.isZslEnabled());
if (needRestartPreview) {
setupPreview();
if (CameraUtil.FOCUS_MODE_CONTINUOUS_PICTURE.equals(
mFocusManager.getFocusMode())) {
mCameraDevice.cancelAutoFocus();
}
- } else if ((mReceivedSnapNum == mBurstSnapNum)
- && (mCameraState != LONGSHOT)){
+ } else if (((mCameraState != LONGSHOT) && (mReceivedSnapNum == mBurstSnapNum))
+ || isLongshotDone()){
+ mUI.enableShutter(true);
mFocusManager.resetTouchFocus();
if (CameraUtil.FOCUS_MODE_CONTINUOUS_PICTURE.equals(
mFocusManager.getFocusMode())) {
@@ -1315,7 +1335,8 @@ public class PhotoModule
}
}
// Animate capture with real jpeg data instead of a preview frame.
- if (mCameraState != LONGSHOT) {
+ if ((mCameraState != LONGSHOT) ||
+ isLongshotDone()) {
Size pic_size = mParameters.getPictureSize();
if ((pic_size.width <= 352) && (pic_size.height<= 288)) {
mUI.setDownFactor(2); //Downsample by 2 for CIF & below
@@ -1356,6 +1377,10 @@ public class PhotoModule
mJpegPictureCallbackTime = 0;
}
+ if (isLongshotDone()) {
+ mLongshotSnapNum = 0;
+ }
+
if (mHiston && (mSnapshotMode ==CameraInfo.CAMERA_SUPPORT_MODE_ZSL)) {
mActivity.runOnUiThread(new Runnable() {
public void run() {
@@ -1514,6 +1539,7 @@ public class PhotoModule
}
if (mCameraState == LONGSHOT) {
+ mLongshotSnapNum = 0;
mCameraDevice.setLongshot(true);
}
@@ -2019,19 +2045,7 @@ public class PhotoModule
synchronized(mCameraDevice) {
if (mCameraState == LONGSHOT) {
mLongshotActive = false;
- mCameraDevice.setLongshot(false);
- mUI.animateCapture(mLastJpegData, mLastJpegOrientation, mMirror);
- if (!mFocusManager.isZslEnabled()) {
- setupPreview();
- } else {
- setCameraState(IDLE);
- mFocusManager.resetTouchFocus();
- if (CameraUtil.FOCUS_MODE_CONTINUOUS_PICTURE.equals(
- mFocusManager.getFocusMode())) {
- mCameraDevice.cancelAutoFocus();
- }
- mUI.resumeFaceDetection();
- }
+ mUI.enableShutter(false);
}
}
@@ -2218,7 +2232,7 @@ public class PhotoModule
private void updateRemainingPhotos() {
if (mJpegFileSizeEstimation != 0) {
- mRemainingPhotos = (int)
+ mRemainingPhotos = (int)
((mActivity.getStorageSpaceBytes() - Storage.LOW_STORAGE_THRESHOLD_BYTES)
/ mJpegFileSizeEstimation);
} else {
@@ -2656,6 +2670,10 @@ public class PhotoModule
@Override
public void stopPreview() {
if (mCameraDevice != null && mCameraState != PREVIEW_STOPPED) {
+ if (mCameraState == LONGSHOT) {
+ mCameraDevice.setLongshot(false);
+ mLongshotActive = false;
+ }
Log.v(TAG, "stopPreview");
mCameraDevice.stopPreview();
}
@@ -3214,6 +3232,9 @@ public class PhotoModule
}
updatePowerMode();
+
+ mLongShotMaxSnap = SystemProperties.getInt(PERSIST_LONGSHOT_MAX_SNAP, -1);
+ mParameters.set("max-longshot-snap",mLongShotMaxSnap);
}
private int estimateJpegFileSize(final Size size, final String quality) {
@@ -4440,6 +4461,11 @@ public class PhotoModule
mCameraDevice.setParameters(mParameters);
mParameters = mCameraDevice.getParameters();
}
+
+ public boolean isLongshotDone() {
+ return ((mCameraState == LONGSHOT) && (mLongshotSnapNum == mReceivedSnapNum) &&
+ !mLongshotActive);
+ }
}
/* Below is no longer needed, except to get rid of compile error