Skip to content
Merged
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
5 changes: 5 additions & 0 deletions packages/camera/camera_android_camerax/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.7.4+3

* Updates `ResolutionPreset.max` to prefer higher resolution over capture rate
for CameraX `ResolutionSelector` use cases on Android.

## 0.7.4+2

* Bumps cameraxVersion from 1.6.0 to 1.6.1.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v26.1.7), do not edit directly.
// Autogenerated from Pigeon (v26.3.4), do not edit directly.
// See also: https://pub.dev/packages/pigeon
@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass")

Expand Down Expand Up @@ -49,7 +49,7 @@ class CameraXError(
val code: String,
override val message: String? = null,
val details: Any? = null
) : Throwable()
) : RuntimeException()
/**
* Maintains instances used to communicate with the corresponding objects in Dart.
*
Expand Down Expand Up @@ -1301,7 +1301,7 @@ enum class CameraStateType(val raw: Int) {
}
}

/** The types (T) properly wrapped to be used as a LiveData<T>. */
/** The types (T) properly wrapped to be used as a `LiveData<T>`. */
enum class LiveDataSupportedType(val raw: Int) {
CAMERA_STATE(0),
ZOOM_STATE(1);
Expand Down Expand Up @@ -4607,6 +4607,7 @@ abstract class PigeonApiResolutionSelector(
abstract fun pigeon_defaultConstructor(
resolutionFilter: androidx.camera.core.resolutionselector.ResolutionFilter?,
resolutionStrategy: androidx.camera.core.resolutionselector.ResolutionStrategy?,
allowedResolutionMode: Long?,
aspectRatioStrategy: androidx.camera.core.resolutionselector.AspectRatioStrategy?
): androidx.camera.core.resolutionselector.ResolutionSelector

Expand All @@ -4620,6 +4621,15 @@ abstract class PigeonApiResolutionSelector(
pigeon_instance: androidx.camera.core.resolutionselector.ResolutionSelector
): androidx.camera.core.resolutionselector.ResolutionStrategy?

/**
* The allowed resolution mode for the `UseCase`.
*
* See [ResolutionSelectorAllowedResolutionMode].
*/
abstract fun allowedResolutionMode(
pigeon_instance: androidx.camera.core.resolutionselector.ResolutionSelector
): Long?

/**
* Returns the specified `AspectRatioStrategy`, or
* `AspectRatioStrategy.ratio_4_3FallbackAutoStrategy` if none is specified when creating the
Expand Down Expand Up @@ -4647,13 +4657,17 @@ abstract class PigeonApiResolutionSelector(
args[1] as androidx.camera.core.resolutionselector.ResolutionFilter?
val resolutionStrategyArg =
args[2] as androidx.camera.core.resolutionselector.ResolutionStrategy?
val allowedResolutionModeArg = args[3] as Long?
val aspectRatioStrategyArg =
args[3] as androidx.camera.core.resolutionselector.AspectRatioStrategy?
args[4] as androidx.camera.core.resolutionselector.AspectRatioStrategy?
val wrapped: List<Any?> =
try {
api.pigeonRegistrar.instanceManager.addDartCreatedInstance(
api.pigeon_defaultConstructor(
resolutionFilterArg, resolutionStrategyArg, aspectRatioStrategyArg),
resolutionFilterArg,
resolutionStrategyArg,
allowedResolutionModeArg,
aspectRatioStrategyArg),
pigeon_identifierArg)
listOf(null)
} catch (exception: Throwable) {
Expand Down Expand Up @@ -4708,23 +4722,30 @@ abstract class PigeonApiResolutionSelector(
pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg)
val resolutionFilterArg = resolutionFilter(pigeon_instanceArg)
val resolutionStrategyArg = resolutionStrategy(pigeon_instanceArg)
val allowedResolutionModeArg = allowedResolutionMode(pigeon_instanceArg)
val binaryMessenger = pigeonRegistrar.binaryMessenger
val codec = pigeonRegistrar.codec
val channelName =
"dev.flutter.pigeon.camera_android_camerax.ResolutionSelector.pigeon_newInstance"
val channel = BasicMessageChannel<Any?>(binaryMessenger, channelName, codec)
channel.send(listOf(pigeon_identifierArg, resolutionFilterArg, resolutionStrategyArg)) {
if (it is List<*>) {
if (it.size > 1) {
callback(
Result.failure(CameraXError(it[0] as String, it[1] as String, it[2] as String?)))
} else {
callback(Result.success(Unit))
channel.send(
listOf(
pigeon_identifierArg,
resolutionFilterArg,
resolutionStrategyArg,
allowedResolutionModeArg)) {
if (it is List<*>) {
if (it.size > 1) {
callback(
Result.failure(
CameraXError(it[0] as String, it[1] as String, it[2] as String?)))
} else {
callback(Result.success(Unit))
}
} else {
callback(Result.failure(CameraXLibraryPigeonUtils.createConnectionError(channelName)))
}
}
} else {
callback(Result.failure(CameraXLibraryPigeonUtils.createConnectionError(channelName)))
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ResolutionSelectorProxyApi extends PigeonApiResolutionSelector {
public ResolutionSelector pigeon_defaultConstructor(
@Nullable ResolutionFilter resolutionFilter,
@Nullable ResolutionStrategy resolutionStrategy,
@Nullable Long allowedResolutionMode,
@Nullable AspectRatioStrategy aspectRatioStrategy) {
final ResolutionSelector.Builder builder = new ResolutionSelector.Builder();
if (aspectRatioStrategy != null) {
Expand All @@ -37,6 +38,9 @@ public ResolutionSelector pigeon_defaultConstructor(
if (resolutionFilter != null) {
builder.setResolutionFilter(resolutionFilter);
}
if (allowedResolutionMode != null) {
builder.setAllowedResolutionMode(allowedResolutionMode.intValue());
}
return builder.build();
}

Expand All @@ -52,6 +56,12 @@ public ResolutionStrategy resolutionStrategy(@NonNull ResolutionSelector pigeonI
return pigeonInstance.getResolutionStrategy();
}

@Nullable
@Override
public Long allowedResolutionMode(@NonNull ResolutionSelector pigeonInstance) {
return (long) pigeonInstance.getAllowedResolutionMode();
}

@NonNull
@Override
public AspectRatioStrategy getAspectRatioStrategy(@NonNull ResolutionSelector pigeonInstance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,63 @@ public void pigeon_defaultConstructor_createsExpectedResolutionSelectorInstance(
final AspectRatioStrategy aspectRatioStrategy = mock(AspectRatioStrategy.class);

final ResolutionSelector instance =
api.pigeon_defaultConstructor(resolutionFilter, resolutionStrategy, aspectRatioStrategy);
api.pigeon_defaultConstructor(
resolutionFilter, resolutionStrategy, null, aspectRatioStrategy);

assertEquals(instance.getResolutionFilter(), resolutionFilter);
assertEquals(instance.getResolutionStrategy(), resolutionStrategy);
assertEquals(instance.getAspectRatioStrategy(), aspectRatioStrategy);
}

@Test
public void pigeon_defaultConstructor_setsPreferHigherResolutionOverCaptureRateWhenRequested() {
final PigeonApiResolutionSelector api =
new TestProxyApiRegistrar().getPigeonApiResolutionSelector();

final ResolutionSelector instance =
api.pigeon_defaultConstructor(
null,
ResolutionStrategy.HIGHEST_AVAILABLE_STRATEGY,
(long) ResolutionSelector.PREFER_HIGHER_RESOLUTION_OVER_CAPTURE_RATE,
null);

assertEquals(
ResolutionSelector.PREFER_HIGHER_RESOLUTION_OVER_CAPTURE_RATE,
instance.getAllowedResolutionMode());
}

@Test
public void pigeon_defaultConstructor_setsPreferCaptureRateOverHigherResolutionWhenRequested() {
final PigeonApiResolutionSelector api =
new TestProxyApiRegistrar().getPigeonApiResolutionSelector();

final ResolutionSelector instance =
api.pigeon_defaultConstructor(
null,
ResolutionStrategy.HIGHEST_AVAILABLE_STRATEGY,
(long) ResolutionSelector.PREFER_CAPTURE_RATE_OVER_HIGHER_RESOLUTION,
null);

assertEquals(
ResolutionSelector.PREFER_CAPTURE_RATE_OVER_HIGHER_RESOLUTION,
instance.getAllowedResolutionMode());
}

@Test
public void allowedResolutionMode_returnsExpectedAllowedResolutionMode() {
final PigeonApiResolutionSelector api =
new TestProxyApiRegistrar().getPigeonApiResolutionSelector();

final ResolutionSelector instance =
new ResolutionSelector.Builder()
.setAllowedResolutionMode(ResolutionSelector.PREFER_HIGHER_RESOLUTION_OVER_CAPTURE_RATE)
.build();

assertEquals(
(long) ResolutionSelector.PREFER_HIGHER_RESOLUTION_OVER_CAPTURE_RATE,
api.allowedResolutionMode(instance).longValue());
}

@Test
public void resolutionFilter_returnsExpectedResolutionFilter() {
final PigeonApiResolutionSelector api =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,11 @@ class AndroidCameraCameraX extends CameraPlatform {
case ResolutionPreset.max:
// Automatically set strategy to choose highest available.
resolutionStrategy = ResolutionStrategy.highestAvailableStrategy;
return ResolutionSelector(resolutionStrategy: resolutionStrategy);
return ResolutionSelector(
resolutionStrategy: resolutionStrategy,
allowedResolutionMode:
ResolutionSelectorAllowedResolutionMode.preferHigherResolutionOverCaptureRate,
);
case null:
// If no preset is specified, default to CameraX's default behavior
// for each UseCase.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ class Surface {
static const int rotation270 = 3;
}

/// Allowed resolution mode constants for [ResolutionSelector].
class ResolutionSelectorAllowedResolutionMode {
/// CameraX prefers capture rate over higher resolution.
///
/// See https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector#PREFER_CAPTURE_RATE_OVER_HIGHER_RESOLUTION().
static const int preferCaptureRateOverHigherResolution = 0;

/// CameraX prefers higher resolution over capture rate.
///
/// See https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector#PREFER_HIGHER_RESOLUTION_OVER_CAPTURE_RATE().
static const int preferHigherResolutionOverCaptureRate = 1;
}

/// An interface for retrieving camera information.
///
/// See https://developer.android.com/reference/androidx/camera/core/CameraInfo.
Expand Down
Loading
Loading