cts: get video size from CamcorderProfile -- DO NOT MERGE
bug: 23036810
bug: 23972679
Change-Id: I35524cc92f6e1ee7d1df2d62d044595438048ac7
(cherry picked from commit ad205439363c2d9b988628d5705913f428d09b89)
diff --git a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
index 216e21b..6cdbbac 100644
--- a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
@@ -20,6 +20,7 @@
import android.cts.util.MediaUtils;
import android.hardware.Camera;
import android.media.MediaFormat;
+import android.media.CamcorderProfile;
import android.media.MediaMetadataRetriever;
import android.media.MediaRecorder;
import android.media.MediaRecorder.OnErrorListener;
@@ -165,19 +166,17 @@
if (!hasCamera()) {
return;
}
- // Try to get camera first supported resolution.
- // If we fail for any reason, set the video size to default value.
- try {
- camera = Camera.open();
- width = camera.getParameters().getSupportedPreviewSizes().get(0).width;
- height = camera.getParameters().getSupportedPreviewSizes().get(0).height;
- } catch (Exception e) {
+ // Try to get camera profile for QUALITY_LOW; if unavailable,
+ // set the video size to default value.
+ CamcorderProfile profile = CamcorderProfile.get(
+ 0 /* cameraId */, CamcorderProfile.QUALITY_LOW);
+ if (profile != null) {
+ width = profile.videoFrameWidth;
+ height = profile.videoFrameHeight;
+ } else {
width = VIDEO_WIDTH;
height = VIDEO_HEIGHT;
}
- if (camera != null) {
- camera.release();
- }
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);