Skip to content
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

[camerax] Wrap classes to implement resolution configuration for image capture, image analysis, and preview #4523

Merged
merged 29 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dec3d69
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 May 1, 2023
0e0333b
Merge remote-tracking branch 'upstream/main'
camsim99 May 2, 2023
bd7ac99
Merge remote-tracking branch 'upstream/main'
camsim99 May 3, 2023
5c3363b
Merge remote-tracking branch 'upstream/main'
camsim99 May 10, 2023
fed9621
Undo changes
camsim99 May 10, 2023
5aabe34
Merge remote-tracking branch 'upstream/main'
camsim99 May 12, 2023
2b9a352
Merge remote-tracking branch 'upstream/main'
camsim99 May 25, 2023
a1173da
Merge remote-tracking branch 'upstream/main'
camsim99 May 30, 2023
cbc3d6b
Merge remote-tracking branch 'upstream/main'
camsim99 May 30, 2023
cae5a4c
Merge remote-tracking branch 'upstream/main'
camsim99 Jun 1, 2023
72283db
Merge remote-tracking branch 'upstream/main'
camsim99 Jun 5, 2023
166a77c
Merge remote-tracking branch 'upstream/main'
camsim99 Jun 5, 2023
399780e
Merge remote-tracking branch 'upstream/main'
camsim99 Jun 14, 2023
8d5d0e7
Merge remote-tracking branch 'upstream/main'
camsim99 Jun 26, 2023
084d960
Merge remote-tracking branch 'upstream/main'
camsim99 Jul 12, 2023
d2a59ac
Merge remote-tracking branch 'upstream/main'
camsim99 Jul 17, 2023
a1422bf
Merge remote-tracking branch 'upstream/main'
camsim99 Jul 17, 2023
bdd87a6
Merge remote-tracking branch 'upstream/main'
camsim99 Jul 18, 2023
137a28b
Merge remote-tracking branch 'upstream/main'
camsim99 Jul 19, 2023
c78e0b8
Add wrapped classes, tests, and remove deprecated apis
camsim99 Jul 19, 2023
3cd06e8
Modify null check to fix integration test
camsim99 Jul 19, 2023
a383e8f
Cleanup
camsim99 Jul 19, 2023
725a4ec
Add missing import
camsim99 Jul 19, 2023
bdfb634
Fix some spelling errors
camsim99 Jul 19, 2023
fc7c977
Merge remote-tracking branch 'upstream/main' into camx_wrapres
camsim99 Jul 19, 2023
41fdabc
Mark new classes as immutable
camsim99 Jul 20, 2023
996ce03
Address review
camsim99 Jul 24, 2023
d9ab6c3
Merge remote-tracking branch 'upstream/main' into camx_wrapres
camsim99 Jul 24, 2023
98e1035
Address review
camsim99 Jul 27, 2023
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
6 changes: 6 additions & 0 deletions packages/camera/camera_android_camerax/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.5.0+12

* Wraps classes needed to implement resolution configuration for image capture, image analysis, and preview.
* Removes usages of deprecated APIs for resolution configuration.
* Bumps CameraX version to 1.3.0-beta01.

## 0.5.0+11

* Fixes issue with image data not being emitted after relistening to stream returned by `onStreamedFrameAvailable`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ android {

dependencies {
// CameraX core library using the camera2 implementation must use same version number.
def camerax_version = "1.3.0-alpha05"
def camerax_version = "1.3.0-beta01"
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// 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.annotation.VisibleForTesting;
import androidx.camera.core.resolutionselector.AspectRatioStrategy;
import io.flutter.plugins.camerax.GeneratedCameraXLibrary.AspectRatioStrategyHostApi;

/**
* Host API implementation for {@link AspectRatioStrategy}.
*
* <p>This class handles instantiating and adding native object instances that are attached to a
* Dart instance or handle method calls on the associated native class or an instance of the class.
*/
public class AspectRatioStrategyHostApiImpl implements AspectRatioStrategyHostApi {
private final InstanceManager instanceManager;
private final AspectRatioStrategyProxy proxy;

/** Proxy for constructors and static method of {@link AspectRatioStrategy}. */
@VisibleForTesting
public static class AspectRatioStrategyProxy {
/** Creates an instance of {@link AspectRatioStrategy}. */
@NonNull
public AspectRatioStrategy create(
@NonNull Long preferredAspectRatio, @NonNull Long fallbackRule) {
return new AspectRatioStrategy(preferredAspectRatio.intValue(), fallbackRule.intValue());
}
}

/**
* Constructs an {@link AspectRatioStrategyHostApiImpl}.
*
* @param instanceManager maintains instances stored to communicate with attached Dart objects
*/
public AspectRatioStrategyHostApiImpl(@NonNull InstanceManager instanceManager) {
this(instanceManager, new AspectRatioStrategyProxy());
}

/**
* Constructs an {@link AspectRatioStrategyHostApiImpl}.
*
* @param instanceManager maintains instances stored to communicate with attached Dart objects
* @param proxy proxy for constructors and static method of {@link AspectRatioStrategy}
*/
@VisibleForTesting
AspectRatioStrategyHostApiImpl(
@NonNull InstanceManager instanceManager, @NonNull AspectRatioStrategyProxy proxy) {
this.instanceManager = instanceManager;
this.proxy = proxy;
}

/**
* Creates an {@link AspectRatioStrategy} instance with the preferred aspect ratio and fallback
* rule specified.
*/
@Override
public void create(
@NonNull Long identifier, @NonNull Long preferredAspectRatio, @NonNull Long fallbackRule) {
instanceManager.addDartCreatedInstance(
proxy.create(preferredAspectRatio, fallbackRule), identifier);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ public void setUp(
binaryMessenger, pendingRecordingHostApiImpl);
videoCaptureHostApiImpl = new VideoCaptureHostApiImpl(binaryMessenger, instanceManager);
GeneratedCameraXLibrary.VideoCaptureHostApi.setup(binaryMessenger, videoCaptureHostApiImpl);
GeneratedCameraXLibrary.ResolutionSelectorHostApi.setup(
binaryMessenger, new ResolutionSelectorHostApiImpl(instanceManager));
GeneratedCameraXLibrary.ResolutionStrategyHostApi.setup(
binaryMessenger, new ResolutionStrategyHostApiImpl(instanceManager));
GeneratedCameraXLibrary.AspectRatioStrategyHostApi.setup(
binaryMessenger, new AspectRatioStrategyHostApiImpl(instanceManager));
}

@Override
Expand Down
Loading