summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEd Heyl <ed@google.com>2011-10-25 19:50:39 +0000
committerEd Heyl <ed@google.com>2011-10-25 19:50:39 +0000
commitb8bd7ee0f8b0c3e0381ae6364bbeca4f28bdf7a4 (patch)
tree40df7dfcac9f8449a6dacb671954bb485000d5bd /src
parent9c890bec972061e0e52b41a16a43d3b8fed73d34 (diff)
parentc04d01bb510465ea35a06b09146a3bb79c6f770e (diff)
downloadLegacyCamera-b8bd7ee0f8b0c3e0381ae6364bbeca4f28bdf7a4.zip
LegacyCamera-b8bd7ee0f8b0c3e0381ae6364bbeca4f28bdf7a4.tar.gz
LegacyCamera-b8bd7ee0f8b0c3e0381ae6364bbeca4f28bdf7a4.tar.bz2
Merge remote branch 'goog/ics-mr0' into ics-mr1
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Camera.java4
-rw-r--r--src/com/android/camera/EffectsRecorder.java15
-rw-r--r--src/com/android/camera/Thumbnail.java15
-rwxr-xr-xsrc/com/android/camera/VideoCamera.java52
4 files changed, 60 insertions, 26 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 252dff7..2ead501 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -1455,7 +1455,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
initializeCapabilities();
resetExposureCompensation();
startPreview();
- startFaceDetection();
+ if (mFirstTimeInitialized) startFaceDetection();
} catch (CameraHardwareException e) {
Util.showErrorAndFinish(this, R.string.cannot_connect_camera);
return;
@@ -1679,7 +1679,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
// display rotation in onCreate may not be what we want.
if (mCameraState == PREVIEW_STOPPED) {
startPreview();
- startFaceDetection();
+ if (mFirstTimeInitialized) startFaceDetection();
} else {
if (Util.getDisplayRotation(this) != mDisplayRotation) {
setDisplayOrientation();
diff --git a/src/com/android/camera/EffectsRecorder.java b/src/com/android/camera/EffectsRecorder.java
index d3b277d..a561011 100644
--- a/src/com/android/camera/EffectsRecorder.java
+++ b/src/com/android/camera/EffectsRecorder.java
@@ -562,8 +562,19 @@ public class EffectsRecorder {
synchronized(EffectsRecorder.this) {
mTextureSource = source;
- if (mState == STATE_RELEASED) return;
-
+ if (mState == STATE_CONFIGURE) {
+ // Stop preview happened while the runner was doing startup tasks
+ // Since we haven't started anything up, don't do anything
+ // Rest of cleanup will happen in onRunnerDone
+ if (mLogVerbose) Log.v(TAG, "Ready callback: Already stopped, skipping.");
+ return;
+ }
+ if (mState == STATE_RELEASED) {
+ // EffectsRecorder has been released, so don't touch the camera device
+ // or anything else
+ if (mLogVerbose) Log.v(TAG, "Ready callback: Already released, skipping.");
+ return;
+ }
if (source == null) {
if (mState == STATE_PREVIEW ||
mState == STATE_STARTING_PREVIEW ||
diff --git a/src/com/android/camera/Thumbnail.java b/src/com/android/camera/Thumbnail.java
index a0f892b..165614b 100644
--- a/src/com/android/camera/Thumbnail.java
+++ b/src/com/android/camera/Thumbnail.java
@@ -36,6 +36,7 @@ import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
+import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -244,11 +245,23 @@ public class Thumbnail {
return createThumbnail(uri, bitmap, orientation);
}
+ public static Bitmap createVideoThumbnail(FileDescriptor fd, int targetWidth) {
+ return createVideoThumbnail(null, fd, targetWidth);
+ }
+
public static Bitmap createVideoThumbnail(String filePath, int targetWidth) {
+ return createVideoThumbnail(filePath, null, targetWidth);
+ }
+
+ private static Bitmap createVideoThumbnail(String filePath, FileDescriptor fd, int targetWidth) {
Bitmap bitmap = null;
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
try {
- retriever.setDataSource(filePath);
+ if (filePath != null) {
+ retriever.setDataSource(filePath);
+ } else {
+ retriever.setDataSource(fd);
+ }
bitmap = retriever.getFrameAtTime(-1);
} catch (IllegalArgumentException ex) {
// Assume this is a corrupt video file
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 0cd57ef..4d09fee 100755
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -948,6 +948,7 @@ public class VideoCamera extends ActivityBase
}
finishRecorderAndCloseCamera();
+ closeVideoFileDescriptor();
if (mSharePopup != null) mSharePopup.dismiss();
@@ -1135,6 +1136,7 @@ public class VideoCamera extends ActivityBase
Bundle myExtras = intent.getExtras();
long requestedSizeLimit = 0;
+ closeVideoFileDescriptor();
if (mIsVideoCaptureIntent && myExtras != null) {
Uri saveUri = (Uri) myExtras.getParcelable(MediaStore.EXTRA_OUTPUT);
if (saveUri != null) {
@@ -1275,6 +1277,7 @@ public class VideoCamera extends ActivityBase
Bundle myExtras = intent.getExtras();
long requestedSizeLimit = 0;
+ closeVideoFileDescriptor();
if (mIsVideoCaptureIntent && myExtras != null) {
Uri saveUri = (Uri) myExtras.getParcelable(MediaStore.EXTRA_OUTPUT);
if (saveUri != null) {
@@ -1327,14 +1330,6 @@ public class VideoCamera extends ActivityBase
mMediaRecorder = null;
}
mVideoFilename = null;
- if (mVideoFileDescriptor != null) {
- try {
- mVideoFileDescriptor.close();
- } catch (IOException e) {
- Log.e(TAG, "Fail to close fd", e);
- }
- mVideoFileDescriptor = null;
- }
}
private void releaseEffectsRecorder() {
@@ -1599,19 +1594,23 @@ public class VideoCamera extends ActivityBase
}
private void showAlert() {
- if (mCurrentVideoFilename != null) {
- Bitmap bitmap = Thumbnail.createVideoThumbnail(mCurrentVideoFilename,
+ Bitmap bitmap = null;
+ if (mVideoFileDescriptor != null) {
+ bitmap = Thumbnail.createVideoThumbnail(mVideoFileDescriptor.getFileDescriptor(),
+ mPreviewFrameLayout.getWidth());
+ } else if (mCurrentVideoFilename != null) {
+ bitmap = Thumbnail.createVideoThumbnail(mCurrentVideoFilename,
mPreviewFrameLayout.getWidth());
- if (bitmap != null) {
- // MetadataRetriever already rotates the thumbnail. We should rotate
- // it to match the UI orientation (and mirror if it is front-facing camera).
- CameraInfo[] info = CameraHolder.instance().getCameraInfo();
- boolean mirror = (info[mCameraId].facing == CameraInfo.CAMERA_FACING_FRONT);
- bitmap = Util.rotateAndMirror(bitmap, -mOrientationCompensationAtRecordStart,
- mirror);
- mReviewImage.setImageBitmap(bitmap);
- mReviewImage.setVisibility(View.VISIBLE);
- }
+ }
+ if (bitmap != null) {
+ // MetadataRetriever already rotates the thumbnail. We should rotate
+ // it to match the UI orientation (and mirror if it is front-facing camera).
+ CameraInfo[] info = CameraHolder.instance().getCameraInfo();
+ boolean mirror = (info[mCameraId].facing == CameraInfo.CAMERA_FACING_FRONT);
+ bitmap = Util.rotateAndMirror(bitmap, -mOrientationCompensationAtRecordStart,
+ mirror);
+ mReviewImage.setImageBitmap(bitmap);
+ mReviewImage.setVisibility(View.VISIBLE);
}
Util.fadeOut(mShutterButton);
@@ -1648,7 +1647,7 @@ public class VideoCamera extends ActivityBase
try {
if (effectsActive()) {
- // This is asynchronous, so we cant add to media store now because thumbnail
+ // This is asynchronous, so we can't add to media store now because thumbnail
// may not be ready. In such case addVideoToMediaStore is called later
// through a callback from the MediaEncoderFilter to EffectsRecorder,
// and then to the VideoCamera.
@@ -2373,4 +2372,15 @@ public class VideoCamera extends ActivityBase
}
return ".3gp";
}
+
+ private void closeVideoFileDescriptor() {
+ if (mVideoFileDescriptor != null) {
+ try {
+ mVideoFileDescriptor.close();
+ } catch (IOException e) {
+ Log.e(TAG, "Fail to close fd", e);
+ }
+ mVideoFileDescriptor = null;
+ }
+ }
}