Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Formatted files
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanbeusekom committed Jan 5, 2021
1 parent bd7b667 commit ad54915
Showing 1 changed file with 40 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public void onOrientationChanged(int i) {
initFps(cameraCharacteristics);
sensorOrientation = cameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
isFrontFacing =
cameraCharacteristics.get(CameraCharacteristics.LENS_FACING) == CameraMetadata.LENS_FACING_FRONT;
cameraCharacteristics.get(CameraCharacteristics.LENS_FACING)
== CameraMetadata.LENS_FACING_FRONT;
ResolutionPreset preset = ResolutionPreset.valueOf(resolutionPreset);
recordingProfile =
CameraUtils.getBestAvailableCamcorderProfileForResolutionPreset(cameraName, preset);
Expand All @@ -148,10 +149,11 @@ public void onOrientationChanged(int i) {
cameraCharacteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM));
}

private void initFps(CameraCharacteristics cameraCharacteristics){
private void initFps(CameraCharacteristics cameraCharacteristics) {
try {
Range<Integer>[] ranges = cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
if(ranges != null) {
Range<Integer>[] ranges =
cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
if (ranges != null) {
for (Range<Integer> range : ranges) {
int upper = range.getUpper();
Log.i("Camera", "[FPS Range Available] is:" + range);
Expand Down Expand Up @@ -285,21 +287,19 @@ private void createCaptureSession(
new CameraCaptureSession.StateCallback() {
@Override
public void onConfigured(@NonNull CameraCaptureSession session) {
if (cameraDevice == null) {
dartMessenger.sendCameraErrorEvent("The camera was closed during configuration.");
return;
}
cameraCaptureSession = session;
if (cameraDevice == null) {
dartMessenger.sendCameraErrorEvent("The camera was closed during configuration.");
return;
}
cameraCaptureSession = session;

updateFpsRange();
updateAutoFocus();
updateFlash(flashMode);
updateExposure(exposureMode);
updateFpsRange();
updateAutoFocus();
updateFlash(flashMode);
updateExposure(exposureMode);

refreshPreviewCaptureSession(
onSuccessCallback,
(code, message) ->dartMessenger.sendCameraErrorEvent(message)
);
refreshPreviewCaptureSession(
onSuccessCallback, (code, message) -> dartMessenger.sendCameraErrorEvent(message));
}

@Override
Expand Down Expand Up @@ -347,9 +347,7 @@ private void createCaptureSession(
}

private void refreshPreviewCaptureSession(
@Nullable Runnable onSuccessCallback,
@NonNull ErrorCallback onErrorCallback
) {
@Nullable Runnable onSuccessCallback, @NonNull ErrorCallback onErrorCallback) {
if (cameraCaptureSession == null) {
return;
}
Expand Down Expand Up @@ -509,11 +507,11 @@ private void runPicturePreCapture() {
CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START);

refreshPreviewCaptureSession(
() -> captureRequestBuilder.set(
CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER,
CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_IDLE),
(code, message) -> pictureCaptureRequest.error(code, message, null)
);
() ->
captureRequestBuilder.set(
CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER,
CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_IDLE),
(code, message) -> pictureCaptureRequest.error(code, message, null));
}

private void runPictureCapture() {
Expand Down Expand Up @@ -562,9 +560,7 @@ private void lockAutoFocus() {
CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START);

refreshPreviewCaptureSession(
null,
(code, message) ->pictureCaptureRequest.error(code, message, null)
);
null, (code, message) -> pictureCaptureRequest.error(code, message, null));
}

private void unlockAutoFocus() {
Expand Down Expand Up @@ -709,9 +705,10 @@ public void onCaptureCompleted(
refreshPreviewCaptureSession(
() -> {
result.success(null);
isFinished = true; },
(code, message) -> result.error("setFlashModeFailed", "Could not set flash mode.", null)
);
isFinished = true;
},
(code, message) ->
result.error("setFlashModeFailed", "Could not set flash mode.", null));
}

@Override
Expand All @@ -732,9 +729,8 @@ public void onCaptureFailed(
updateFlash(mode);

refreshPreviewCaptureSession(
() -> result.success(null) ,
(code, message) -> result.error("setFlashModeFailed", "Could not set flash mode.", null)
);
() -> result.success(null),
(code, message) -> result.error("setFlashModeFailed", "Could not set flash mode.", null));
}
}

Expand Down Expand Up @@ -769,9 +765,7 @@ public void setExposurePoint(@NonNull final Result result, Double x, Double y)
// Apply it
updateExposure(exposureMode);
refreshPreviewCaptureSession(
() -> result.success(null),
(code, message) -> result.error("CameraAccess", message, null)
);
() -> result.success(null), (code, message) -> result.error("CameraAccess", message, null));
}

@TargetApi(VERSION_CODES.P)
Expand Down Expand Up @@ -905,21 +899,20 @@ private void updateFpsRange() {

private void updateAutoFocus() {
if (useAutoFocus) {
int[] modes = cameraCharacteristics.get(
CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES);
int[] modes = cameraCharacteristics.get(CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES);
// Auto focus is not supported
if (modes == null || modes.length == 0 ||
(modes.length == 1 && modes[0] == CameraCharacteristics.CONTROL_AF_MODE_OFF)) {
if (modes == null
|| modes.length == 0
|| (modes.length == 1 && modes[0] == CameraCharacteristics.CONTROL_AF_MODE_OFF)) {
useAutoFocus = false;
captureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
CaptureRequest.CONTROL_AF_MODE_OFF);
captureRequestBuilder.set(
CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
} else {
captureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
captureRequestBuilder.set(
CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
}
} else {
captureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
CaptureRequest.CONTROL_AF_MODE_OFF);
captureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
}
}

Expand Down

0 comments on commit ad54915

Please sign in to comment.