Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,30 +225,6 @@ public Camera(
dartMessenger,
videoCaptureSettings.resolutionPreset);

Integer recordingFps = null;

if (videoCaptureSettings.fps != null && videoCaptureSettings.fps.intValue() > 0) {
recordingFps = videoCaptureSettings.fps;
} else {

if (SdkCapabilityChecker.supportsEncoderProfiles()) {
EncoderProfiles encoderProfiles = getRecordingProfile();
if (encoderProfiles != null && encoderProfiles.getVideoProfiles().size() > 0) {
recordingFps = encoderProfiles.getVideoProfiles().get(0).getFrameRate();
}
} else {
CamcorderProfile camcorderProfile = getRecordingProfileLegacy();
recordingFps = null != camcorderProfile ? camcorderProfile.videoFrameRate : null;
}
}

if (recordingFps != null && recordingFps.intValue() > 0) {

final FpsRangeFeature fpsRange = new FpsRangeFeature(cameraProperties);
fpsRange.setValue(new Range<Integer>(recordingFps, recordingFps));
this.cameraFeatures.setFpsRange(fpsRange);
}

// Create capture callback.
captureTimeouts = new CaptureTimeoutsWrapper(3000, 3000);
captureProps = new CameraCaptureProperties();
Expand Down Expand Up @@ -326,6 +302,32 @@ private void prepareMediaRecorder(String outputFilePath) throws IOException {
.build();
}

private void setFpsCameraFeature(CameraProperties cameraProperties) {
Integer recordingFps = null;

if (videoCaptureSettings.fps != null && videoCaptureSettings.fps.intValue() > 0) {
recordingFps = videoCaptureSettings.fps;
} else {

if (SdkCapabilityChecker.supportsEncoderProfiles()) {
EncoderProfiles encoderProfiles = getRecordingProfile();
if (encoderProfiles != null && encoderProfiles.getVideoProfiles().size() > 0) {
recordingFps = encoderProfiles.getVideoProfiles().get(0).getFrameRate();
}
} else {
CamcorderProfile camcorderProfile = getRecordingProfileLegacy();
recordingFps = null != camcorderProfile ? camcorderProfile.videoFrameRate : null;
}
}

if (recordingFps != null && recordingFps.intValue() > 0) {

final FpsRangeFeature fpsRange = new FpsRangeFeature(cameraProperties);
fpsRange.setValue(new Range<Integer>(recordingFps, recordingFps));
this.cameraFeatures.setFpsRange(fpsRange);
}
}

@SuppressLint("MissingPermission")
public void open(Integer imageFormatGroup) throws CameraAccessException {
this.imageFormatGroup = imageFormatGroup;
Expand Down Expand Up @@ -851,6 +853,9 @@ public String stopVideoRecording() {
// Re-create autofocus feature so it's using continuous capture focus mode now.
cameraFeatures.setAutoFocus(
cameraFeatureFactory.createAutoFocusFeature(cameraProperties, false));
// Reset to non recording fps range (the default)
cameraFeatures.setFpsRange(cameraFeatureFactory.createFpsRangeFeature(cameraProperties));

recordingVideo = false;
try {
closeRenderer();
Expand Down Expand Up @@ -1252,6 +1257,8 @@ void prepareRecording() {
// Re-create autofocus feature so it's using video focus mode now.
cameraFeatures.setAutoFocus(
cameraFeatureFactory.createAutoFocusFeature(cameraProperties, true));
// Update camera features with the desired fps range
setFpsCameraFeature(cameraProperties);
}

private void setStreamHandler(EventChannel imageStreamChannel) {
Expand Down Expand Up @@ -1375,6 +1382,7 @@ public void setDescriptionWhileRecording(CameraProperties properties) {
videoCaptureSettings.resolutionPreset);
cameraFeatures.setAutoFocus(
cameraFeatureFactory.createAutoFocusFeature(cameraProperties, true));
setFpsCameraFeature(cameraProperties);
try {
open(imageFormatGroup);
} catch (CameraAccessException e) {
Expand Down