-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[camerax] Retrieve exposure and zoom camera information #3798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8d4e97a
Add base code
camsim99 011d205
Add impl code
camsim99 bec0734
Redo wrapping
camsim99 6a20918
Merge remote-tracking branch 'upstream/main' into cam_info
camsim99 494404a
Format and get build apk working
camsim99 9b4b705
Add java tests, fix current dart plugin test
camsim99 57941b3
Add new tests
camsim99 5adc355
Format and finish adding tests
camsim99 a6d30b7
Fix tests
camsim99 c642c83
Add more annotations
camsim99 2b4a372
Merge remote-tracking branch 'upstream/main' into cam_info
camsim99 b60e1b3
Edit changelog
camsim99 f3d6b43
Format
camsim99 b82bda4
Merge remote-tracking branch 'upstream/main' into cam_info
camsim99 6fd597a
Fix channel connection issue
camsim99 351043e
First passthrough
camsim99 e57ba9e
Formatting
camsim99 cdfb661
Fix cameraInfo flutter api impl
camsim99 de3c442
Merge remote-tracking branch 'upstream/main' into cam_info
camsim99 6b4c017
Personal review
camsim99 96178e8
Regenerate mocks
camsim99 107d3df
Fix dart tests
camsim99 a907639
Address review
camsim99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this should block this PR, but I should move logic like this out of the create methods since they are constructor-adjacent. |
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix this in that PR if this lands first if I have time. Otherwise, I'll file an issue and update this line in that PR.