aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorYin-Chia Yeh <yinchiayeh@google.com>2018-02-08 16:16:32 -0800
committerYin-Chia Yeh <yinchiayeh@google.com>2018-02-08 16:16:32 -0800
commit554eeb528b67b38dc70e34b352f6834d59ae822d (patch)
tree2e5bbd8fdd04d68a94d99de68b88891e52adc817 /apps
parent7604d177fb82b59793be4af5b342feabb70d485d (diff)
downloadpdk-554eeb528b67b38dc70e34b352f6834d59ae822d.tar.gz
TestingCamera: support devices without camcorder profile
Bug: 72261912 Change-Id: I32fd989b74af627c2f647511dc21772ec7bc04a4
Diffstat (limited to 'apps')
-rw-r--r--apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java35
1 files changed, 33 insertions, 2 deletions
diff --git a/apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java b/apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java
index d743443..ec76c8f 100644
--- a/apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java
+++ b/apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java
@@ -1037,7 +1037,9 @@ public class TestingCamera extends Activity
updateColorEffects(mParams);
// Trigger updating video record size to match camcorder profile
- mCamcorderProfileSpinner.setSelection(mCamcorderProfile);
+ if (mCamcorderProfile >= 0) {
+ mCamcorderProfileSpinner.setSelection(mCamcorderProfile);
+ }
if (mParams.isVideoStabilizationSupported()) {
log("Video stabilization is supported");
@@ -1317,11 +1319,18 @@ public class TestingCamera extends Activity
mCamcorderProfiles.add(CamcorderProfile.get(cameraId, PROFILES[i]));
}
}
+
String[] nameArray = (String[])availableCamcorderProfileNames.toArray(new String[0]);
mCamcorderProfileSpinner.setAdapter(
new ArrayAdapter<String>(
this, R.layout.spinner_item, nameArray));
+ if (availableCamcorderProfileNames.size() == 0) {
+ log("Camera " + cameraId + " doesn't support camcorder profile");
+ mCamcorderProfile = -1;
+ return;
+ }
+
mCamcorderProfile = 0;
log("Setting camcorder profile to " + nameArray[mCamcorderProfile]);
@@ -1569,6 +1578,19 @@ public class TestingCamera extends Activity
}
}
+ private static final int BIT_RATE_1080P = 16000000;
+ private static final int BIT_RATE_MIN = 64000;
+ private static final int BIT_RATE_MAX = 40000000;
+
+ private int getVideoBitRate(Camera.Size sz) {
+ int rate = BIT_RATE_1080P;
+ float scaleFactor = sz.height * sz.width / (float)(1920 * 1080);
+ rate = (int)(rate * scaleFactor);
+
+ // Clamp to the MIN, MAX range.
+ return Math.max(BIT_RATE_MIN, Math.min(BIT_RATE_MAX, rate));
+ }
+
private void startRecording() {
log("Starting recording");
@@ -1608,8 +1630,17 @@ public class TestingCamera extends Activity
mRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
- mRecorder.setProfile(mCamcorderProfiles.get(mCamcorderProfile));
+
Camera.Size videoRecordSize = mVideoRecordSizes.get(mVideoRecordSize);
+ if (mCamcorderProfile >= 0) {
+ mRecorder.setProfile(mCamcorderProfiles.get(mCamcorderProfile));
+ } else {
+ mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
+ mRecorder.setVideoEncodingBitRate(getVideoBitRate(videoRecordSize));
+ mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
+ mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
+ }
+
if (videoRecordSize.width > 0 && videoRecordSize.height > 0) {
mRecorder.setVideoSize(videoRecordSize.width, videoRecordSize.height);
}