From 3f7e00441f65ebd463a68d4c687589a65980ac5b Mon Sep 17 00:00:00 2001 From: Doris Liu Date: Wed, 31 Jul 2013 11:25:09 -0700 Subject: Set default video quality to the highest Bug: 9886141 Change-Id: I4741d5c898ac666923cfc12abc78d5d3517cb05f --- src/com/android/camera/CameraSettings.java | 48 ++++++++++-------------------- src/com/android/camera/VideoModule.java | 29 +++++++----------- 2 files changed, 26 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index 4e9a5ddfe..3558014cc 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -93,16 +93,16 @@ public class CameraSettings { return group; } - @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) - public static String getDefaultVideoQuality(int cameraId, + public static String getSupportedHighestVideoQuality(int cameraId, String defaultQuality) { - if (ApiHelper.HAS_FINE_RESOLUTION_QUALITY_LEVELS) { - if (CamcorderProfile.hasProfile( - cameraId, Integer.valueOf(defaultQuality))) { - return defaultQuality; - } - } - return Integer.toString(CamcorderProfile.QUALITY_HIGH); + // When launching the camera app first time, we will set the video quality + // to the first one (i.e. highest quality) in the supported list + List supported = getSupportedVideoQuality(cameraId); + if (supported == null) { + Log.e(TAG, "No supported video quality is found"); + return defaultQuality; + } + return supported.get(0); } public static void initialCameraPictureSize( @@ -177,7 +177,7 @@ public class CameraSettings { // Since the screen could be loaded from different resources, we need // to check if the preference is available here if (videoQuality != null) { - filterUnsupportedOptions(group, videoQuality, getSupportedVideoQuality()); + filterUnsupportedOptions(group, videoQuality, getSupportedVideoQuality(mCameraId)); } if (pictureSize != null) { @@ -532,37 +532,19 @@ public class CameraSettings { writePreferredCameraId(preferences, currentCameraId); } - private ArrayList getSupportedVideoQuality() { + private static ArrayList getSupportedVideoQuality(int cameraId) { ArrayList supported = new ArrayList(); // Check for supported quality - if (ApiHelper.HAS_FINE_RESOLUTION_QUALITY_LEVELS) { - getFineResolutionQuality(supported); - } else { - supported.add(Integer.toString(CamcorderProfile.QUALITY_HIGH)); - CamcorderProfile high = CamcorderProfile.get( - mCameraId, CamcorderProfile.QUALITY_HIGH); - CamcorderProfile low = CamcorderProfile.get( - mCameraId, CamcorderProfile.QUALITY_LOW); - if (high.videoFrameHeight * high.videoFrameWidth > - low.videoFrameHeight * low.videoFrameWidth) { - supported.add(Integer.toString(CamcorderProfile.QUALITY_LOW)); - } - } - - return supported; - } - - @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) - private void getFineResolutionQuality(ArrayList supported) { - if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_1080P)) { + if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_1080P)) { supported.add(Integer.toString(CamcorderProfile.QUALITY_1080P)); } - if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_720P)) { + if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_720P)) { supported.add(Integer.toString(CamcorderProfile.QUALITY_720P)); } - if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_480P)) { + if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_480P)) { supported.add(Integer.toString(CamcorderProfile.QUALITY_480P)); } + return supported; } private void initVideoEffect(PreferenceGroup group, ListPreference videoEffect) { diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index e3efa22b6..956890e5e 100644 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -472,20 +472,10 @@ public class VideoModule implements CameraModule, if (effectsActive()) { mUI.overrideSettings( CameraSettings.KEY_VIDEO_QUALITY, - Integer.toString(getLowVideoQuality())); + Integer.toString(CamcorderProfile.QUALITY_480P)); } } - @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) - private static int getLowVideoQuality() { - if (ApiHelper.HAS_FINE_RESOLUTION_QUALITY_LEVELS) { - return CamcorderProfile.QUALITY_480P; - } else { - return CamcorderProfile.QUALITY_LOW; - } - } - - @Override public void onOrientationChanged(int orientation) { // We keep the last known orientation. So if the user first orient @@ -565,7 +555,7 @@ public class VideoModule implements CameraModule, // back to use SurfaceTexture for preview and we need to stop then start // the preview. This will cause the preview flicker since the preview // will not be continuous for a short period of time. - // TODO: need to get the capture animation to work + // TODO: need to get the capture animation to work // ((CameraScreenNail) mActivity.mCameraScreenNail).animateCapture(mDisplayRotation); mUI.enablePreviewThumb(true); @@ -613,11 +603,14 @@ public class VideoModule implements CameraModule, private void readVideoPreferences() { // The preference stores values from ListPreference and is thus string type for all values. // We need to convert it to int manually. - String defaultQuality = CameraSettings.getDefaultVideoQuality(mCameraId, - mActivity.getResources().getString(R.string.pref_video_quality_default)); - String videoQuality = - mPreferences.getString(CameraSettings.KEY_VIDEO_QUALITY, - defaultQuality); + String videoQuality = mPreferences.getString(CameraSettings.KEY_VIDEO_QUALITY, + null); + if (videoQuality == null) { + // check for highest quality before setting default value + videoQuality = CameraSettings.getSupportedHighestVideoQuality(mCameraId, + mActivity.getResources().getString(R.string.pref_video_quality_default)); + mPreferences.edit().putString(CameraSettings.KEY_VIDEO_QUALITY, videoQuality); + } int quality = Integer.valueOf(videoQuality); // Set video quality. @@ -649,7 +642,7 @@ public class VideoModule implements CameraModule, // Set quality to be no higher than 480p. CamcorderProfile profile = CamcorderProfile.get(mCameraId, quality); if (profile.videoFrameHeight > 480) { - quality = getLowVideoQuality(); + quality = CamcorderProfile.QUALITY_480P; } } else { mEffectParameter = null; -- cgit v1.2.3