Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7894cc2
Add base code from proof of concept
camsim99 Feb 7, 2023
efca3ed
Fix analyzer
camsim99 Feb 7, 2023
b4ae1db
Add example app and tests
camsim99 Feb 9, 2023
7c8168b
Actually add tets and visible for testing annotation
camsim99 Feb 9, 2023
93d442b
Make methods private
camsim99 Feb 9, 2023
d99ef9c
Merge remote-tracking branch 'upstream/main' into camx_preview
camsim99 Feb 9, 2023
bf1ca9a
Fix tests
camsim99 Feb 9, 2023
b237d6e
Fix analyze:
camsim99 Feb 10, 2023
a21429a
Update changelog
camsim99 Feb 10, 2023
dcff8bc
Formatting
camsim99 Feb 10, 2023
a183944
Merge remote-tracking branch 'upstream/main' into camx_preview
camsim99 Feb 10, 2023
f163907
Update todos with links and modify camera controller
camsim99 Feb 10, 2023
285659d
Format and add availableCameras
camsim99 Feb 10, 2023
cffc0ac
Fix mocks
camsim99 Feb 10, 2023
889802d
Try bumping mockito version
camsim99 Feb 10, 2023
24ee512
Review documentation
camsim99 Feb 10, 2023
573cf33
Re-generate mocks
camsim99 Feb 13, 2023
d08c087
Fix typo
camsim99 Feb 14, 2023
1e1dd8b
Fix another typo
camsim99 Feb 14, 2023
e1cea85
Address review and fix bug
camsim99 Feb 14, 2023
5ccc872
Merge remote-tracking branch 'upstream/main' into camx_preview
camsim99 Feb 14, 2023
7129845
Fix analyze
camsim99 Feb 14, 2023
c54c547
Merge remote-tracking branch 'upstream/main' into camx_preview
camsim99 Feb 14, 2023
5f30bc7
Fix tests
camsim99 Feb 14, 2023
8fc71f9
Foramtting
camsim99 Feb 14, 2023
d50bd87
Clear preview is paused
camsim99 Feb 15, 2023
de2fc29
Add unknown lens
camsim99 Feb 15, 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
Prev Previous commit
Next Next commit
Review documentation
  • Loading branch information
camsim99 committed Feb 10, 2023
commit 24ee512bb82e1efb2bcb82dec431c20037758f22
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AndroidCameraCameraX extends CameraPlatform {
@visibleForTesting
Preview? preview;

/// Whether or not the [Preview] is currently bound to the lifecycle that the
/// Whether or not the [preview] is currently bound to the lifecycle that the
/// [processCameraProvider] tracks.
@visibleForTesting
bool previewIsBound = false;
Expand All @@ -57,8 +57,7 @@ class AndroidCameraCameraX extends CameraPlatform {
@visibleForTesting
CameraSelector? cameraSelector;

/// The controller we need to broadcast the different events coming
/// from handleMethodCall, specific to camera events.
/// The controller we need to broadcast the different camera events.
///
/// It is a `broadcast` because multiple controllers will connect to
/// different stream views of this Controller.
Expand Down Expand Up @@ -118,14 +117,14 @@ class AndroidCameraCameraX extends CameraPlatform {
return cameraDescriptions;
}

/// Creates an uninitialized camera instance and returns the cameraId.
/// Creates an uninitialized camera instance and returns the camera ID.
///
/// In the CameraX library, cameras are accessed by combining [UseCase]s
/// to an instance of a [ProcessCameraProvider]. Thus, to create an
/// unitialized camera instance, this method retrieves a
/// [ProcessCameraProvider] instance.
///
/// To return the cameraID, which represents the ID of the surface texture
/// To return the camera ID, which is equivalent to the ID of the surface texture
/// that a camera preview can be drawn to, a [Preview] instance is configured
/// and bound to the [ProcessCameraProvider] instance.
@override
Expand All @@ -134,9 +133,10 @@ class AndroidCameraCameraX extends CameraPlatform {
ResolutionPreset? resolutionPreset, {
bool enableAudio = false,
}) async {
// Must obtatin proper permissions before attempts to access a camera.
// Must obtatin proper permissions before attempting to access a camera.
await requestCameraPermissions(enableAudio);

// Save CameraSelector that matches cameraDescription.
final int cameraSelectorLensDirection =
_getCameraSelectorLensDirection(cameraDescription.lensDirection);
final bool cameraIsFrontFacing =
Expand All @@ -163,7 +163,7 @@ class AndroidCameraCameraX extends CameraPlatform {
/// Initializes the camera on the device.
///
/// Since initialization of a camera does not directly map as an operation to
/// the CameraX library, this method only retrieves information about the
/// the CameraX library, this method just retrieves information about the
/// camera and sends a [CameraInitializedEvent].
///
/// [imageFormatGroup] is used to specify the image formatting used.
Expand Down Expand Up @@ -220,13 +220,13 @@ class AndroidCameraCameraX extends CameraPlatform {
processCameraProvider?.unbindAll();
}

/// Callback method for the initialization of a camera.
/// The camera has been initialized.
@override
Stream<CameraInitializedEvent> onCameraInitialized(int cameraId) {
return _cameraEvents(cameraId).whereType<CameraInitializedEvent>();
}

/// Callback method for native camera errors.
/// The camera experienced an error.
@override
Stream<CameraErrorEvent> onCameraError(int cameraId) {
return SystemServices.cameraErrorStreamController.stream
Expand All @@ -235,20 +235,24 @@ class AndroidCameraCameraX extends CameraPlatform {
});
}

/// Callback method for changes in device orientation.
/// The ui orientation changed.
@override
Stream<DeviceOrientationChangedEvent> onDeviceOrientationChanged() {
return SystemServices.deviceOrientationChangedStreamController.stream;
}

/// Pause the active preview on the current frame for the selected camera.
///
/// [cameraId] not used.
@override
Future<void> pausePreview(int cameraId) async {
_unbindPreviewFromLifecycle();
_previewIsPaused = true;
}

/// Resume the paused preview for the selected camera.
///
/// [cameraId] not used.
@override
Future<void> resumePreview(int cameraId) async {
await _bindPreviewToLifecycle();
Expand Down Expand Up @@ -276,7 +280,7 @@ class AndroidCameraCameraX extends CameraPlatform {
// Methods for binding UseCases to the lifecycle of the camera controlled
// by a ProcessCameraProvider instance:

/// Binds [Preview] instance to the camera lifecycle controlled by the
/// Binds [preview] instance to the camera lifecycle controlled by the
/// [processCameraProvider].
Future<void> _bindPreviewToLifecycle() async {
assert(processCameraProvider != null);
Expand All @@ -292,7 +296,7 @@ class AndroidCameraCameraX extends CameraPlatform {
previewIsBound = true;
}

/// Unbinds [Preview] instance to camera lifecycle controlled by the
/// Unbinds [preview] instance to camera lifecycle controlled by the
/// [processCameraProvider].
void _unbindPreviewFromLifecycle() {
if (preview == null || !previewIsBound) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void main() {
enableAudio: enableAudio),
equals(testSurfaceTextureId));

// Verify permnissions are requested and the camera starts listening for device orientation changes.
// Verify permissions are requested and the camera starts listening for device orientation changes.
expect(camera.cameraPermissionsRequested, isTrue);
expect(camera.startedListeningForDeviceOrientationChanges, isTrue);

Expand Down