diff options
author | Rodrigo Carceroni <carceroni@google.com> | 2011-10-14 14:00:39 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-10-14 14:00:39 -0700 |
commit | f3d505afe66e0961e904027e8ab98455ccd3bd2e (patch) | |
tree | 4982cc864aa4f041c5fb17082aed9d7d2a9a1df6 /src/com/android | |
parent | f3b7efa21a1f2b365655acd8efffbdc1b83e6b0c (diff) | |
parent | caf8466dcdf6d6c496e46961bb3132126363ef83 (diff) | |
download | packages_apps_LegacyCamera-f3d505afe66e0961e904027e8ab98455ccd3bd2e.zip packages_apps_LegacyCamera-f3d505afe66e0961e904027e8ab98455ccd3bd2e.tar.gz packages_apps_LegacyCamera-f3d505afe66e0961e904027e8ab98455ccd3bd2e.tar.bz2 |
Merge "Bug 5383077: handle video thumbnail generation correctly when effects are on" into ics-mr0
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/camera/EffectsRecorder.java | 18 | ||||
-rwxr-xr-x | src/com/android/camera/VideoCamera.java | 17 |
2 files changed, 30 insertions, 5 deletions
diff --git a/src/com/android/camera/EffectsRecorder.java b/src/com/android/camera/EffectsRecorder.java index 3059281..5e8bfc1 100644 --- a/src/com/android/camera/EffectsRecorder.java +++ b/src/com/android/camera/EffectsRecorder.java @@ -25,9 +25,10 @@ import android.filterfw.core.GraphRunner; import android.filterfw.core.GraphRunner.OnRunnerDoneListener; import android.filterfw.geometry.Point; import android.filterfw.geometry.Quad; -import android.filterpacks.videosrc.SurfaceTextureSource.SurfaceTextureSourceListener; import android.filterpacks.videoproc.BackDropperFilter; import android.filterpacks.videoproc.BackDropperFilter.LearningDoneListener; +import android.filterpacks.videosink.MediaEncoderFilter.OnRecordingDoneListener; +import android.filterpacks.videosrc.SurfaceTextureSource.SurfaceTextureSourceListener; import android.graphics.SurfaceTexture; import android.hardware.Camera; @@ -71,6 +72,7 @@ public class EffectsRecorder { public static final int EFFECT_MSG_DONE_LEARNING = 1; public static final int EFFECT_MSG_SWITCHING_EFFECT = 2; public static final int EFFECT_MSG_EFFECTS_STOPPED = 3; + public static final int EFFECT_MSG_RECORDING_DONE = 4; private Context mContext; private Handler mHandler; @@ -370,7 +372,8 @@ public class EffectsRecorder { "recordingHeight", mProfile.videoFrameHeight, "recordingProfile", mProfile, "audioSource", MediaRecorder.AudioSource.CAMCORDER, - "learningDoneListener", mLearningDoneListener); + "learningDoneListener", mLearningDoneListener, + "recordingDoneListener", mRecordingDoneListener); mRunner = null; mGraphId = -1; @@ -542,6 +545,16 @@ public class EffectsRecorder { } }; + // A callback to finalize the media after the recording is done. + private OnRecordingDoneListener mRecordingDoneListener = + new OnRecordingDoneListener() { + // Forward the callback to the VideoCamera object (as an asynchronous event). + public void onRecordingDone() { + if (mLogVerbose) Log.v(TAG, "Recording done callback triggered"); + sendMessage(EFFECT_NONE, EFFECT_MSG_RECORDING_DONE); + } + }; + public synchronized void startRecording() { if (mLogVerbose) Log.v(TAG, "Starting recording (" + this + ")"); @@ -755,4 +768,5 @@ public class EffectsRecorder { }); } } + } diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 2566271..dcb784c 100755 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -1362,6 +1362,10 @@ public class VideoCamera extends ActivityBase } private void addVideoToMediaStore() { + if (mStorageSpace < LOW_STORAGE_THRESHOLD) { + Log.e(TAG, "Space insufficient to add media: " + mStorageSpace); + return; + } if (mVideoFileDescriptor == null) { Uri videoTable = Uri.parse("content://media/external/video/media"); mCurrentVideoValues.put(Video.Media.SIZE, @@ -1640,20 +1644,24 @@ public class VideoCamera extends ActivityBase private void stopVideoRecording() { Log.v(TAG, "stopVideoRecording"); if (mMediaRecorderRecording) { - boolean shouldAddToMediaStore = false; + boolean shouldAddToMediaStoreNow = false; try { if (effectsActive()) { + // This is asynchronous, so we cant 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. mEffectsRecorder.stopRecording(); } else { mMediaRecorder.setOnErrorListener(null); mMediaRecorder.setOnInfoListener(null); mMediaRecorder.stop(); + shouldAddToMediaStoreNow = true; } mCurrentVideoFilename = mVideoFilename; Log.v(TAG, "Setting current video filename: " + mCurrentVideoFilename); - shouldAddToMediaStore = true; } catch (RuntimeException e) { Log.e(TAG, "stop fail", e); if (mVideoFilename != null) deleteVideoFile(mVideoFilename); @@ -1665,7 +1673,7 @@ public class VideoCamera extends ActivityBase enableCameraControls(true); } keepScreenOnAwhile(); - if (shouldAddToMediaStore && mStorageSpace >= LOW_STORAGE_THRESHOLD) { + if (shouldAddToMediaStoreNow) { addVideoToMediaStore(); } } @@ -1930,6 +1938,9 @@ public class VideoCamera extends ActivityBase // and restart regular preview. mBgLearningMessageFrame.setVisibility(View.GONE); checkQualityAndStartPreview(); + } else if (effectMsg == EffectsRecorder.EFFECT_MSG_RECORDING_DONE) { + addVideoToMediaStore(); + getThumbnail(); } else if (effectId == EffectsRecorder.EFFECT_BACKDROPPER) { switch (effectMsg) { case EffectsRecorder.EFFECT_MSG_STARTED_LEARNING: |