diff options
author | Alex Ray <aray@google.com> | 2012-09-05 13:18:05 -0700 |
---|---|---|
committer | Alex Ray <aray@google.com> | 2012-10-29 22:50:52 -0700 |
commit | 8bf3e54287366cf790c25577568334b92f67d178 (patch) | |
tree | 34bf899eff2e55038c7fe6bbc8eeaf0b1834daa3 /apps/TestingCamera | |
parent | b18600b1d8df55637a97679f13c26439c35b9efd (diff) | |
download | pdk-8bf3e54287366cf790c25577568334b92f67d178.tar.gz |
TestingCamera: Add video recording resolutions
Select camcorder profile and resolution to record at; enables testing
various video recording resolutions that do not have explicit profiles.
Change-Id: I03666f8f0348cc6993a54f0bbcbd9647a5734a40
Diffstat (limited to 'apps/TestingCamera')
-rw-r--r-- | apps/TestingCamera/res/layout/main.xml | 14 | ||||
-rw-r--r-- | apps/TestingCamera/res/values/strings.xml | 1 | ||||
-rw-r--r-- | apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java | 66 |
3 files changed, 81 insertions, 0 deletions
diff --git a/apps/TestingCamera/res/layout/main.xml b/apps/TestingCamera/res/layout/main.xml index b6932b1..a83c5db 100644 --- a/apps/TestingCamera/res/layout/main.xml +++ b/apps/TestingCamera/res/layout/main.xml @@ -225,6 +225,20 @@ android:layout_height="wrap_content" android:layout_weight="1" /> + <TextView + android:id="@+id/video_record_size_spinner_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="@string/video_record_size_prompt" + android:textAppearance="?android:attr/textAppearanceSmall" /> + + <Spinner + android:id="@+id/video_record_size_spinner" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" /> + <ToggleButton android:id="@+id/start_record" android:layout_width="fill_parent" diff --git a/apps/TestingCamera/res/values/strings.xml b/apps/TestingCamera/res/values/strings.xml index ca0730d..e86b350 100644 --- a/apps/TestingCamera/res/values/strings.xml +++ b/apps/TestingCamera/res/values/strings.xml @@ -29,6 +29,7 @@ <string name="record_on_label">Recording on</string> <string name="record_off_label">Recording off</string> <string name="camcorder_profile_prompt">Camcorder profile</string> + <string name="video_record_size_prompt">Video Record size</string> <string name="horiz_rule_color">#777777</string> <string name="show_info">Info</string> <string name="info_ok_button_label">OK</string> diff --git a/apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java b/apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java index d6ec0e6..dc58384 100644 --- a/apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java +++ b/apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java @@ -77,6 +77,7 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback { private Spinner mSnapshotSizeSpinner; private Button mTakePictureButton; private Spinner mCamcorderProfileSpinner; + private Spinner mVideoRecordSizeSpinner; private ToggleButton mRecordToggle; private TextView mLogView; @@ -97,6 +98,8 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback { private int mSnapshotSize = 0; private List<CamcorderProfile> mCamcorderProfiles; private int mCamcorderProfile = 0; + private List<Camera.Size> mVideoRecordSizes; + private int mVideoRecordSize = 0; private MediaRecorder mRecorder; private File mRecordingFile; @@ -159,6 +162,9 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback { mCamcorderProfileSpinner = (Spinner) findViewById(R.id.camcorder_profile_spinner); mCamcorderProfileSpinner.setOnItemSelectedListener(mCamcorderProfileListener); + mVideoRecordSizeSpinner = (Spinner) findViewById(R.id.video_record_size_spinner); + mVideoRecordSizeSpinner.setOnItemSelectedListener(mVideoRecordSizeListener); + mRecordToggle = (ToggleButton) findViewById(R.id.start_record); mRecordToggle.setOnClickListener(mRecordToggleListener); mPreviewOnlyControls.add(mRecordToggle); @@ -422,6 +428,35 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback { log("Setting camcorder profile to " + ((TextView)view).getText()); mCamcorderProfile = pos; + + // Additionally change video recording size to match + mVideoRecordSize = 0; // "default", in case it's not found + int width = mCamcorderProfiles.get(pos).videoFrameWidth; + int height = mCamcorderProfiles.get(pos).videoFrameHeight; + for (int i = 0; i < mVideoRecordSizes.size(); i++) { + Camera.Size s = mVideoRecordSizes.get(i); + if (width == s.width && height == s.height) { + mVideoRecordSize = i; + break; + } + } + log("Setting video record size to " + mVideoRecordSize); + mVideoRecordSizeSpinner.setSelection(mVideoRecordSize); + } + + public void onNothingSelected(AdapterView<?> parent) { + + } + }; + + private AdapterView.OnItemSelectedListener mVideoRecordSizeListener = + new AdapterView.OnItemSelectedListener() { + public void onItemSelected(AdapterView<?> parent, + View view, int pos, long id) { + if (pos == mVideoRecordSize) return; + + log("Setting video record size to " + ((TextView)view).getText()); + mVideoRecordSize = pos; } public void onNothingSelected(AdapterView<?> parent) { @@ -503,6 +538,7 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback { updateFlashModes(mParams); updateSnapshotSizes(mParams); updateCamcorderProfile(mCameraId); + updateVideoRecordSize(mCameraId); // Update parameters based on above updates mCamera.setParameters(mParams); @@ -667,6 +703,32 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback { } + private void updateVideoRecordSize(int cameraId) { + List<Camera.Size> videoSizes = mParams.getSupportedVideoSizes(); + if (videoSizes == null) { // TODO: surface this to the user + log("Failed to get video size list, using preview sizes instead"); + videoSizes = mParams.getSupportedPreviewSizes(); + } + + List<String> availableVideoRecordSizes = new ArrayList<String>(); + mVideoRecordSizes = new ArrayList<Camera.Size>(); + + availableVideoRecordSizes.add("Default"); + mVideoRecordSizes.add(mCamera.new Size(0,0)); + + for (Camera.Size s : videoSizes) { + availableVideoRecordSizes.add(s.width + "x" + s.height); + mVideoRecordSizes.add(s); + } + String[] nameArray = (String[])availableVideoRecordSizes.toArray(new String[0]); + mVideoRecordSizeSpinner.setAdapter( + new ArrayAdapter<String>( + this, R.layout.spinner_item, nameArray)); + + mVideoRecordSize = 0; + log("Setting video record profile to " + nameArray[mVideoRecordSize]); + } + void resizePreview(int width, int height) { if (mPreviewHolder != null) { int viewHeight = mPreviewView.getHeight(); @@ -761,6 +823,10 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback { mRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER); mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); mRecorder.setProfile(mCamcorderProfiles.get(mCamcorderProfile)); + Camera.Size videoRecordSize = mVideoRecordSizes.get(mVideoRecordSize); + if (videoRecordSize.width > 0 && videoRecordSize.height > 0) { + mRecorder.setVideoSize(videoRecordSize.width, videoRecordSize.height); + } File outputFile = getOutputMediaFile(MEDIA_TYPE_VIDEO); log("File name:" + outputFile.toString()); mRecorder.setOutputFile(outputFile.toString()); |