summaryrefslogtreecommitdiffstats
path: root/media/java
diff options
context:
space:
mode:
Diffstat (limited to 'media/java')
-rw-r--r--media/java/android/media/CamcorderProfile.java18
-rw-r--r--media/java/android/media/CameraProfile.java16
-rw-r--r--media/java/android/media/MediaRecorder.java25
3 files changed, 54 insertions, 5 deletions
diff --git a/media/java/android/media/CamcorderProfile.java b/media/java/android/media/CamcorderProfile.java
index a27df57..4004c76 100644
--- a/media/java/android/media/CamcorderProfile.java
+++ b/media/java/android/media/CamcorderProfile.java
@@ -16,6 +16,9 @@
package android.media;
+import android.hardware.Camera;
+import android.hardware.Camera.CameraInfo;
+
/**
* The CamcorderProfile class is used to retrieve the
* predefined camcorder profile settings for camcorder applications.
@@ -119,12 +122,21 @@ public class CamcorderProfile
public int audioChannels;
/**
- * Returns the camcorder profile for the default camera at the given
- * quality level.
+ * Returns the camcorder profile for the first back-facing camera on the
+ * device at the given quality level. If the device has no back-facing
+ * camera, this returns null.
* @param quality the target quality level for the camcorder profile
*/
public static CamcorderProfile get(int quality) {
- return get(0, quality);
+ int numberOfCameras = Camera.getNumberOfCameras();
+ CameraInfo cameraInfo = new CameraInfo();
+ for (int i = 0; i < numberOfCameras; i++) {
+ Camera.getCameraInfo(i, cameraInfo);
+ if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
+ return get(i, quality);
+ }
+ }
+ return null;
}
/**
diff --git a/media/java/android/media/CameraProfile.java b/media/java/android/media/CameraProfile.java
index 6a0be08..905e2d2 100644
--- a/media/java/android/media/CameraProfile.java
+++ b/media/java/android/media/CameraProfile.java
@@ -16,6 +16,9 @@
package android.media;
+import android.hardware.Camera;
+import android.hardware.Camera.CameraInfo;
+
import java.util.Arrays;
import java.util.HashMap;
@@ -46,12 +49,21 @@ public class CameraProfile
/**
* Returns a pre-defined still image capture (jpeg) quality level
* used for the given quality level in the Camera application for
- * the default camera.
+ * the first back-facing camera on the device. If the device has no
+ * back-facing camera, this returns 0.
*
* @param quality The target quality level
*/
public static int getJpegEncodingQualityParameter(int quality) {
- return getJpegEncodingQualityParameter(0, quality);
+ int numberOfCameras = Camera.getNumberOfCameras();
+ CameraInfo cameraInfo = new CameraInfo();
+ for (int i = 0; i < numberOfCameras; i++) {
+ Camera.getCameraInfo(i, cameraInfo);
+ if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
+ return getJpegEncodingQualityParameter(i, quality);
+ }
+ }
+ return 0;
}
/**
diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java
index b38124e..ecabae8 100644
--- a/media/java/android/media/MediaRecorder.java
+++ b/media/java/android/media/MediaRecorder.java
@@ -285,6 +285,31 @@ public class MediaRecorder
}
/**
+ * Sets the orientation hint for output video playback.
+ * This method should be called before prepare(). This method will not
+ * trigger the source video frame to rotate during video recording, but to
+ * add a composition matrix containing the rotation angle in the output
+ * video if the output format is OutputFormat.THREE_GPP or
+ * OutputFormat.MPEG_4 so that a video player can choose the proper
+ * orientation for playback. Note that some video players may choose
+ * to ignore the compostion matrix in a video during playback.
+ *
+ * @param degrees the angle to be rotated clockwise in degrees.
+ * The supported angles are 0, 90, 180, and 270 degrees.
+ * @throws IllegalArgumentException if the angle is not supported.
+ *
+ */
+ public void setOrientationHint(int degrees) {
+ if (degrees != 0 &&
+ degrees != 90 &&
+ degrees != 180 &&
+ degrees != 270) {
+ throw new IllegalArgumentException("Unsupported angle: " + degrees);
+ }
+ setParameter(String.format("video-param-rotation-angle-degrees=%d", degrees));
+ }
+
+ /**
* Sets the format of the output file produced during recording. Call this
* after setAudioSource()/setVideoSource() but before prepare().
*