forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[camerax] Retrieve exposure and zoom camera information (flutter#3798)
Implements retrieval of exposure and zoom camera information. Specifically, implements the following: - `getMinExposureOffset()` - `getMaxExposureOffset()` - `getExposureOffsetStepSize()` - `getMaxZoomLevel()` - `getMinZoomLevel()` Part of flutter/flutter#115846. Part of flutter/flutter#125371. Part of flutter/flutter#120468.
- Loading branch information
Showing
29 changed files
with
2,014 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...a_android_camerax/android/src/main/java/io/flutter/plugins/camerax/CameraHostApiImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugins.camerax; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.camera.core.Camera; | ||
import androidx.camera.core.CameraInfo; | ||
import io.flutter.plugin.common.BinaryMessenger; | ||
import io.flutter.plugins.camerax.GeneratedCameraXLibrary.CameraHostApi; | ||
import java.util.Objects; | ||
|
||
public class CameraHostApiImpl implements CameraHostApi { | ||
private final BinaryMessenger binaryMessenger; | ||
private final InstanceManager instanceManager; | ||
|
||
public CameraHostApiImpl( | ||
@NonNull BinaryMessenger binaryMessenger, @NonNull InstanceManager instanceManager) { | ||
this.binaryMessenger = binaryMessenger; | ||
this.instanceManager = instanceManager; | ||
} | ||
|
||
/** | ||
* Retrieves the {@link CameraInfo} instance that contains information about the {@link Camera} | ||
* instance with the specified identifier. | ||
*/ | ||
@Override | ||
@NonNull | ||
public Long getCameraInfo(@NonNull Long identifier) { | ||
Camera camera = (Camera) Objects.requireNonNull(instanceManager.getInstance(identifier)); | ||
CameraInfo cameraInfo = camera.getCameraInfo(); | ||
|
||
CameraInfoFlutterApiImpl cameraInfoFlutterApiImpl = | ||
new CameraInfoFlutterApiImpl(binaryMessenger, instanceManager); | ||
cameraInfoFlutterApiImpl.create(cameraInfo, reply -> {}); | ||
|
||
return instanceManager.getIdentifierForStrongReference(cameraInfo); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...camerax/android/src/main/java/io/flutter/plugins/camerax/ExposureStateFlutterApiImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugins.camerax; | ||
|
||
import android.util.Range; | ||
import androidx.annotation.NonNull; | ||
import androidx.camera.core.ExposureState; | ||
import io.flutter.plugin.common.BinaryMessenger; | ||
import io.flutter.plugins.camerax.GeneratedCameraXLibrary.ExposureCompensationRange; | ||
import io.flutter.plugins.camerax.GeneratedCameraXLibrary.ExposureStateFlutterApi; | ||
|
||
public class ExposureStateFlutterApiImpl extends ExposureStateFlutterApi { | ||
private final InstanceManager instanceManager; | ||
|
||
public ExposureStateFlutterApiImpl( | ||
@NonNull BinaryMessenger binaryMessenger, @NonNull InstanceManager instanceManager) { | ||
super(binaryMessenger); | ||
this.instanceManager = instanceManager; | ||
} | ||
|
||
/** | ||
* Creates a {@link ExposureState} on the Dart side with its exposure compensation range that can | ||
* be used to set the exposure compensation index and its exposure compensation step, the smallest | ||
* step by which the exposure compensation can be changed. | ||
*/ | ||
void create(@NonNull ExposureState exposureState, @NonNull Reply<Void> reply) { | ||
if (instanceManager.containsInstance(exposureState)) { | ||
return; | ||
} | ||
|
||
final Range<Integer> exposureCompensationRangeFromState = | ||
exposureState.getExposureCompensationRange(); | ||
ExposureCompensationRange exposureCompensationRange = | ||
new ExposureCompensationRange.Builder() | ||
.setMinCompensation(exposureCompensationRangeFromState.getLower().longValue()) | ||
.setMaxCompensation(exposureCompensationRangeFromState.getUpper().longValue()) | ||
.build(); | ||
final Double exposureCompensationStep = | ||
exposureState.getExposureCompensationStep().doubleValue(); | ||
|
||
create( | ||
instanceManager.addHostCreatedInstance(exposureState), | ||
exposureCompensationRange, | ||
exposureCompensationStep, | ||
reply); | ||
} | ||
} |
Oops, something went wrong.