Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ Thomas Danner <[email protected]>
Diego Velásquez <[email protected]>
Hajime Nakamura <[email protected]>
Tuyển Vũ Xuân <[email protected]>
Nicholas Cullen <[email protected]>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Range;
import android.util.Size;
import android.view.Display;
import android.view.OrientationEventListener;
Expand Down Expand Up @@ -289,6 +290,7 @@ private class Camera {
private Size videoSize;
private MediaRecorder mediaRecorder;
private boolean recordingVideo;
private Range<Integer> aeFPSRange;

Camera(final String cameraName, final String resolutionPreset, @NonNull final Result result) {

Expand Down Expand Up @@ -322,6 +324,8 @@ private class Camera {
isFrontFacing =
characteristics.get(CameraCharacteristics.LENS_FACING)
== CameraMetadata.LENS_FACING_FRONT;

setBestAERange(characteristics);
computeBestCaptureSize(streamConfigurationMap);
computeBestPreviewAndRecordingSize(streamConfigurationMap, minPreviewSize, captureSize);

Expand Down Expand Up @@ -395,6 +399,29 @@ private boolean hasAudioPermission() {
== PackageManager.PERMISSION_GRANTED;
}

private void setBestAERange(CameraCharacteristics characteristics) {
Range<Integer>[] fpsRanges =
characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);

if (fpsRanges.length <= 0) {
return;
}

Integer idx = 0;
Integer biggestDiference = 0;

for (Integer i = 0; i < fpsRanges.length; i++) {
Integer currentDifference = fpsRanges[i].getUpper() - fpsRanges[i].getLower();

if (currentDifference > biggestDiference) {
idx = i;
biggestDiference = currentDifference;
}
}

aeFPSRange = fpsRanges[idx];
}

private void computeBestPreviewAndRecordingSize(
StreamConfigurationMap streamConfigurationMap, Size minPreviewSize, Size captureSize) {
Size[] sizes = streamConfigurationMap.getOutputSizes(SurfaceTexture.class);
Expand Down Expand Up @@ -738,8 +765,15 @@ public void onConfigured(@NonNull CameraCaptureSession session) {
}
try {
cameraCaptureSession = session;

captureRequestBuilder.set(
CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);

if (Camera.this.aeFPSRange != null) {
captureRequestBuilder.set(
CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, Camera.this.aeFPSRange);
}

cameraCaptureSession.setRepeatingRequest(captureRequestBuilder.build(), null, null);
} catch (CameraAccessException e) {
sendErrorEvent(e.getMessage());
Expand Down
1 change: 1 addition & 0 deletions packages/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ authors:
- Quentin Le Guennec <[email protected]>
- Koushik Ravikumar <[email protected]>
- Nissim Dsilva <[email protected]>
- Nicholas Cullen <[email protected]>

homepage: https://github.com/flutter/plugins/tree/master/packages/camera

Expand Down