summaryrefslogtreecommitdiffstats
path: root/media/java
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2010-06-30 20:22:40 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-06-30 20:22:40 -0700
commitbda93c4cb94b47c86251d22df16e46a514c191ef (patch)
tree08ba3e6f84f7f037d7ab623cb36c0d880c74ad15 /media/java
parentd3233ae9027cd0459bdcb6f574ee1ffe02736109 (diff)
parent09b9005769f2b717f637131578ce6cfa6bd62bd9 (diff)
downloadframeworks_base-bda93c4cb94b47c86251d22df16e46a514c191ef.zip
frameworks_base-bda93c4cb94b47c86251d22df16e46a514c191ef.tar.gz
frameworks_base-bda93c4cb94b47c86251d22df16e46a514c191ef.tar.bz2
am 09b90057: Add multiple camera support for in MediaProfiles.
Merge commit '09b9005769f2b717f637131578ce6cfa6bd62bd9' into gingerbread-plus-aosp * commit '09b9005769f2b717f637131578ce6cfa6bd62bd9': Add multiple camera support for in MediaProfiles.
Diffstat (limited to 'media/java')
-rw-r--r--media/java/android/media/CamcorderProfile.java18
-rw-r--r--media/java/android/media/CameraProfile.java38
2 files changed, 44 insertions, 12 deletions
diff --git a/media/java/android/media/CamcorderProfile.java b/media/java/android/media/CamcorderProfile.java
index 64d6460..a27df57 100644
--- a/media/java/android/media/CamcorderProfile.java
+++ b/media/java/android/media/CamcorderProfile.java
@@ -119,15 +119,26 @@ public class CamcorderProfile
public int audioChannels;
/**
- * Returns the camcorder profile for the given quality level.
+ * Returns the camcorder profile for the default camera at the given
+ * quality level.
* @param quality the target quality level for the camcorder profile
*/
public static CamcorderProfile get(int quality) {
+ return get(0, quality);
+ }
+
+ /**
+ * Returns the camcorder profile for the given camera at the given
+ * quality level.
+ * @param cameraId the id for the camera
+ * @param quality the target quality level for the camcorder profile
+ */
+ public static CamcorderProfile get(int cameraId, int quality) {
if (quality < QUALITY_LOW || quality > QUALITY_HIGH) {
String errMessage = "Unsupported quality level: " + quality;
throw new IllegalArgumentException(errMessage);
}
- return native_get_camcorder_profile(quality);
+ return native_get_camcorder_profile(cameraId, quality);
}
static {
@@ -165,5 +176,6 @@ public class CamcorderProfile
// Methods implemented by JNI
private static native final void native_init();
- private static native final CamcorderProfile native_get_camcorder_profile(int quality);
+ private static native final CamcorderProfile native_get_camcorder_profile(
+ int cameraId, int quality);
}
diff --git a/media/java/android/media/CameraProfile.java b/media/java/android/media/CameraProfile.java
index f8d3935..6a0be08 100644
--- a/media/java/android/media/CameraProfile.java
+++ b/media/java/android/media/CameraProfile.java
@@ -17,6 +17,7 @@
package android.media;
import java.util.Arrays;
+import java.util.HashMap;
/**
* The CameraProfile class is used to retrieve the pre-defined still image
@@ -40,36 +41,55 @@ public class CameraProfile
/*
* Cache the Jpeg encoding quality parameters
*/
- private static final int[] sJpegEncodingQualityParameters;
+ private static final HashMap<Integer, int[]> sCache = new HashMap<Integer, int[]>();
/**
* Returns a pre-defined still image capture (jpeg) quality level
- * used for the given quality level in the Camera application.
+ * used for the given quality level in the Camera application for
+ * the default camera.
*
* @param quality The target quality level
*/
public static int getJpegEncodingQualityParameter(int quality) {
+ return getJpegEncodingQualityParameter(0, quality);
+ }
+
+ /**
+ * Returns a pre-defined still image capture (jpeg) quality level
+ * used for the given quality level in the Camera application for
+ * the specified camera.
+ *
+ * @param cameraId The id of the camera
+ * @param quality The target quality level
+ */
+ public static int getJpegEncodingQualityParameter(int cameraId, int quality) {
if (quality < QUALITY_LOW || quality > QUALITY_HIGH) {
throw new IllegalArgumentException("Unsupported quality level: " + quality);
}
- return sJpegEncodingQualityParameters[quality];
+ synchronized (sCache) {
+ int[] levels = sCache.get(cameraId);
+ if (levels == null) {
+ levels = getImageEncodingQualityLevels(cameraId);
+ sCache.put(cameraId, levels);
+ }
+ return levels[quality];
+ }
}
static {
System.loadLibrary("media_jni");
native_init();
- sJpegEncodingQualityParameters = getImageEncodingQualityLevels();
}
- private static int[] getImageEncodingQualityLevels() {
- int nLevels = native_get_num_image_encoding_quality_levels();
+ private static int[] getImageEncodingQualityLevels(int cameraId) {
+ int nLevels = native_get_num_image_encoding_quality_levels(cameraId);
if (nLevels != QUALITY_HIGH + 1) {
throw new RuntimeException("Unexpected Jpeg encoding quality levels " + nLevels);
}
int[] levels = new int[nLevels];
for (int i = 0; i < nLevels; ++i) {
- levels[i] = native_get_image_encoding_quality_level(i);
+ levels[i] = native_get_image_encoding_quality_level(cameraId, i);
}
Arrays.sort(levels); // Lower quality level ALWAYS comes before higher one
return levels;
@@ -77,6 +97,6 @@ public class CameraProfile
// Methods implemented by JNI
private static native final void native_init();
- private static native final int native_get_num_image_encoding_quality_levels();
- private static native final int native_get_image_encoding_quality_level(int index);
+ private static native final int native_get_num_image_encoding_quality_levels(int cameraId);
+ private static native final int native_get_image_encoding_quality_level(int cameraId, int index);
}