use of android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession in project android_frameworks_base by ResurrectionRemix.
the class Camera2RecordingTest method startSlowMotionRecording.
private void startSlowMotionRecording(boolean useMediaRecorder, int videoFrameRate, int captureRate, Range<Integer> fpsRange, CameraCaptureSession.CaptureCallback listener, boolean useHighSpeedSession) throws Exception {
List<Surface> outputSurfaces = new ArrayList<Surface>(2);
assertTrue("Both preview and recording surfaces should be valid", mPreviewSurface.isValid() && mRecordingSurface.isValid());
outputSurfaces.add(mPreviewSurface);
outputSurfaces.add(mRecordingSurface);
// Video snapshot surface
if (mReaderSurface != null) {
outputSurfaces.add(mReaderSurface);
}
mSessionListener = new BlockingSessionCallback();
mSession = configureCameraSession(mCamera, outputSurfaces, useHighSpeedSession, mSessionListener, mHandler);
// Create slow motion request list
List<CaptureRequest> slowMoRequests = null;
if (useHighSpeedSession) {
CaptureRequest.Builder requestBuilder = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
requestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fpsRange);
requestBuilder.addTarget(mPreviewSurface);
requestBuilder.addTarget(mRecordingSurface);
slowMoRequests = ((CameraConstrainedHighSpeedCaptureSession) mSession).createHighSpeedRequestList(requestBuilder.build());
} else {
CaptureRequest.Builder recordingRequestBuilder = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
recordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_USE_SCENE_MODE);
recordingRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO);
CaptureRequest.Builder recordingOnlyBuilder = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
recordingOnlyBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_USE_SCENE_MODE);
recordingOnlyBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO);
int slowMotionFactor = captureRate / videoFrameRate;
// Make sure camera output frame rate is set to correct value.
recordingRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fpsRange);
recordingRequestBuilder.addTarget(mRecordingSurface);
recordingRequestBuilder.addTarget(mPreviewSurface);
recordingOnlyBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fpsRange);
recordingOnlyBuilder.addTarget(mRecordingSurface);
slowMoRequests = new ArrayList<CaptureRequest>();
// Preview + recording.
slowMoRequests.add(recordingRequestBuilder.build());
for (int i = 0; i < slowMotionFactor - 1; i++) {
// Recording only.
slowMoRequests.add(recordingOnlyBuilder.build());
}
}
mSession.setRepeatingBurst(slowMoRequests, listener, mHandler);
if (useMediaRecorder) {
mMediaRecorder.start();
} else {
// TODO: need implement MediaCodec path.
}
}
use of android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession in project android_frameworks_base by AOSPA.
the class Camera2RecordingTest method startSlowMotionRecording.
private void startSlowMotionRecording(boolean useMediaRecorder, int videoFrameRate, int captureRate, Range<Integer> fpsRange, CameraCaptureSession.CaptureCallback listener, boolean useHighSpeedSession) throws Exception {
List<Surface> outputSurfaces = new ArrayList<Surface>(2);
assertTrue("Both preview and recording surfaces should be valid", mPreviewSurface.isValid() && mRecordingSurface.isValid());
outputSurfaces.add(mPreviewSurface);
outputSurfaces.add(mRecordingSurface);
// Video snapshot surface
if (mReaderSurface != null) {
outputSurfaces.add(mReaderSurface);
}
mSessionListener = new BlockingSessionCallback();
mSession = configureCameraSession(mCamera, outputSurfaces, useHighSpeedSession, mSessionListener, mHandler);
// Create slow motion request list
List<CaptureRequest> slowMoRequests = null;
if (useHighSpeedSession) {
CaptureRequest.Builder requestBuilder = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
requestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fpsRange);
requestBuilder.addTarget(mPreviewSurface);
requestBuilder.addTarget(mRecordingSurface);
slowMoRequests = ((CameraConstrainedHighSpeedCaptureSession) mSession).createHighSpeedRequestList(requestBuilder.build());
} else {
CaptureRequest.Builder recordingRequestBuilder = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
recordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_USE_SCENE_MODE);
recordingRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO);
CaptureRequest.Builder recordingOnlyBuilder = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
recordingOnlyBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_USE_SCENE_MODE);
recordingOnlyBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO);
int slowMotionFactor = captureRate / videoFrameRate;
// Make sure camera output frame rate is set to correct value.
recordingRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fpsRange);
recordingRequestBuilder.addTarget(mRecordingSurface);
recordingRequestBuilder.addTarget(mPreviewSurface);
recordingOnlyBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fpsRange);
recordingOnlyBuilder.addTarget(mRecordingSurface);
slowMoRequests = new ArrayList<CaptureRequest>();
// Preview + recording.
slowMoRequests.add(recordingRequestBuilder.build());
for (int i = 0; i < slowMotionFactor - 1; i++) {
// Recording only.
slowMoRequests.add(recordingOnlyBuilder.build());
}
}
mSession.setRepeatingBurst(slowMoRequests, listener, mHandler);
if (useMediaRecorder) {
mMediaRecorder.start();
} else {
// TODO: need implement MediaCodec path.
}
}
use of android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession in project OpenCamera by ageback.
the class CameraController2 method setRepeatingRequest.
private void setRepeatingRequest(CaptureRequest request) throws CameraAccessException {
if (MyDebug.LOG)
Log.d(TAG, "setRepeatingRequest");
if (camera == null || captureSession == null) {
if (MyDebug.LOG)
Log.d(TAG, "no camera or capture session");
return;
}
try {
if (is_video_high_speed && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
CameraConstrainedHighSpeedCaptureSession captureSessionHighSpeed = (CameraConstrainedHighSpeedCaptureSession) captureSession;
List<CaptureRequest> mPreviewBuilderBurst = captureSessionHighSpeed.createHighSpeedRequestList(request);
captureSessionHighSpeed.setRepeatingBurst(mPreviewBuilderBurst, previewCaptureCallback, handler);
} else {
captureSession.setRepeatingRequest(request, previewCaptureCallback, handler);
}
if (MyDebug.LOG)
Log.d(TAG, "setRepeatingRequest done");
} catch (IllegalStateException e) {
if (MyDebug.LOG)
Log.d(TAG, "captureSession already closed!");
e.printStackTrace();
// got this as a Google Play exception (from onCaptureCompleted->processCompleted) - this means the capture session is already closed
}
}
use of android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession in project android_packages_apps_Snap by LineageOS.
the class Camera2GraphView method applyZoomAndUpdate.
private void applyZoomAndUpdate(int id) {
if (!checkSessionAndBuilder(mCaptureSession[id], mPreviewRequestBuilder[id])) {
return;
}
applyZoom(mPreviewRequestBuilder[id], id);
try {
if (id == MONO_ID && !canStartMonoPreview()) {
mCaptureSession[id].capture(mPreviewRequestBuilder[id].build(), mCaptureCallback, mCameraHandler);
} else {
CameraCaptureSession session = mCaptureSession[id];
if (session instanceof CameraConstrainedHighSpeedCaptureSession) {
List list = CameraUtil.createHighSpeedRequestList(mPreviewRequestBuilder[id].build(), id);
((CameraConstrainedHighSpeedCaptureSession) session).setRepeatingBurst(list, mCaptureCallback, mCameraHandler);
} else {
mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id].build(), mCaptureCallback, mCameraHandler);
}
}
} catch (CameraAccessException | IllegalStateException e) {
e.printStackTrace();
}
}
use of android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession in project platform_frameworks_base by android.
the class Camera2RecordingTest method startSlowMotionRecording.
private void startSlowMotionRecording(boolean useMediaRecorder, int videoFrameRate, int captureRate, Range<Integer> fpsRange, CameraCaptureSession.CaptureCallback listener, boolean useHighSpeedSession) throws Exception {
List<Surface> outputSurfaces = new ArrayList<Surface>(2);
assertTrue("Both preview and recording surfaces should be valid", mPreviewSurface.isValid() && mRecordingSurface.isValid());
outputSurfaces.add(mPreviewSurface);
outputSurfaces.add(mRecordingSurface);
// Video snapshot surface
if (mReaderSurface != null) {
outputSurfaces.add(mReaderSurface);
}
mSessionListener = new BlockingSessionCallback();
mSession = configureCameraSession(mCamera, outputSurfaces, useHighSpeedSession, mSessionListener, mHandler);
// Create slow motion request list
List<CaptureRequest> slowMoRequests = null;
if (useHighSpeedSession) {
CaptureRequest.Builder requestBuilder = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
requestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fpsRange);
requestBuilder.addTarget(mPreviewSurface);
requestBuilder.addTarget(mRecordingSurface);
slowMoRequests = ((CameraConstrainedHighSpeedCaptureSession) mSession).createHighSpeedRequestList(requestBuilder.build());
} else {
CaptureRequest.Builder recordingRequestBuilder = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
recordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_USE_SCENE_MODE);
recordingRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO);
CaptureRequest.Builder recordingOnlyBuilder = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
recordingOnlyBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_USE_SCENE_MODE);
recordingOnlyBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO);
int slowMotionFactor = captureRate / videoFrameRate;
// Make sure camera output frame rate is set to correct value.
recordingRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fpsRange);
recordingRequestBuilder.addTarget(mRecordingSurface);
recordingRequestBuilder.addTarget(mPreviewSurface);
recordingOnlyBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fpsRange);
recordingOnlyBuilder.addTarget(mRecordingSurface);
slowMoRequests = new ArrayList<CaptureRequest>();
// Preview + recording.
slowMoRequests.add(recordingRequestBuilder.build());
for (int i = 0; i < slowMotionFactor - 1; i++) {
// Recording only.
slowMoRequests.add(recordingOnlyBuilder.build());
}
}
mSession.setRepeatingBurst(slowMoRequests, listener, mHandler);
if (useMediaRecorder) {
mMediaRecorder.start();
} else {
// TODO: need implement MediaCodec path.
}
}
Aggregations