summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorPannag Sanketi <psanketi@google.com>2011-10-18 15:58:58 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-18 15:58:58 -0700
commit967d36c02eca4ae3af6dcd93ac9c7ffd6401aea5 (patch)
tree1a7dbb12f583bc8f56166170ac15a372af70e538 /src/com/android
parent66188959498860c8b43ab7b9119c7b5c890c83dc (diff)
parentd979079aa0735beb302dd58797af0c6b600edfea (diff)
downloadLegacyCamera-967d36c02eca4ae3af6dcd93ac9c7ffd6401aea5.zip
LegacyCamera-967d36c02eca4ae3af6dcd93ac9c7ffd6401aea5.tar.gz
LegacyCamera-967d36c02eca4ae3af6dcd93ac9c7ffd6401aea5.tar.bz2
Merge "Add timelapse recording support to effects mode." into ics-mr0
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/camera/EffectsRecorder.java44
-rwxr-xr-xsrc/com/android/camera/VideoCamera.java12
2 files changed, 52 insertions, 4 deletions
diff --git a/src/com/android/camera/EffectsRecorder.java b/src/com/android/camera/EffectsRecorder.java
index bd0aff5..8b63ceb 100644
--- a/src/com/android/camera/EffectsRecorder.java
+++ b/src/com/android/camera/EffectsRecorder.java
@@ -80,6 +80,7 @@ public class EffectsRecorder {
private Camera mCameraDevice;
private CamcorderProfile mProfile;
+ private double mCaptureRate = 0;
private SurfaceHolder mPreviewSurfaceHolder;
private int mPreviewWidth;
private int mPreviewHeight;
@@ -222,9 +223,31 @@ public class EffectsRecorder {
* disable the limit
*/
public synchronized void setMaxFileSize(long maxFileSize) {
+ switch (mState) {
+ case STATE_RECORD:
+ throw new RuntimeException("setMaxFileSize cannot be called while recording!");
+ case STATE_RELEASED:
+ throw new RuntimeException("setMaxFileSize called on an already released recorder!");
+ default:
+ break;
+ }
mMaxFileSize = maxFileSize;
}
+ public void setCaptureRate(double fps) {
+ switch (mState) {
+ case STATE_RECORD:
+ throw new RuntimeException("setCaptureRate cannot be called while recording!");
+ case STATE_RELEASED:
+ throw new RuntimeException("setCaptureRate called on an already released recorder!");
+ default:
+ break;
+ }
+
+ if (mLogVerbose) Log.v(TAG, "Setting time lapse capture rate to " + fps + " fps");
+ mCaptureRate = fps;
+ }
+
public void setPreviewDisplay(SurfaceHolder previewSurfaceHolder,
int previewWidth,
int previewHeight) {
@@ -382,10 +405,8 @@ public class EffectsRecorder {
"recordingWidth", mProfile.videoFrameWidth,
"recordingHeight", mProfile.videoFrameHeight,
"recordingProfile", mProfile,
- "audioSource", MediaRecorder.AudioSource.CAMCORDER,
"learningDoneListener", mLearningDoneListener,
"recordingDoneListener", mRecordingDoneListener);
-
mRunner = null;
mGraphId = -1;
mCurrentEffect = EFFECT_NONE;
@@ -592,17 +613,34 @@ public class EffectsRecorder {
} else {
recorder.setInputValue("outputFile", mOutputFile);
}
+ // It is ok to set the audiosource without checking for timelapse here
+ // since that check will be done in the MediaEncoderFilter itself
+ recorder.setInputValue("audioSource", MediaRecorder.AudioSource.CAMCORDER);
+ recorder.setInputValue("recordingProfile", mProfile);
recorder.setInputValue("orientationHint", mOrientationHint);
+ // Important to set the timelapseinterval to 0 if the capture rate is not >0
+ // since the recorder does not get created every time the recording starts.
+ // The recorder infers whether the capture is timelapsed based on the value of
+ // this interval
+ boolean captureTimeLapse = mCaptureRate > 0;
+ if (captureTimeLapse) {
+ double timeBetweenFrameCapture = 1 / mCaptureRate;
+ recorder.setInputValue("timelapseRecordingIntervalUs",
+ (long) (1000000 * timeBetweenFrameCapture));
+ } else {
+ recorder.setInputValue("timelapseRecordingIntervalUs", 0L);
+ }
+
if (mInfoListener != null) {
recorder.setInputValue("infoListener", mInfoListener);
}
if (mErrorListener != null) {
recorder.setInputValue("errorListener", mErrorListener);
}
+ recorder.setInputValue("maxFileSize", mMaxFileSize);
recorder.setInputValue("recording", true);
if (mRecordSound != null) mRecordSound.play();
- recorder.setInputValue("maxFileSize", mMaxFileSize);
mState = STATE_RECORD;
}
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index df8adb9..6a251d4 100755
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -1243,6 +1243,8 @@ public class VideoCamera extends ActivityBase
mEffectsRecorder = new EffectsRecorder(this);
+ // TODO: Confirm none of the foll need to go to initializeEffectsRecording()
+ // and none of these change even when the preview is not refreshed.
mEffectsRecorder.setCamera(mCameraDevice);
mEffectsRecorder.setCameraFacing(info.facing);
mEffectsRecorder.setProfile(mProfile);
@@ -1294,7 +1296,15 @@ public class VideoCamera extends ActivityBase
requestedSizeLimit = myExtras.getLong(MediaStore.EXTRA_SIZE_LIMIT);
}
- // TODO: Timelapse
+ mEffectsRecorder.setProfile(mProfile);
+ // important to set the capture rate to zero if not timelapsed, since the
+ // effectsrecorder object does not get created again for each recording
+ // session
+ if (mCaptureTimeLapse) {
+ mEffectsRecorder.setCaptureRate((1000 / (double) mTimeBetweenTimeLapseFrameCaptureMs));
+ } else {
+ mEffectsRecorder.setCaptureRate(0);
+ }
// Set output file
if (mVideoFileDescriptor != null) {