summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2011-10-12 19:13:22 -0700
committerPannag Sanketi <psanketi@google.com>2011-10-18 14:44:07 -0700
commitd979079aa0735beb302dd58797af0c6b600edfea (patch)
treec5865e17d35466a464cea6c92900c070c96803b0
parent267bccfc197cdb2eaa44a0a96c8138863d1cc0bc (diff)
downloadLegacyCamera-d979079aa0735beb302dd58797af0c6b600edfea.zip
LegacyCamera-d979079aa0735beb302dd58797af0c6b600edfea.tar.gz
LegacyCamera-d979079aa0735beb302dd58797af0c6b600edfea.tar.bz2
Add timelapse recording support to effects mode.
Bug: 5452088 Change-Id: I87c69e715ccdd6c48f18ecaa1fb4f362e2a9d567
-rw-r--r--res/raw/backdropper.graph5
-rw-r--r--res/raw/goofy_face.graph5
-rw-r--r--src/com/android/camera/EffectsRecorder.java44
-rwxr-xr-xsrc/com/android/camera/VideoCamera.java12
4 files changed, 56 insertions, 10 deletions
diff --git a/res/raw/backdropper.graph b/res/raw/backdropper.graph
index 3a48fc4..a903f12 100644
--- a/res/raw/backdropper.graph
+++ b/res/raw/backdropper.graph
@@ -30,7 +30,6 @@
@external recordingHeight;
@external recordingProfile;
@external recordingDoneListener;
-@external audioSource;
@external previewSurface;
@external previewWidth;
@@ -73,11 +72,11 @@
// Recording output
@filter MediaEncoderFilter recorder {
- audioSource = $audioSource;
recordingProfile = $recordingProfile;
recordingDoneListener = $recordingDoneListener;
recording = false;
- // outputFile, orientationHint, inputRegion, listeners
+ // outputFile, orientationHint, inputRegion,
+ // audioSource, listeners, captureRate
// will be set when recording starts
}
diff --git a/res/raw/goofy_face.graph b/res/raw/goofy_face.graph
index 7145033..fa2df43 100644
--- a/res/raw/goofy_face.graph
+++ b/res/raw/goofy_face.graph
@@ -32,7 +32,6 @@
@external recordingHeight;
@external recordingProfile;
@external recordingDoneListener;
-@external audioSource;
@external previewSurface;
@external previewWidth;
@@ -97,11 +96,11 @@
// Recording output
@filter MediaEncoderFilter recorder {
- audioSource = $audioSource;
recordingProfile = $recordingProfile;
recordingDoneListener = $recordingDoneListener;
recording = false;
- // outputFile, orientationHint, inputRegion, listeners
+ // outputFile, orientationHint, inputRegion,
+ // audioSource, listeners, captureRate
// will be set when recording starts
}
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) {