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

* Updates `ResolutionPreset.max` to allow CameraX high-resolution still capture sizes on Android.

## 0.7.3

* Fixes `videoBitrate` configuration being ignored during video recording.
Expand Down

Large diffs are not rendered by default.

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,66 @@ 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 @@ -1521,7 +1521,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