aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-03-14 00:01:33 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-03-14 00:01:33 +0000
commitd69a0398814f68bc0dc2792d1555238cf5228473 (patch)
treee3f8ac0b4d346b0623f34cfd9898e784fb099a55 /apps
parenta2724412e11396864fbccccc469041af3972332e (diff)
parent554eeb528b67b38dc70e34b352f6834d59ae822d (diff)
downloadpdk-d69a0398814f68bc0dc2792d1555238cf5228473.tar.gz
Merge "TestingCamera: support devices without camcorder profile"
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);
}