diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-08 03:56:12 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-08 03:56:12 -0700 |
commit | 2616d29c4c28cea59e7ec7ce63e8b2760e8cae21 (patch) | |
tree | 82b7679cb114fc00e224c8e3febf6e7bc7da379b | |
parent | cb4b88e7d62dec7c38953278d8d2facafd89a14c (diff) | |
parent | b6ed73e152c385c10ea20c605fa231e04de38ccc (diff) | |
download | LegacyCamera-2616d29c4c28cea59e7ec7ce63e8b2760e8cae21.zip LegacyCamera-2616d29c4c28cea59e7ec7ce63e8b2760e8cae21.tar.gz LegacyCamera-2616d29c4c28cea59e7ec7ce63e8b2760e8cae21.tar.bz2 |
Merge change 6455 into donut
* changes:
Read max file size from video capture intent.
-rw-r--r-- | res/values/strings.xml | 3 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 39 |
2 files changed, 30 insertions, 12 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index cd76778..7d7761b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -572,4 +572,7 @@ <!-- The messsage shown on progress dialog when deleting images --> <string name="delete_images_message">Deleting images, please wait\u2026</string> + <!-- The messsage shown when video record reaches size limit. --> + <string name="video_reach_size_limit">Size limit reached.</string> + </resources> diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index bdea9c3..ed240e6 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -133,7 +133,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, // The video frame size we will record (like 352x288). private int mVideoWidth, mVideoHeight; - // The video duration limit. + // The video duration limit. 0 menas no limit. private int mMaxVideoDurationInMs; boolean mPausing = false; @@ -439,11 +439,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, getBooleanPreference(CameraSettings.KEY_VIDEO_QUALITY, CameraSettings.DEFAULT_VIDEO_QUALITY_VALUE); - // 1 minute = 60000ms - mMaxVideoDurationInMs = - 60000 * getIntPreference(CameraSettings.KEY_VIDEO_DURATION, - CameraSettings.DEFAULT_VIDEO_DURATION_VALUE); - + // Set video quality. Intent intent = getIntent(); if (intent.hasExtra(MediaStore.EXTRA_VIDEO_QUALITY)) { int extraVideoQuality = @@ -451,6 +447,17 @@ public class VideoCamera extends Activity implements View.OnClickListener, videoQualityHigh = (extraVideoQuality > 0); } + // Set video duration limit. + if (intent.hasExtra(MediaStore.EXTRA_SIZE_LIMIT)) { + // No duration limit if file size limit is requested. + mMaxVideoDurationInMs = 0; + } else { + // 1 minute = 60000ms + mMaxVideoDurationInMs = + 60000 * getIntPreference(CameraSettings.KEY_VIDEO_DURATION, + CameraSettings.DEFAULT_VIDEO_DURATION_VALUE); + } + if (videoQualityHigh) { // CIF size mVideoWidth = 352; @@ -786,6 +793,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, 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) { @@ -799,6 +807,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, Log.e(TAG, ex.toString()); } } + requestedSizeLimit = myExtras.getLong(MediaStore.EXTRA_SIZE_LIMIT); } releaseMediaRecorder(); @@ -833,13 +842,17 @@ public class VideoCamera extends Activity implements View.OnClickListener, mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface()); - long remaining = getAvailableStorage(); + // Set maximum file size. // remaining >= LOW_STORAGE_THRESHOLD at this point, reserve a quarter // of that to make it more likely that recording can complete // successfully. + long maxFileSize = getAvailableStorage() - LOW_STORAGE_THRESHOLD / 4; + if (requestedSizeLimit > 0 && requestedSizeLimit < maxFileSize) { + maxFileSize = requestedSizeLimit; + } + try { - mMediaRecorder.setMaxFileSize( - remaining - LOW_STORAGE_THRESHOLD / 4); + mMediaRecorder.setMaxFileSize(maxFileSize); } catch (RuntimeException exception) { // We are going to ignore failure of setMaxFileSize here, as // a) The composer selected may simply not support it, or @@ -1016,7 +1029,9 @@ public class VideoCamera extends Activity implements View.OnClickListener, } else if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED) { mShutterButton.performClick(); - updateAndShowStorageHint(true); + // Show the toast. + Toast.makeText(VideoCamera.this, R.string.video_reach_size_limit, + Toast.LENGTH_LONG).show(); } } @@ -1254,8 +1269,8 @@ public class VideoCamera extends Activity implements View.OnClickListener, // Starting a minute before reaching the max duration // limit, we'll countdown the remaining time instead. - boolean countdownRemainingTime = - (delta >= mMaxVideoDurationInMs - 60000); + boolean countdownRemainingTime = (mMaxVideoDurationInMs != 0 + && delta >= mMaxVideoDurationInMs - 60000); if (countdownRemainingTime) { delta = Math.max(0, mMaxVideoDurationInMs - delta); |