summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/VideoCamera.java
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-10-24 17:24:41 +0800
committerWu-cheng Li <wuchengli@google.com>2011-10-24 17:43:14 +0800
commiteb47ed18eb3eec902d1ce18d20530e296bd83d9e (patch)
tree8ec70f7bea271c3e6a272400cd92aa7129d4a6a6 /src/com/android/camera/VideoCamera.java
parent37eac5970dcac64ddb547f32f4a642c77b83a28f (diff)
downloadLegacyCamera-eb47ed18eb3eec902d1ce18d20530e296bd83d9e.zip
LegacyCamera-eb47ed18eb3eec902d1ce18d20530e296bd83d9e.tar.gz
LegacyCamera-eb47ed18eb3eec902d1ce18d20530e296bd83d9e.tar.bz2
Fix video thumbnail is not displayed when intent passes the fd.
bug:5494625 Change-Id: I2bc482c05b9ca47bb566e351746a6e4dccdd6111
Diffstat (limited to 'src/com/android/camera/VideoCamera.java')
-rwxr-xr-xsrc/com/android/camera/VideoCamera.java52
1 files changed, 31 insertions, 21 deletions
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 5ad9205..9f47d5c 100755
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -949,6 +949,7 @@ public class VideoCamera extends ActivityBase
}
finishRecorderAndCloseCamera();
+ closeVideoFileDescriptor();
if (mSharePopup != null) mSharePopup.dismiss();
@@ -1136,6 +1137,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) {
@@ -1276,6 +1278,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) {
@@ -1328,14 +1331,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() {
@@ -1600,19 +1595,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);
@@ -1649,7 +1648,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.
@@ -2374,4 +2373,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;
+ }
+ }
}