summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2009-11-10 18:32:09 +0800
committerWu-cheng Li <wuchengli@google.com>2009-11-12 11:41:24 +0800
commit9324f11afe9366cd5479828a214dc8de8696a5ab (patch)
tree23ba2cdd90c6d7483637eb53768c2a757a79df08 /src
parent01ed85fbf71fd89db9d031d1cc5529afd7b624f0 (diff)
downloadLegacyCamera-9324f11afe9366cd5479828a214dc8de8696a5ab.zip
LegacyCamera-9324f11afe9366cd5479828a214dc8de8696a5ab.tar.gz
LegacyCamera-9324f11afe9366cd5479828a214dc8de8696a5ab.tar.bz2
Add postview callback to know when the captured image is shown. b2237074
Some platform display the captured image to the screen in postview callback. Some do that in raw picture callback. The camera application wants to make sure the captured image is displayed for at least 1.2 seconds. But orginally the app does not register postview callback and always start the timer in raw picture callback. Currently postview callback always arrives before raw callback. Without this change, the camera app may think the captured image is not displyed long enough and add some delay before starting preview, which will increase the shot-to-shot latency (ex: 0.8s) unexpectedly.
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Camera.java57
1 files changed, 40 insertions, 17 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 972476d..22612ce 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -177,6 +177,8 @@ public class Camera extends Activity implements View.OnClickListener,
private final OneShotPreviewCallback mOneShotPreviewCallback =
new OneShotPreviewCallback();
private final ShutterCallback mShutterCallback = new ShutterCallback();
+ private final PostViewPictureCallback mPostViewPictureCallback =
+ new PostViewPictureCallback();
private final RawPictureCallback mRawPictureCallback =
new RawPictureCallback();
private final AutoFocusCallback mAutoFocusCallback =
@@ -190,6 +192,7 @@ public class Camera extends Activity implements View.OnClickListener,
private long mFocusCallbackTime;
private long mCaptureStartTime;
private long mShutterCallbackTime;
+ private long mPostViewPictureCallbackTime;
private long mRawPictureCallbackTime;
private long mJpegPictureCallbackTime;
private int mPicturesRemaining;
@@ -197,9 +200,9 @@ public class Camera extends Activity implements View.OnClickListener,
// These latency time are for the CameraLatency test.
public long mAutoFocusTime;
public long mShutterLag;
- public long mShutterAndRawPictureCallbackTime;
- public long mJpegPictureCallbackTimeLag;
- public long mRawPictureAndJpegPictureCallbackTime;
+ public long mShutterToPictureDisplayedTime;
+ public long mPictureDisplayedToJpegCallbackTime;
+ public long mJpegCallbackToFirstFrameTime;
// Add the media server tag
public static boolean mMediaServerDied = false;
@@ -553,9 +556,9 @@ public class Camera extends Activity implements View.OnClickListener,
android.hardware.Camera camera) {
long now = System.currentTimeMillis();
if (mJpegPictureCallbackTime != 0) {
- mJpegPictureCallbackTimeLag = now - mJpegPictureCallbackTime;
- Log.v(TAG, "mJpegPictureCallbackTimeLag = "
- + mJpegPictureCallbackTimeLag + "ms");
+ mJpegCallbackToFirstFrameTime = now - mJpegPictureCallbackTime;
+ Log.v(TAG, "mJpegCallbackToFirstFrameTime = "
+ + mJpegCallbackToFirstFrameTime + "ms");
mJpegPictureCallbackTime = 0;
} else {
Log.v(TAG, "Got first frame");
@@ -573,14 +576,22 @@ public class Camera extends Activity implements View.OnClickListener,
}
}
+ private final class PostViewPictureCallback implements PictureCallback {
+ public void onPictureTaken(
+ byte [] data, android.hardware.Camera camera) {
+ mPostViewPictureCallbackTime = System.currentTimeMillis();
+ Log.v(TAG, "mShutterToPostViewCallbackTime = "
+ + (mPostViewPictureCallbackTime - mShutterCallbackTime)
+ + "ms");
+ }
+ }
+
private final class RawPictureCallback implements PictureCallback {
public void onPictureTaken(
byte [] rawData, android.hardware.Camera camera) {
mRawPictureCallbackTime = System.currentTimeMillis();
- mShutterAndRawPictureCallbackTime =
- mRawPictureCallbackTime - mShutterCallbackTime;
- Log.v(TAG, "mShutterAndRawPictureCallbackTime = "
- + mShutterAndRawPictureCallbackTime + "ms");
+ Log.v(TAG, "mShutterToRawCallbackTime = "
+ + (mRawPictureCallbackTime - mShutterCallbackTime) + "ms");
}
}
@@ -598,16 +609,27 @@ public class Camera extends Activity implements View.OnClickListener,
}
mJpegPictureCallbackTime = System.currentTimeMillis();
- mRawPictureAndJpegPictureCallbackTime =
- mJpegPictureCallbackTime - mRawPictureCallbackTime;
- Log.v(TAG, "mRawPictureAndJpegPictureCallbackTime = "
- + mRawPictureAndJpegPictureCallbackTime + "ms");
+ // If postview callback has arrived, the captured image is displayed
+ // in postview callback. If not, the captured image is displayed in
+ // raw picture callback.
+ if (mPostViewPictureCallbackTime != 0) {
+ mShutterToPictureDisplayedTime =
+ mPostViewPictureCallbackTime - mShutterCallbackTime;
+ mPictureDisplayedToJpegCallbackTime =
+ mJpegPictureCallbackTime - mPostViewPictureCallbackTime;
+ } else {
+ mShutterToPictureDisplayedTime =
+ mRawPictureCallbackTime - mShutterCallbackTime;
+ mPictureDisplayedToJpegCallbackTime =
+ mJpegPictureCallbackTime - mRawPictureCallbackTime;
+ }
+ Log.v(TAG, "mPictureDisplayedToJpegCallbackTime = "
+ + mPictureDisplayedToJpegCallbackTime + "ms");
if (!mIsImageCaptureIntent) {
// We want to show the taken picture for a while, so we wait
// for at least 1.2 second before restarting the preview.
- long delay = 1200 - (
- System.currentTimeMillis() - mRawPictureCallbackTime);
+ long delay = 1200 - mPictureDisplayedToJpegCallbackTime;
if (delay < 0) {
restartPreview();
} else {
@@ -810,7 +832,7 @@ public class Camera extends Activity implements View.OnClickListener,
mCameraDevice.setParameters(mParameters);
mCameraDevice.takePicture(mShutterCallback, mRawPictureCallback,
- new JpegPictureCallback(loc));
+ mPostViewPictureCallback, new JpegPictureCallback(loc));
mPreviewing = false;
}
@@ -820,6 +842,7 @@ public class Camera extends Activity implements View.OnClickListener,
return;
}
mCaptureStartTime = System.currentTimeMillis();
+ mPostViewPictureCallbackTime = 0;
// Don't check the filesystem here, we can't afford the latency.
// Instead, check the cached value which was calculated when the