use of android.util.Size in project android_frameworks_base by ResurrectionRemix.
the class Camera2CaptureRequestTest method testAeModeAndLock.
/**
* Test AE mode and lock.
*
* <p>
* For AE lock, when it is locked, exposure parameters shouldn't be changed.
* For AE modes, each mode should satisfy the per frame controls defined in
* API specifications.
* </p>
*/
public void testAeModeAndLock() throws Exception {
for (int i = 0; i < mCameraIds.length; i++) {
try {
openDevice(mCameraIds[i]);
if (!mStaticInfo.isColorOutputSupported()) {
Log.i(TAG, "Camera " + mCameraIds[i] + " does not support color outputs, skipping");
continue;
}
// Max preview size.
Size maxPreviewSz = mOrderedPreviewSizes.get(0);
// Update preview surface with given size for all sub-tests.
updatePreviewSurface(maxPreviewSz);
// Test iteration starts...
for (int iteration = 0; iteration < getIterationCount(); ++iteration) {
Log.v(TAG, String.format("AE mode and lock: %d/%d", iteration + 1, getIterationCount()));
// Test aeMode and lock
int[] aeModes = mStaticInfo.getAeAvailableModesChecked();
for (int mode : aeModes) {
aeModeAndLockTestByMode(mode);
}
getResultPrinter().printStatus(getIterationCount(), iteration + 1, mCameraIds[i]);
Thread.sleep(getTestWaitIntervalMs());
}
} finally {
closeDevice();
}
}
}
use of android.util.Size in project android_frameworks_base by ResurrectionRemix.
the class Camera2SwitchPreviewTest method updatePreviewSurfaceWithVideo.
/**
* Update preview size with video size.
*
* <p>Preview size will be capped with max preview size.</p>
*
* @param videoSize The video size used for preview.
* @param videoFrameRate The video frame rate
*
*/
private void updatePreviewSurfaceWithVideo(Size videoSize, int videoFrameRate) throws Exception {
if (mOrderedPreviewSizes == null) {
throw new IllegalStateException("supported preview size list is not initialized yet");
}
final float FRAME_DURATION_TOLERANCE = 0.01f;
long videoFrameDuration = (long) (1e9 / videoFrameRate * (1.0 + FRAME_DURATION_TOLERANCE));
HashMap<Size, Long> minFrameDurationMap = mStaticInfo.getAvailableMinFrameDurationsForFormatChecked(ImageFormat.PRIVATE);
Size maxPreviewSize = mOrderedPreviewSizes.get(0);
Size previewSize = null;
if (videoSize.getWidth() > maxPreviewSize.getWidth() || videoSize.getHeight() > maxPreviewSize.getHeight()) {
for (Size s : mOrderedPreviewSizes) {
Long frameDuration = minFrameDurationMap.get(s);
if (mStaticInfo.isHardwareLevelLegacy()) {
// Legacy doesn't report min frame duration
frameDuration = new Long(0);
}
assertTrue("Cannot find minimum frame duration for private size" + s, frameDuration != null);
if (frameDuration <= videoFrameDuration && s.getWidth() <= videoSize.getWidth() && s.getHeight() <= videoSize.getHeight()) {
Log.w(TAG, "Overwrite preview size from " + videoSize.toString() + " to " + s.toString());
previewSize = s;
break;
// If all preview size doesn't work then we fallback to video size
}
}
}
if (previewSize == null) {
previewSize = videoSize;
}
updatePreviewSurface(previewSize);
}
use of android.util.Size in project android_frameworks_base by ResurrectionRemix.
the class Camera2SwitchPreviewTest method prepareRecordingWithProfile.
/**
* Configure MediaRecorder recording session with CamcorderProfile, prepare
* the recording surface.
*/
private void prepareRecordingWithProfile(CamcorderProfile profile) throws Exception {
// Prepare MediaRecorder.
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mMediaRecorder.setProfile(profile);
mMediaRecorder.setOutputFile(mOutMediaFileName);
if (mPersistentSurface != null) {
mMediaRecorder.setInputSurface(mPersistentSurface);
mRecordingSurface = mPersistentSurface;
}
mMediaRecorder.prepare();
if (mPersistentSurface == null) {
mRecordingSurface = mMediaRecorder.getSurface();
}
assertNotNull("Recording surface must be non-null!", mRecordingSurface);
mVideoFrameRate = profile.videoFrameRate;
mVideoSize = new Size(profile.videoFrameWidth, profile.videoFrameHeight);
}
use of android.util.Size in project android_frameworks_base by ResurrectionRemix.
the class Camera2SwitchPreviewTest method prepareCapturePreview.
protected void prepareCapturePreview(CaptureRequest.Builder previewRequest, CaptureRequest.Builder stillRequest, CaptureCallback resultListener, ImageReader.OnImageAvailableListener imageListener) throws Exception {
Size captureSz = mOrderedStillSizes.get(0);
Size previewSz = mOrderedPreviewSizes.get(1);
if (VERBOSE) {
Log.v(TAG, String.format("Prepare single capture (%s) and preview (%s)", captureSz.toString(), previewSz.toString()));
}
// Update preview size.
updatePreviewSurface(previewSz);
// Create ImageReader.
createImageReader(captureSz, ImageFormat.JPEG, MAX_READER_IMAGES, imageListener);
// Configure output streams with preview and jpeg streams.
List<Surface> outputSurfaces = new ArrayList<Surface>();
outputSurfaces.add(mPreviewSurface);
outputSurfaces.add(mReaderSurface);
mSessionListener = new BlockingSessionCallback();
mSession = configureCameraSession(mCamera, outputSurfaces, mSessionListener, mHandler);
// Configure the requests.
previewRequest.addTarget(mPreviewSurface);
stillRequest.addTarget(mPreviewSurface);
stillRequest.addTarget(mReaderSurface);
// Start preview.
mSession.setRepeatingRequest(previewRequest.build(), resultListener, mHandler);
}
use of android.util.Size in project android_frameworks_base by ResurrectionRemix.
the class Camera2RecordingTest method updatePreviewSurfaceWithVideo.
/**
* Update preview size with video size.
*
* <p>Preview size will be capped with max preview size.</p>
*
* @param videoSize The video size used for preview.
* @param videoFrameRate The video frame rate
*
*/
private void updatePreviewSurfaceWithVideo(Size videoSize, int videoFrameRate) {
if (mOrderedPreviewSizes == null) {
throw new IllegalStateException("supported preview size list is not initialized yet");
}
final float FRAME_DURATION_TOLERANCE = 0.01f;
long videoFrameDuration = (long) (1e9 / videoFrameRate * (1.0 + FRAME_DURATION_TOLERANCE));
HashMap<Size, Long> minFrameDurationMap = mStaticInfo.getAvailableMinFrameDurationsForFormatChecked(ImageFormat.PRIVATE);
Size maxPreviewSize = mOrderedPreviewSizes.get(0);
Size previewSize = null;
if (videoSize.getWidth() > maxPreviewSize.getWidth() || videoSize.getHeight() > maxPreviewSize.getHeight()) {
for (Size s : mOrderedPreviewSizes) {
Long frameDuration = minFrameDurationMap.get(s);
if (mStaticInfo.isHardwareLevelLegacy()) {
// Legacy doesn't report min frame duration
frameDuration = new Long(0);
}
assertTrue("Cannot find minimum frame duration for private size" + s, frameDuration != null);
if (frameDuration <= videoFrameDuration && s.getWidth() <= videoSize.getWidth() && s.getHeight() <= videoSize.getHeight()) {
Log.w(TAG, "Overwrite preview size from " + videoSize.toString() + " to " + s.toString());
previewSize = s;
break;
// If all preview size doesn't work then we fallback to video size
}
}
}
if (previewSize == null) {
previewSize = videoSize;
}
updatePreviewSurface(previewSize);
}
Aggregations