diff options
author | Chih-Chung Chang <chihchung@google.com> | 2010-06-22 20:50:55 +0800 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2010-07-01 10:57:15 +0800 |
commit | 09b9005769f2b717f637131578ce6cfa6bd62bd9 (patch) | |
tree | 9f079a79030d894e6c81f919799a379e4fda3a9f /media/java | |
parent | 160edb3645f8b7012bab70ae6e6e8c4a5733082b (diff) | |
download | frameworks_base-09b9005769f2b717f637131578ce6cfa6bd62bd9.zip frameworks_base-09b9005769f2b717f637131578ce6cfa6bd62bd9.tar.gz frameworks_base-09b9005769f2b717f637131578ce6cfa6bd62bd9.tar.bz2 |
Add multiple camera support for in MediaProfiles.
Change-Id: Ie89568a0f5f5fd08ede77e33f9a559215d6bed9a
Diffstat (limited to 'media/java')
-rw-r--r-- | media/java/android/media/CamcorderProfile.java | 18 | ||||
-rw-r--r-- | media/java/android/media/CameraProfile.java | 38 |
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); } |