summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/camera/EffectsRecorder.java12
-rwxr-xr-xsrc/com/android/camera/VideoCamera.java10
-rwxr-xr-xtests/src/com/android/camera/stress/SwitchPreview.java3
3 files changed, 24 insertions, 1 deletions
diff --git a/src/com/android/camera/EffectsRecorder.java b/src/com/android/camera/EffectsRecorder.java
index 5e8bfc1..bd0aff5 100644
--- a/src/com/android/camera/EffectsRecorder.java
+++ b/src/com/android/camera/EffectsRecorder.java
@@ -89,6 +89,7 @@ public class EffectsRecorder {
private String mOutputFile;
private FileDescriptor mFd;
private int mOrientationHint = 0;
+ private long mMaxFileSize = 0;
private int mCameraFacing = Camera.CameraInfo.CAMERA_FACING_BACK;
private int mEffect = EFFECT_NONE;
@@ -214,6 +215,16 @@ public class EffectsRecorder {
mFd = fd;
}
+ /**
+ * Sets the maximum filesize (in bytes) of the recording session.
+ * This will be passed on to the MediaEncoderFilter and then to the
+ * MediaRecorder ultimately. If zero or negative, the MediaRecorder will
+ * disable the limit
+ */
+ public synchronized void setMaxFileSize(long maxFileSize) {
+ mMaxFileSize = maxFileSize;
+ }
+
public void setPreviewDisplay(SurfaceHolder previewSurfaceHolder,
int previewWidth,
int previewHeight) {
@@ -591,6 +602,7 @@ public class EffectsRecorder {
}
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 1249ce9..e8d8456 100755
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -71,7 +71,6 @@ import android.widget.Toast;
import java.io.File;
import java.io.IOException;
-import java.io.FileDescriptor;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
@@ -1278,6 +1277,7 @@ public class VideoCamera extends ActivityBase
Intent intent = getIntent();
Bundle myExtras = intent.getExtras();
+ long requestedSizeLimit = 0;
if (mIsVideoCaptureIntent && myExtras != null) {
Uri saveUri = (Uri) myExtras.getParcelable(MediaStore.EXTRA_OUTPUT);
if (saveUri != null) {
@@ -1290,6 +1290,7 @@ public class VideoCamera extends ActivityBase
Log.e(TAG, ex.toString());
}
}
+ requestedSizeLimit = myExtras.getLong(MediaStore.EXTRA_SIZE_LIMIT);
}
// TODO: Timelapse
@@ -1301,6 +1302,13 @@ public class VideoCamera extends ActivityBase
generateVideoFilename(mProfile.fileFormat);
mEffectsRecorder.setOutputFile(mVideoFilename);
}
+
+ // Set maximum file size.
+ long maxFileSize = mStorageSpace - Storage.LOW_STORAGE_THRESHOLD;
+ if (requestedSizeLimit > 0 && requestedSizeLimit < maxFileSize) {
+ maxFileSize = requestedSizeLimit;
+ }
+ mEffectsRecorder.setMaxFileSize(maxFileSize);
}
diff --git a/tests/src/com/android/camera/stress/SwitchPreview.java b/tests/src/com/android/camera/stress/SwitchPreview.java
index 6af915e..c5dd7c1 100755
--- a/tests/src/com/android/camera/stress/SwitchPreview.java
+++ b/tests/src/com/android/camera/stress/SwitchPreview.java
@@ -97,10 +97,13 @@ public class SwitchPreview extends ActivityInstrumentationTestCase2 <VideoCamera
for (int i=0; i< TOTAL_NUMBER_OF_SWITCHING; i++) {
Thread.sleep(WAIT_FOR_PREVIEW);
Intent intent = new Intent();
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setClass(getInstrumentation().getTargetContext(),
VideoCamera.class);
getActivity().startActivity(intent);
Thread.sleep(WAIT_FOR_PREVIEW);
+ intent = new Intent();
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setClass(getInstrumentation().getTargetContext(),
Camera.class);
getActivity().startActivity(intent);