Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dad18b9
add lens type info to camera plugin [ios-only]
lenzpaul Mar 6, 2025
a53858b
run pigeon generator
lenzpaul Mar 6, 2025
6b8fa07
Update tests
lenzpaul Mar 6, 2025
e0c743a
updated versions and Changelogs
lenzpaul Mar 6, 2025
78fbe47
adds dependency_overrides for federated plugin PR
lenzpaul Mar 6, 2025
2248a71
Add lens type information to camera plugin tests
lenzpaul Mar 6, 2025
0bbfd07
Add iOS version checks ensuring API availability for camera device types
lenzpaul Mar 6, 2025
5e347d7
Apply formatting fixes
lenzpaul Mar 6, 2025
989a270
created helper function for lens direction and type
lenzpaul Mar 6, 2025
ba8263a
Change lens type enum to only use UltraWide, Wide, and Telephoto
lenzpaul Mar 6, 2025
ae66e57
run pigeon gen and applied flutter_plugin_tools.dart formatting
lenzpaul Mar 6, 2025
ec472d7
Update CHANGELOG and Fix CI errors
lenzpaul Mar 6, 2025
9540ef7
Fix formatting for CI
lenzpaul Mar 6, 2025
5a3db31
Refactor camera lens direction and type handling in CameraPlugin
lenzpaul Mar 6, 2025
39aac3c
Fix documentation for camera lens type descriptions in messages.dart …
lenzpaul Mar 6, 2025
ec7f8f2
run format script
lenzpaul Mar 6, 2025
16f9fc4
Remove unnecessary pubspec changes
lenzpaul Mar 6, 2025
d2404a6
Remove temporary dependency overrides from pubspec.yaml files
lenzpaul Mar 6, 2025
697c023
Remove Runner changes
lenzpaul Mar 6, 2025
8aed9ea
Updates versions and CHANGELOGs. Runs pigeon generator
lenzpaul Mar 6, 2025
119beaa
Revert implementation changes in camera_avfoundation
lenzpaul Mar 6, 2025
e338f6f
Revert changes in camera pkg
lenzpaul Mar 6, 2025
93e2484
Updates CameraDescription tests to add toString and include lensType
lenzpaul Mar 7, 2025
77fe9da
Minor changelog adjustments
stuartmorgan-g Mar 7, 2025
8348878
Merge branch 'main' into camera_package_patch_2
stuartmorgan-g Mar 25, 2025
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
Refactor camera lens direction and type handling in CameraPlugin
  • Loading branch information
lenzpaul committed Mar 6, 2025
commit 5a3db31f83307b00a3adef47be9caaac1e578821
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,37 @@
message:error.localizedDescription
details:error.domain];
}
static void FCPGetLensDirectionAndType(AVCaptureDevice *device,
FCPPlatformCameraLensDirection *lensDirection,
FCPPlatformCameraLensType *lensType) {
switch (device.position) {
case AVCaptureDevicePositionBack:
*lensDirection = FCPPlatformCameraLensDirectionBack;
break;
case AVCaptureDevicePositionFront:
*lensDirection = FCPPlatformCameraLensDirectionFront;
break;
case AVCaptureDevicePositionUnspecified:
*lensDirection = FCPPlatformCameraLensDirectionExternal;
break;
}

if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInWideAngleCamera]) {
*lensType = FCPPlatformCameraLensTypeWide;
} else if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInTelephotoCamera]) {
*lensType = FCPPlatformCameraLensTypeTelephoto;
} else if (@available(iOS 13.0, *)) {
if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInUltraWideCamera]) {
*lensType = FCPPlatformCameraLensTypeUltraWide;
} else if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInDualWideCamera]) {
*lensType = FCPPlatformCameraLensTypeWide;
} else {
*lensType = FCPPlatformCameraLensTypeUnknown;
}
} else {
*lensType = FCPPlatformCameraLensTypeUnknown;
}
}

@interface CameraPlugin ()
@property(readonly, nonatomic) NSObject<FlutterTextureRegistry> *registry;
Expand Down Expand Up @@ -151,7 +182,7 @@ - (void)availableCamerasWithCompletion:
for (NSObject<FLTCaptureDevice> *device in devices) {
FCPPlatformCameraLensDirection lensFacing;
FCPPlatformCameraLensType lensType;
getLensDirectionAndType(device, &lensFacing, &lensType);
FCPGetLensDirectionAndType(device, &lensFacing, &lensType);

[reply addObject:[FCPPlatformCameraDescription makeWithName:device.uniqueID
lensDirection:lensFacing
Expand All @@ -161,38 +192,6 @@ - (void)availableCamerasWithCompletion:
});
}

static void getLensDirectionAndType(AVCaptureDevice *device,
FCPPlatformCameraLensDirection *lensDirection,
FCPPlatformCameraLensType *lensType) {
switch (device.position) {
case AVCaptureDevicePositionBack:
*lensDirection = FCPPlatformCameraLensDirectionBack;
break;
case AVCaptureDevicePositionFront:
*lensDirection = FCPPlatformCameraLensDirectionFront;
break;
case AVCaptureDevicePositionUnspecified:
*lensDirection = FCPPlatformCameraLensDirectionExternal;
break;
}

if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInWideAngleCamera]) {
*lensType = FCPPlatformCameraLensTypeWide;
} else if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInTelephotoCamera]) {
*lensType = FCPPlatformCameraLensTypeTelephoto;
} else if (@available(iOS 13.0, *)) {
if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInUltraWideCamera]) {
*lensType = FCPPlatformCameraLensTypeUltraWide;
} else if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInDualWideCamera]) {
*lensType = FCPPlatformCameraLensTypeWide;
} else {
*lensType = FCPPlatformCameraLensTypeUnknown;
}
} else {
*lensType = FCPPlatformCameraLensTypeUnknown;
}
}

- (void)createCameraWithName:(nonnull NSString *)cameraName
settings:(nonnull FCPPlatformMediaSettings *)settings
completion:
Expand Down