Skip to content
Draft
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.6.26+4

* Removes outdated restrictions against concurrent camera use cases.

## 0.6.26+3

* Bumps kotlin_version to 2.3.0.
Expand Down
16 changes: 0 additions & 16 deletions packages/camera/camera_android_camerax/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,6 @@ should add it to your `pubspec.yaml` as usual.

## Limitations

### Concurrent preview display, video recording, image capture, and image streaming

The CameraX plugin only supports the concurrent camera use cases supported by Camerax; see
[their documentation][6] for more information. To avoid the usage of unsupported concurrent
use cases, the plugin behaves according to the following:

* If the preview is paused (via `pausePreview`), concurrent video recording and image capture
and/or image streaming (via `startVideoCapturing(cameraId, VideoCaptureOptions(streamCallback:...))`)
is supported.
* If the preview is not paused
* **and** the camera device is at least supported hardware [`LIMITED`][8], then concurrent
image capture and video recording is supported.
* **and** the camera device is at least supported hardware [`LEVEL_3`][7], then concurrent
video recording and image streaming is supported, but concurrent video recording, image
streaming, and image capture is not supported.

### 240p resolution configuration for video recording

240p resolution configuration for video recording is unsupported by CameraX, and thus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1122,47 +1122,12 @@ class AndroidCameraCameraX extends CameraPlatform {
// There is currently an active recording, so do not start a new one.
return;
}

dynamic Function(CameraImageData)? streamCallback = options.streamCallback;
if (!_previewIsPaused) {
// The plugin binds the preview use case to the camera lifecycle when
// createCamera is called, but camera use cases can become limited
// when video recording and displaying a preview concurrently. This logic
// will prioritize attempting to continue displaying the preview,
// stream images, and record video if specified and supported. Otherwise,
// the preview must be paused in order to allow those concurrently. See
// https://developer.android.com/media/camera/camerax/architecture#combine-use-cases
// for more information on supported concurrent camera use cases.
final camera2CameraInfo = Camera2CameraInfo.from(cameraInfo: cameraInfo!);
final cameraInfoSupportedHardwareLevel =
(await camera2CameraInfo.getCameraCharacteristic(
CameraCharacteristics.infoSupportedHardwareLevel,
))!
as InfoSupportedHardwareLevel;

// Handle limited level device restrictions:
final cameraSupportsConcurrentImageCapture =
cameraInfoSupportedHardwareLevel != InfoSupportedHardwareLevel.legacy;
if (!cameraSupportsConcurrentImageCapture) {
// Concurrent preview + video recording + image capture is not supported
// unless the camera device is cameraSupportsHardwareLevelLimited or
// better.
await _unbindUseCaseFromLifecycle(imageCapture!);
}

// Handle level 3 device restrictions:
final cameraSupportsHardwareLevel3 =
cameraInfoSupportedHardwareLevel == InfoSupportedHardwareLevel.level3;
if (!cameraSupportsHardwareLevel3 || streamCallback == null) {
// Concurrent preview + video recording + image streaming is not supported
// unless the camera device is cameraSupportsHardwareLevel3 or better.
streamCallback = null;
await _unbindUseCaseFromLifecycle(imageAnalysis!);
} else {
// If image streaming concurrently with video recording, image capture
// is unsupported.
await _unbindUseCaseFromLifecycle(imageCapture!);
}
final dynamic Function(CameraImageData)? streamCallback =
options.streamCallback;
if (streamCallback == null) {
// ImageAnalysis is not universally supported with Preview + VideoCapture,
// so unbind ImageAnalysis if it is not in use.
await _unbindUseCaseFromLifecycle(imageAnalysis!);
}

await _bindUseCaseToLifecycle(videoCapture!, options.cameraId);
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_android_camerax/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_android_camerax
description: Android implementation of the camera plugin using the CameraX library.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.6.26+3
version: 0.6.26+4

environment:
sdk: ^3.9.0
Expand Down
Loading
Loading