summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bestas <mikeioannina@gmail.com>2015-09-11 00:52:56 +0300
committerMichael Bestas <mikeioannina@gmail.com>2015-09-17 23:26:03 +0300
commit35a38acb7943b018c5d239d00c4ad48da5072b87 (patch)
tree4abe60876a717d5e0e1d412d2897620c4c2306c7
parent3bef2d9db59db7ff9d19cb6aa5e4bc3cd9381471 (diff)
downloadandroid_packages_apps_Snap-35a38acb7943b018c5d239d00c4ad48da5072b87.zip
android_packages_apps_Snap-35a38acb7943b018c5d239d00c4ad48da5072b87.tar.gz
android_packages_apps_Snap-35a38acb7943b018c5d239d00c4ad48da5072b87.tar.bz2
Snap: Cleanup video profile handling
* Fix camcorder crashes on older devices Revert "SnapdragonCamera: Fix compatibility issues with KK." This reverts commit 0d33346534a728a1f8efaec05fcdccbe3e5440e1. Revert "SnapdragonCamera: Throw error popup for unsupported video profile." This reverts commit 3e50703cff0bc243b922a2299c58a45a4cbd91a9. Change-Id: I1152180a590650a7583430936f3759d1831e91dd
-rw-r--r--res/values/arrays.xml42
-rw-r--r--res/values/qcomstrings.xml3
-rw-r--r--src/com/android/camera/AndroidCameraManagerImpl.java9
-rw-r--r--src/com/android/camera/CameraSettings.java43
-rw-r--r--src/com/android/camera/VideoModule.java28
5 files changed, 52 insertions, 73 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 706d7a4..1d5ef06 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -31,21 +31,35 @@
<item>@string/pref_video_quality_entry_cif</item>
<item>@string/pref_video_quality_entry_qvga</item>
<item>@string/pref_video_quality_entry_qcif</item>
- </string-array>
+ </string-array>
+
<string-array name="pref_video_quality_entryvalues" translatable="false">
- <item>4096x2160</item>
- <item>3840x2160</item>
- <item>1920x1080</item>
- <item>1280x720</item>
- <item>720x480</item>
- <item>864x480</item>
- <item>800x480</item>
- <item>640x480</item>
- <item>480x360</item>
- <item>400x240</item>
- <item>352x288</item>
- <item>320x240</item>
- <item>176x144</item>
+ <!-- The integer value of CamcorderProfile.QUALITY_4kDCI -->
+ <item>13</item>
+ <!-- The integer value of CamcorderProfile.QUALITY_2160P -->
+ <item>8</item>
+ <!-- The integer value of CamcorderProfile.QUALITY_1080P -->
+ <item>6</item>
+ <!-- The integer value of CamcorderProfile.QUALITY_720P -->
+ <item>5</item>
+ <!-- The integer value of CamcorderProfile.QUALITY_480P -->
+ <item>4</item>
+ <!-- The integer value of CamcorderProfile.QUALITY_FWVGA -->
+ <item>12</item>
+ <!-- The integer value of CamcorderProfile.QUALITY_WVGA -->
+ <item>9</item>
+ <!-- The integer value of CamcorderProfile.QUALITY_VGA -->
+ <item>10</item>
+ <!-- The integer value of CamcorderProfile.QUALITY_HVGA -->
+ <item>19</item>
+ <!-- The integer value of CamcorderProfile.QUALITY_WQVGA -->
+ <item>11</item>
+ <!-- The integer value of CamcorderProfile.QUALITY_CIF -->
+ <item>3</item>
+ <!-- The integer value of CamcorderProfile.QUALITY_QVGA -->
+ <item>7</item>
+ <!-- The integer value of CamcorderProfile.QUALITY_QCIF -->
+ <item>2</item>
</string-array>
<!-- Camera Preference save path entries -->
diff --git a/res/values/qcomstrings.xml b/res/values/qcomstrings.xml
index 135ab48..0779868 100644
--- a/res/values/qcomstrings.xml
+++ b/res/values/qcomstrings.xml
@@ -319,9 +319,6 @@
<!-- The message is shown in dialog when the app encounters an unsupported video resolution-->
<string name="error_app_unsupported">Unsupported video resolution for this encoder type</string>
- <!-- The message is shown in dialog when the app encounters an unsupported video profile-->
- <string name="error_app_unsupported_profile">Unsupported video profile</string>
-
<!--The message is shown in dialog when the raw snapshot is selected in zsl mode-->
<string name="error_app_unsupported_raw">Raw picture format is not supported
in zsl mode, change to JPEG
diff --git a/src/com/android/camera/AndroidCameraManagerImpl.java b/src/com/android/camera/AndroidCameraManagerImpl.java
index 621be06..a03631a 100644
--- a/src/com/android/camera/AndroidCameraManagerImpl.java
+++ b/src/com/android/camera/AndroidCameraManagerImpl.java
@@ -202,7 +202,14 @@ class AndroidCameraManagerImpl implements CameraManager {
try {
switch (msg.what) {
case OPEN_CAMERA:
- mCamera = android.hardware.Camera.open(msg.arg1);
+ try {
+ mCamera = android.hardware.Camera.openLegacy(msg.arg1,
+ android.hardware.Camera.CAMERA_HAL_API_VERSION_1_0);
+ } catch (RuntimeException e) {
+ /* Retry with open if openLegacy fails */
+ Log.v(TAG, "openLegacy failed. Using open instead");
+ mCamera = android.hardware.Camera.open(msg.arg1);
+ }
if (mCamera != null) {
mParametersIsDirty = true;
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 3eab068..7761fa1 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -253,31 +253,13 @@ public class CameraSettings {
private final int mCameraId;
private static final HashMap<Integer, String>
VIDEO_ENCODER_TABLE = new HashMap<Integer, String>();
- public static final HashMap<String, Integer>
- VIDEO_QUALITY_TABLE = new HashMap<String, Integer>();
static {
- //video encoders
VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.H263, "h263");
VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.H264, "h264");
VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.H265, "h265");
VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.MPEG_4_SP, "m4v");
-
- //video qualities
- VIDEO_QUALITY_TABLE.put("4096x2160", CamcorderProfile.QUALITY_4kDCI);
- VIDEO_QUALITY_TABLE.put("3840x2160", CamcorderProfile.QUALITY_2160P);
- VIDEO_QUALITY_TABLE.put("1920x1080", CamcorderProfile.QUALITY_1080P);
- VIDEO_QUALITY_TABLE.put("1280x720", CamcorderProfile.QUALITY_720P);
- VIDEO_QUALITY_TABLE.put("720x480", CamcorderProfile.QUALITY_480P);
- VIDEO_QUALITY_TABLE.put("864x480", CamcorderProfile.QUALITY_FWVGA);
- VIDEO_QUALITY_TABLE.put("800x480", CamcorderProfile.QUALITY_WVGA);
- VIDEO_QUALITY_TABLE.put("640x480", CamcorderProfile.QUALITY_VGA);
- VIDEO_QUALITY_TABLE.put("480x360", CamcorderProfile.QUALITY_HVGA);
- VIDEO_QUALITY_TABLE.put("400x240", CamcorderProfile.QUALITY_WQVGA);
- VIDEO_QUALITY_TABLE.put("352x288", CamcorderProfile.QUALITY_CIF);
- VIDEO_QUALITY_TABLE.put("320x240", CamcorderProfile.QUALITY_QVGA);
- VIDEO_QUALITY_TABLE.put("176x144", CamcorderProfile.QUALITY_QCIF);
- }
+ }
public CameraSettings(Activity activity, Parameters parameters,
int cameraId, CameraInfo[] cameraInfo) {
@@ -299,7 +281,7 @@ public class CameraSettings {
int cameraId, Parameters parameters) {
// 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<String> supported = getSupportedVideoQualities(cameraId,parameters);
+ List<String> supported = getSupportedVideoQuality(cameraId,parameters);
assert (supported != null) : "No supported video quality is found";
return supported.get(0);
}
@@ -779,7 +761,7 @@ public class CameraSettings {
}
if (videoQuality != null) {
- filterUnsupportedOptions(group, videoQuality, getSupportedVideoQualities(
+ filterUnsupportedOptions(group, videoQuality, getSupportedVideoQuality(
mCameraId,mParameters));
}
@@ -1234,6 +1216,11 @@ public class CameraSettings {
supported.add(Integer.toString(CamcorderProfile.QUALITY_VGA));
}
}
+ if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_HVGA)) {
+ if (checkSupportedVideoQuality(parameters,480,360)){
+ supported.add(Integer.toString(CamcorderProfile.QUALITY_HVGA));
+ }
+ }
if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_CIF)) {
if (checkSupportedVideoQuality(parameters,352,288)){
supported.add(Integer.toString(CamcorderProfile.QUALITY_CIF));
@@ -1251,20 +1238,6 @@ public class CameraSettings {
}
}
- public static ArrayList<String> getSupportedVideoQualities(int cameraId,Parameters parameters) {
- ArrayList<String> supported = new ArrayList<String>();
- List<String> temp = sizeListToStringList(parameters.getSupportedVideoSizes());
- for (String videoSize : temp) {
- if (VIDEO_QUALITY_TABLE.containsKey(videoSize)) {
- int profile = VIDEO_QUALITY_TABLE.get(videoSize);
- if (CamcorderProfile.hasProfile(cameraId, profile)) {
- supported.add(videoSize);
- }
- }
- }
- return supported;
- }
-
public static boolean isInternalPreviewSupported(Parameters params) {
boolean ret = false;
if (null != params) {
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index fadd3ee..54aa866 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -318,7 +318,6 @@ public class VideoModule implements CameraModule,
private boolean mUnsupportedHSRVideoSize = false;
private boolean mUnsupportedHFRVideoCodec = false;
private String mDefaultAntibanding = null;
- boolean mUnsupportedProfile = false;
// This Handler is used to post message back onto the main thread of the
// application
@@ -772,16 +771,18 @@ public class VideoModule implements CameraModule,
mParameters = mCameraDevice.getParameters();
String defaultQuality = mActivity.getResources().getString(
R.string.pref_video_quality_default);
- if (!defaultQuality.equals("")){
- videoQuality = defaultQuality;
+ if (!defaultQuality.equals("")) {
+ if (CamcorderProfile.hasProfile(Integer.parseInt(defaultQuality))) {
+ videoQuality = defaultQuality;
+ }
} else {
- // check for highest quality supported
- videoQuality = CameraSettings.getSupportedHighestVideoQuality(
- mCameraId, mParameters);
+ // check for highest quality supported
+ videoQuality = CameraSettings.getSupportedHighestVideoQuality(
+ mCameraId, mParameters);
}
mPreferences.edit().putString(CameraSettings.KEY_VIDEO_QUALITY, videoQuality).apply();
}
- int quality = CameraSettings.VIDEO_QUALITY_TABLE.get(videoQuality);
+ int quality = Integer.valueOf(videoQuality);
// Set video quality.
Intent intent = mActivity.getIntent();
@@ -803,12 +804,6 @@ public class VideoModule implements CameraModule,
mCaptureTimeLapse = (mTimeBetweenTimeLapseFrameCaptureMs != 0);
// TODO: This should be checked instead directly +1000.
if (mCaptureTimeLapse) quality += 1000;
- mUnsupportedProfile = false;
- boolean hasProfile = CamcorderProfile.hasProfile(mCameraId, quality);
- if (!hasProfile) {
- mUnsupportedProfile = true;
- return;
- }
mProfile = CamcorderProfile.get(mCameraId, quality);
getDesiredPreviewSize();
qcomReadVideoPreferences();
@@ -1678,13 +1673,6 @@ public class VideoModule implements CameraModule,
mStartRecPending = false;
return;
}
- if (mUnsupportedProfile == true) {
- Log.e(TAG, "Unsupported video profile");
- RotateTextToast.makeText(mActivity, R.string.error_app_unsupported_profile,
- Toast.LENGTH_SHORT).show();
- mStartRecPending = false;
- return;
- }
//??
//if (!mCameraDevice.waitDone()) return;
mCurrentVideoUri = null;