Loading app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -790,7 +790,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv clickView(switchVideoButton); waitUntilCameraOpened(); assertTrue(mPreview.isVideo()); CamcorderProfile profile = mPreview.getCamcorderProfile(); Preview.VideoProfile profile = mPreview.getVideoProfile(); CameraController.Size video_preview_size = mPreview.getCameraController().getPreviewSize(); //targetRatio = mPreview.getTargetRatioForPreview(display_size); targetRatio = mPreview.getTargetRatio(); Loading Loading @@ -835,7 +835,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv clickView(switchVideoButton); waitUntilCameraOpened(); assertTrue(mPreview.isVideo()); profile = mPreview.getCamcorderProfile(); profile = mPreview.getVideoProfile(); video_preview_size = mPreview.getCameraController().getPreviewSize(); //targetRatio = mPreview.getTargetRatioForPreview(display_size); targetRatio = mPreview.getTargetRatio(); Loading app/src/main/java/net/sourceforge/opencamera/CameraController/CameraController2.java +25 −6 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import android.graphics.SurfaceTexture; import android.hardware.camera2.CameraAccessException; import android.hardware.camera2.CameraCaptureSession; import android.hardware.camera2.CameraCharacteristics; import android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession; import android.hardware.camera2.CameraDevice; import android.hardware.camera2.CameraManager; import android.hardware.camera2.CameraMetadata; Loading Loading @@ -104,6 +105,7 @@ public class CameraController2 extends CameraController { private Image pending_image; private ErrorCallback take_picture_error_cb; private boolean want_video_high_speed; private boolean is_video_high_speed; // whether we're actually recording in high speed //private ImageReader previewImageReader; private SurfaceTexture texture; private Surface surface_texture; Loading Loading @@ -2097,6 +2099,7 @@ public class CameraController2 extends CameraController { throw new RuntimeException(); // throw as RuntimeException, as this is a programming error } this.want_video_high_speed = want_video_high_speed; this.is_video_high_speed = false; // reset just to be safe } @Override Loading Loading @@ -3112,7 +3115,14 @@ public class CameraController2 extends CameraController { Log.d(TAG, "no camera or capture session"); return; } 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"); } Loading Loading @@ -3349,21 +3359,30 @@ public class CameraController2 extends CameraController { } else { Log.d(TAG, "imageReader: " + imageReader); Log.d(TAG, "imageReader: " + imageReader.getWidth()); Log.d(TAG, "imageReader: " + imageReader.getHeight()); Log.d(TAG, "imageReader: " + imageReader.getImageFormat()); Log.d(TAG, "imageReader width: " + imageReader.getWidth()); Log.d(TAG, "imageReader height: " + imageReader.getHeight()); Log.d(TAG, "imageReader format: " + imageReader.getImageFormat()); } } } if( want_video_high_speed && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ) { if( video_recorder != null && want_video_high_speed && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ) { //StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); //configs.getHighSpeedVideoFpsRangesFor() // okay to set this for previewBuilder - we create a new one in initVideoRecorderPostPrepare() when starting // video recording, and another one when stopping video recording in reconnect(). Range<Integer> fps_range = new Range<>(120, 120); previewBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fps_range); camera.createConstrainedHighSpeedCaptureSession(surfaces, myStateCallback, handler); is_video_high_speed = true; } else { camera.createCaptureSession(surfaces, myStateCallback, handler); is_video_high_speed = false; } if( MyDebug.LOG ) Log.d(TAG, "wait until session created..."); Loading app/src/main/java/net/sourceforge/opencamera/MainActivity.java +2 −2 Original line number Diff line number Diff line Loading @@ -1336,7 +1336,7 @@ public class MainActivity extends Activity implements AudioListener.AudioListene if( preview.getVideoQualityHander().getCurrentVideoQuality() != null ) { bundle.putString("current_video_quality", preview.getVideoQualityHander().getCurrentVideoQuality()); } CamcorderProfile camcorder_profile = preview.getCamcorderProfile(); Preview.VideoProfile camcorder_profile = preview.getVideoProfile(); bundle.putInt("video_frame_width", camcorder_profile.videoFrameWidth); bundle.putInt("video_frame_height", camcorder_profile.videoFrameHeight); bundle.putInt("video_bit_rate", camcorder_profile.videoBitRate); Loading Loading @@ -2858,7 +2858,7 @@ public class MainActivity extends Activity implements AudioListener.AudioListene SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); boolean simple = true; if( preview.isVideo() ) { CamcorderProfile profile = preview.getCamcorderProfile(); Preview.VideoProfile profile = preview.getVideoProfile(); String bitrate_string; if( profile.videoBitRate >= 10000000 ) bitrate_string = profile.videoBitRate/1000000 + "Mbps"; Loading app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java +2 −2 Original line number Diff line number Diff line Loading @@ -1325,7 +1325,7 @@ public class MyApplicationInterface implements ApplicationInterface { } @Override public void onVideoRecordStartError(CamcorderProfile profile) { public void onVideoRecordStartError(Preview.VideoProfile profile) { if( MyDebug.LOG ) Log.d(TAG, "onVideoRecordStartError"); String error_message; Loading @@ -1344,7 +1344,7 @@ public class MyApplicationInterface implements ApplicationInterface { } @Override public void onVideoRecordStopError(CamcorderProfile profile) { public void onVideoRecordStopError(Preview.VideoProfile profile) { if( MyDebug.LOG ) Log.d(TAG, "onVideoRecordStopError"); //main_activity.getPreview().showToast(null, R.string.failed_to_record_video); Loading app/src/main/java/net/sourceforge/opencamera/Preview/ApplicationInterface.java +2 −2 Original line number Diff line number Diff line Loading @@ -113,8 +113,8 @@ public interface ApplicationInterface { void onPhotoError(); // callback for failing to take a photo void onVideoInfo(int what, int extra); // callback for info when recording video (see MediaRecorder.OnInfoListener) void onVideoError(int what, int extra); // callback for errors when recording video (see MediaRecorder.OnErrorListener) void onVideoRecordStartError(CamcorderProfile profile); // callback for video recording failing to start void onVideoRecordStopError(CamcorderProfile profile); // callback for video recording being corrupted void onVideoRecordStartError(Preview.VideoProfile profile); // callback for video recording failing to start void onVideoRecordStopError(Preview.VideoProfile profile); // callback for video recording being corrupted void onFailedReconnectError(); // failed to reconnect camera after stopping video recording void onFailedCreateVideoFileError(); // callback if unable to create file for recording video void hasPausedPreview(boolean paused); // called when the preview is paused or unpaused (due to getPausePreviewPref()) Loading Loading
app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -790,7 +790,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv clickView(switchVideoButton); waitUntilCameraOpened(); assertTrue(mPreview.isVideo()); CamcorderProfile profile = mPreview.getCamcorderProfile(); Preview.VideoProfile profile = mPreview.getVideoProfile(); CameraController.Size video_preview_size = mPreview.getCameraController().getPreviewSize(); //targetRatio = mPreview.getTargetRatioForPreview(display_size); targetRatio = mPreview.getTargetRatio(); Loading Loading @@ -835,7 +835,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv clickView(switchVideoButton); waitUntilCameraOpened(); assertTrue(mPreview.isVideo()); profile = mPreview.getCamcorderProfile(); profile = mPreview.getVideoProfile(); video_preview_size = mPreview.getCameraController().getPreviewSize(); //targetRatio = mPreview.getTargetRatioForPreview(display_size); targetRatio = mPreview.getTargetRatio(); Loading
app/src/main/java/net/sourceforge/opencamera/CameraController/CameraController2.java +25 −6 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import android.graphics.SurfaceTexture; import android.hardware.camera2.CameraAccessException; import android.hardware.camera2.CameraCaptureSession; import android.hardware.camera2.CameraCharacteristics; import android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession; import android.hardware.camera2.CameraDevice; import android.hardware.camera2.CameraManager; import android.hardware.camera2.CameraMetadata; Loading Loading @@ -104,6 +105,7 @@ public class CameraController2 extends CameraController { private Image pending_image; private ErrorCallback take_picture_error_cb; private boolean want_video_high_speed; private boolean is_video_high_speed; // whether we're actually recording in high speed //private ImageReader previewImageReader; private SurfaceTexture texture; private Surface surface_texture; Loading Loading @@ -2097,6 +2099,7 @@ public class CameraController2 extends CameraController { throw new RuntimeException(); // throw as RuntimeException, as this is a programming error } this.want_video_high_speed = want_video_high_speed; this.is_video_high_speed = false; // reset just to be safe } @Override Loading Loading @@ -3112,7 +3115,14 @@ public class CameraController2 extends CameraController { Log.d(TAG, "no camera or capture session"); return; } 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"); } Loading Loading @@ -3349,21 +3359,30 @@ public class CameraController2 extends CameraController { } else { Log.d(TAG, "imageReader: " + imageReader); Log.d(TAG, "imageReader: " + imageReader.getWidth()); Log.d(TAG, "imageReader: " + imageReader.getHeight()); Log.d(TAG, "imageReader: " + imageReader.getImageFormat()); Log.d(TAG, "imageReader width: " + imageReader.getWidth()); Log.d(TAG, "imageReader height: " + imageReader.getHeight()); Log.d(TAG, "imageReader format: " + imageReader.getImageFormat()); } } } if( want_video_high_speed && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ) { if( video_recorder != null && want_video_high_speed && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ) { //StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); //configs.getHighSpeedVideoFpsRangesFor() // okay to set this for previewBuilder - we create a new one in initVideoRecorderPostPrepare() when starting // video recording, and another one when stopping video recording in reconnect(). Range<Integer> fps_range = new Range<>(120, 120); previewBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fps_range); camera.createConstrainedHighSpeedCaptureSession(surfaces, myStateCallback, handler); is_video_high_speed = true; } else { camera.createCaptureSession(surfaces, myStateCallback, handler); is_video_high_speed = false; } if( MyDebug.LOG ) Log.d(TAG, "wait until session created..."); Loading
app/src/main/java/net/sourceforge/opencamera/MainActivity.java +2 −2 Original line number Diff line number Diff line Loading @@ -1336,7 +1336,7 @@ public class MainActivity extends Activity implements AudioListener.AudioListene if( preview.getVideoQualityHander().getCurrentVideoQuality() != null ) { bundle.putString("current_video_quality", preview.getVideoQualityHander().getCurrentVideoQuality()); } CamcorderProfile camcorder_profile = preview.getCamcorderProfile(); Preview.VideoProfile camcorder_profile = preview.getVideoProfile(); bundle.putInt("video_frame_width", camcorder_profile.videoFrameWidth); bundle.putInt("video_frame_height", camcorder_profile.videoFrameHeight); bundle.putInt("video_bit_rate", camcorder_profile.videoBitRate); Loading Loading @@ -2858,7 +2858,7 @@ public class MainActivity extends Activity implements AudioListener.AudioListene SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); boolean simple = true; if( preview.isVideo() ) { CamcorderProfile profile = preview.getCamcorderProfile(); Preview.VideoProfile profile = preview.getVideoProfile(); String bitrate_string; if( profile.videoBitRate >= 10000000 ) bitrate_string = profile.videoBitRate/1000000 + "Mbps"; Loading
app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java +2 −2 Original line number Diff line number Diff line Loading @@ -1325,7 +1325,7 @@ public class MyApplicationInterface implements ApplicationInterface { } @Override public void onVideoRecordStartError(CamcorderProfile profile) { public void onVideoRecordStartError(Preview.VideoProfile profile) { if( MyDebug.LOG ) Log.d(TAG, "onVideoRecordStartError"); String error_message; Loading @@ -1344,7 +1344,7 @@ public class MyApplicationInterface implements ApplicationInterface { } @Override public void onVideoRecordStopError(CamcorderProfile profile) { public void onVideoRecordStopError(Preview.VideoProfile profile) { if( MyDebug.LOG ) Log.d(TAG, "onVideoRecordStopError"); //main_activity.getPreview().showToast(null, R.string.failed_to_record_video); Loading
app/src/main/java/net/sourceforge/opencamera/Preview/ApplicationInterface.java +2 −2 Original line number Diff line number Diff line Loading @@ -113,8 +113,8 @@ public interface ApplicationInterface { void onPhotoError(); // callback for failing to take a photo void onVideoInfo(int what, int extra); // callback for info when recording video (see MediaRecorder.OnInfoListener) void onVideoError(int what, int extra); // callback for errors when recording video (see MediaRecorder.OnErrorListener) void onVideoRecordStartError(CamcorderProfile profile); // callback for video recording failing to start void onVideoRecordStopError(CamcorderProfile profile); // callback for video recording being corrupted void onVideoRecordStartError(Preview.VideoProfile profile); // callback for video recording failing to start void onVideoRecordStopError(Preview.VideoProfile profile); // callback for video recording being corrupted void onFailedReconnectError(); // failed to reconnect camera after stopping video recording void onFailedCreateVideoFileError(); // callback if unable to create file for recording video void hasPausedPreview(boolean paused); // called when the preview is paused or unpaused (due to getPausePreviewPref()) Loading