Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ef3a2fd
add lens type info to camera plugin [ios-only]
lenzpaul Apr 1, 2025
3cfb74c
run pigeon generator
lenzpaul Apr 1, 2025
944eb04
Update tests
lenzpaul Apr 1, 2025
62323ed
updated versions and Changelogs
lenzpaul Apr 1, 2025
e79e957
adds dependency_overrides for federated plugin PR
lenzpaul Apr 1, 2025
6ae7c00
Add lens type information to camera plugin tests
lenzpaul Apr 1, 2025
ca60496
Add iOS version checks ensuring API availability for camera device types
lenzpaul Apr 1, 2025
e3bbf15
Apply formatting fixes
lenzpaul Apr 1, 2025
1fc8b22
created helper function for lens direction and type
lenzpaul Apr 1, 2025
a696017
Change lens type enum to only use UltraWide, Wide, and Telephoto
lenzpaul Apr 1, 2025
c138373
run pigeon gen and applied flutter_plugin_tools.dart formatting
lenzpaul Apr 1, 2025
83f62da
Update CHANGELOG and Fix CI errors
lenzpaul Apr 1, 2025
d90b0cf
Fix formatting for CI
lenzpaul Apr 1, 2025
85c0dc2
Refactor camera lens direction and type handling in CameraPlugin
lenzpaul Apr 1, 2025
a6c9bb6
Fix documentation for camera lens type descriptions in messages.dart …
lenzpaul Apr 1, 2025
8348554
run format script
lenzpaul Apr 1, 2025
5a69630
Remove unnecessary pubspec changes
lenzpaul Apr 1, 2025
2b797f6
Update camera_platform_interface to 2.9.0 and other minor changes
lenzpaul Apr 1, 2025
4b9335c
Bump camera_platform_interface to 2.10.0 and remove its dependency ov…
lenzpaul Apr 1, 2025
cdf2014
run pigeon generator
lenzpaul Apr 1, 2025
48959c5
Ran formatting script
lenzpaul Apr 1, 2025
a2ed93a
Fix CI issues
lenzpaul Apr 3, 2025
770657a
Fix CI issue: Remove Package.resolved file from iOS example project
lenzpaul Apr 3, 2025
17240e4
Bump version to 0.11.2 and update camera_avfoundation dependency to ^…
lenzpaul Apr 3, 2025
a8d05a6
Merge branch 'main' into camera_package_patch
stuartmorgan-g Sep 26, 2025
e3abfe4
Merge branch 'main' into camera_package_patch
stuartmorgan-g Oct 2, 2025
9b6abc4
Infer enum types
stuartmorgan-g Oct 2, 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
1 change: 1 addition & 0 deletions packages/camera/camera/test/camera_preview_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class FakeController extends ValueNotifier<CameraValue>
name: '',
lensDirection: CameraLensDirection.back,
sensorOrientation: 0,
lensType: CameraLensType.ultraWide,
);

@override
Expand Down
4 changes: 4 additions & 0 deletions packages/camera/camera_avfoundation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.22

* Adds lensType in the PlatformCameraDescription

## 0.9.21+4

* Migrates `updateOrientation` and `setCaptureSessionPreset` methods to Swift.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class MockCaptureDevice: NSObject, FLTCaptureDevice {

var uniqueID = ""
var position = AVCaptureDevice.Position.unspecified
var deviceType = AVCaptureDevice.DeviceType.builtInWideAngleCamera

var activeFormat: FLTCaptureDeviceFormat {
get {
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_avfoundation/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
# The example app is bundled with the plugin so we use a path dependency on
# the parent directory to use the current plugin's version.
path: ../
camera_platform_interface: ^2.7.0
camera_platform_interface: ^2.10.0
flutter:
sdk: flutter
path_provider: ^2.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,12 @@ extension CameraPlugin: FCPCameraApi {
var reply: [FCPPlatformCameraDescription] = []

for device in devices {
var lensFacing: FCPPlatformCameraLensDirection

switch device.position {
case .back:
lensFacing = .back
case .front:
lensFacing = .front
case .unspecified:
lensFacing = .external
@unknown default:
lensFacing = .external
}

let lensFacing = strongSelf.platformLensDirection(for: device)
let lensType = strongSelf.platformLensType(for: device)
let cameraDescription = FCPPlatformCameraDescription.make(
withName: device.uniqueID,
lensDirection: lensFacing
lensDirection: lensFacing,
lensType: lensType
)
reply.append(cameraDescription)
}
Expand All @@ -169,6 +159,35 @@ extension CameraPlugin: FCPCameraApi {
}
}

private func platformLensDirection(for device: FLTCaptureDevice) -> FCPPlatformCameraLensDirection
{
switch device.position {
case .back:
return .back
case .front:
return .front
case .unspecified:
return .external
@unknown default:
return .external
}
}

private func platformLensType(for device: FLTCaptureDevice) -> FCPPlatformCameraLensType {
switch device.deviceType {
case .builtInWideAngleCamera:
return .wide
case .builtInTelephotoCamera:
return .telephoto
case .builtInUltraWideCamera:
return .ultraWide
case .builtInDualWideCamera:
return .wide
default:
return .unknown
}
}

public func createCamera(
withName cameraName: String,
settings: FCPPlatformMediaSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ - (AVCaptureDevicePosition)position {
return self.device.position;
}

- (AVCaptureDeviceType)deviceType {
return self.device.deviceType;
}

// Format/Configuration
- (NSObject<FLTCaptureDeviceFormat> *)activeFormat {
return [[FLTDefaultCaptureDeviceFormat alloc] initWithFormat:self.device.activeFormat];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ NS_ASSUME_NONNULL_BEGIN
// Position/Orientation
@property(nonatomic, readonly) AVCaptureDevicePosition position;

// Lens type
@property(nonatomic, readonly) AVCaptureDeviceType deviceType;

// Format/Configuration
@property(nonatomic, retain) NSObject<FLTCaptureDeviceFormat> *activeFormat;
@property(nonatomic, readonly) NSArray<NSObject<FLTCaptureDeviceFormat> *> *formats;
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 (v22.4.2), do not edit directly.
// Autogenerated from Pigeon (v22.7.4), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import <Foundation/Foundation.h>
Expand All @@ -28,6 +28,23 @@ typedef NS_ENUM(NSUInteger, FCPPlatformCameraLensDirection) {
- (instancetype)initWithValue:(FCPPlatformCameraLensDirection)value;
@end

typedef NS_ENUM(NSUInteger, FCPPlatformCameraLensType) {
/// A built-in wide-angle camera device type.
FCPPlatformCameraLensTypeWide = 0,
/// A built-in camera device type with a longer focal length than a wide-angle camera.
FCPPlatformCameraLensTypeTelephoto = 1,
/// A built-in camera device type with a shorter focal length than a wide-angle camera.
FCPPlatformCameraLensTypeUltraWide = 2,
/// Unknown camera device type.
FCPPlatformCameraLensTypeUnknown = 3,
};

/// Wrapper for FCPPlatformCameraLensType to allow for nullability.
@interface FCPPlatformCameraLensTypeBox : NSObject
@property(nonatomic, assign) FCPPlatformCameraLensType value;
- (instancetype)initWithValue:(FCPPlatformCameraLensType)value;
@end

typedef NS_ENUM(NSUInteger, FCPPlatformDeviceOrientation) {
FCPPlatformDeviceOrientationPortraitUp = 0,
FCPPlatformDeviceOrientationLandscapeLeft = 1,
Expand Down Expand Up @@ -124,11 +141,14 @@ typedef NS_ENUM(NSUInteger, FCPPlatformResolutionPreset) {
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithName:(NSString *)name
lensDirection:(FCPPlatformCameraLensDirection)lensDirection;
lensDirection:(FCPPlatformCameraLensDirection)lensDirection
lensType:(FCPPlatformCameraLensType)lensType;
/// The name of the camera device.
@property(nonatomic, copy) NSString *name;
/// The direction the camera is facing.
@property(nonatomic, assign) FCPPlatformCameraLensDirection lensDirection;
/// The type of the camera lens.
@property(nonatomic, assign) FCPPlatformCameraLensType lensType;
@end

@interface FCPPlatformCameraState : NSObject
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 (v22.4.2), do not edit directly.
// Autogenerated from Pigeon (v22.7.4), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import "./include/camera_avfoundation/messages.g.h"
Expand Down Expand Up @@ -49,6 +49,16 @@ - (instancetype)initWithValue:(FCPPlatformCameraLensDirection)value {
}
@end

@implementation FCPPlatformCameraLensTypeBox
- (instancetype)initWithValue:(FCPPlatformCameraLensType)value {
self = [super init];
if (self) {
_value = value;
}
return self;
}
@end

@implementation FCPPlatformDeviceOrientationBox
- (instancetype)initWithValue:(FCPPlatformDeviceOrientation)value {
self = [super init];
Expand Down Expand Up @@ -152,10 +162,12 @@ + (nullable FCPPlatformSize *)nullableFromList:(NSArray<id> *)list;

@implementation FCPPlatformCameraDescription
+ (instancetype)makeWithName:(NSString *)name
lensDirection:(FCPPlatformCameraLensDirection)lensDirection {
lensDirection:(FCPPlatformCameraLensDirection)lensDirection
lensType:(FCPPlatformCameraLensType)lensType {
FCPPlatformCameraDescription *pigeonResult = [[FCPPlatformCameraDescription alloc] init];
pigeonResult.name = name;
pigeonResult.lensDirection = lensDirection;
pigeonResult.lensType = lensType;
return pigeonResult;
}
+ (FCPPlatformCameraDescription *)fromList:(NSArray<id> *)list {
Expand All @@ -164,6 +176,8 @@ + (FCPPlatformCameraDescription *)fromList:(NSArray<id> *)list {
FCPPlatformCameraLensDirectionBox *boxedFCPPlatformCameraLensDirection =
GetNullableObjectAtIndex(list, 1);
pigeonResult.lensDirection = boxedFCPPlatformCameraLensDirection.value;
FCPPlatformCameraLensTypeBox *boxedFCPPlatformCameraLensType = GetNullableObjectAtIndex(list, 2);
pigeonResult.lensType = boxedFCPPlatformCameraLensType.value;
return pigeonResult;
}
+ (nullable FCPPlatformCameraDescription *)nullableFromList:(NSArray<id> *)list {
Expand All @@ -173,6 +187,7 @@ + (nullable FCPPlatformCameraDescription *)nullableFromList:(NSArray<id> *)list
return @[
self.name ?: [NSNull null],
[[FCPPlatformCameraLensDirectionBox alloc] initWithValue:self.lensDirection],
[[FCPPlatformCameraLensTypeBox alloc] initWithValue:self.lensType],
];
}
@end
Expand Down Expand Up @@ -315,56 +330,62 @@ - (nullable id)readValueOfType:(UInt8)type {
initWithValue:[enumAsNumber integerValue]];
}
case 130: {
NSNumber *enumAsNumber = [self readValue];
return enumAsNumber == nil
? nil
: [[FCPPlatformCameraLensTypeBox alloc] initWithValue:[enumAsNumber integerValue]];
}
case 131: {
NSNumber *enumAsNumber = [self readValue];
return enumAsNumber == nil ? nil
: [[FCPPlatformDeviceOrientationBox alloc]
initWithValue:[enumAsNumber integerValue]];
}
case 131: {
case 132: {
NSNumber *enumAsNumber = [self readValue];
return enumAsNumber == nil
? nil
: [[FCPPlatformExposureModeBox alloc] initWithValue:[enumAsNumber integerValue]];
}
case 132: {
case 133: {
NSNumber *enumAsNumber = [self readValue];
return enumAsNumber == nil
? nil
: [[FCPPlatformFlashModeBox alloc] initWithValue:[enumAsNumber integerValue]];
}
case 133: {
case 134: {
NSNumber *enumAsNumber = [self readValue];
return enumAsNumber == nil
? nil
: [[FCPPlatformFocusModeBox alloc] initWithValue:[enumAsNumber integerValue]];
}
case 134: {
case 135: {
NSNumber *enumAsNumber = [self readValue];
return enumAsNumber == nil ? nil
: [[FCPPlatformImageFileFormatBox alloc]
initWithValue:[enumAsNumber integerValue]];
}
case 135: {
case 136: {
NSNumber *enumAsNumber = [self readValue];
return enumAsNumber == nil ? nil
: [[FCPPlatformImageFormatGroupBox alloc]
initWithValue:[enumAsNumber integerValue]];
}
case 136: {
case 137: {
NSNumber *enumAsNumber = [self readValue];
return enumAsNumber == nil ? nil
: [[FCPPlatformResolutionPresetBox alloc]
initWithValue:[enumAsNumber integerValue]];
}
case 137:
return [FCPPlatformCameraDescription fromList:[self readValue]];
case 138:
return [FCPPlatformCameraState fromList:[self readValue]];
return [FCPPlatformCameraDescription fromList:[self readValue]];
case 139:
return [FCPPlatformMediaSettings fromList:[self readValue]];
return [FCPPlatformCameraState fromList:[self readValue]];
case 140:
return [FCPPlatformPoint fromList:[self readValue]];
return [FCPPlatformMediaSettings fromList:[self readValue]];
case 141:
return [FCPPlatformPoint fromList:[self readValue]];
case 142:
return [FCPPlatformSize fromList:[self readValue]];
default:
return [super readValueOfType:type];
Expand All @@ -380,48 +401,52 @@ - (void)writeValue:(id)value {
FCPPlatformCameraLensDirectionBox *box = (FCPPlatformCameraLensDirectionBox *)value;
[self writeByte:129];
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
} else if ([value isKindOfClass:[FCPPlatformCameraLensTypeBox class]]) {
FCPPlatformCameraLensTypeBox *box = (FCPPlatformCameraLensTypeBox *)value;
[self writeByte:130];
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
} else if ([value isKindOfClass:[FCPPlatformDeviceOrientationBox class]]) {
FCPPlatformDeviceOrientationBox *box = (FCPPlatformDeviceOrientationBox *)value;
[self writeByte:130];
[self writeByte:131];
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
} else if ([value isKindOfClass:[FCPPlatformExposureModeBox class]]) {
FCPPlatformExposureModeBox *box = (FCPPlatformExposureModeBox *)value;
[self writeByte:131];
[self writeByte:132];
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
} else if ([value isKindOfClass:[FCPPlatformFlashModeBox class]]) {
FCPPlatformFlashModeBox *box = (FCPPlatformFlashModeBox *)value;
[self writeByte:132];
[self writeByte:133];
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
} else if ([value isKindOfClass:[FCPPlatformFocusModeBox class]]) {
FCPPlatformFocusModeBox *box = (FCPPlatformFocusModeBox *)value;
[self writeByte:133];
[self writeByte:134];
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
} else if ([value isKindOfClass:[FCPPlatformImageFileFormatBox class]]) {
FCPPlatformImageFileFormatBox *box = (FCPPlatformImageFileFormatBox *)value;
[self writeByte:134];
[self writeByte:135];
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
} else if ([value isKindOfClass:[FCPPlatformImageFormatGroupBox class]]) {
FCPPlatformImageFormatGroupBox *box = (FCPPlatformImageFormatGroupBox *)value;
[self writeByte:135];
[self writeByte:136];
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
} else if ([value isKindOfClass:[FCPPlatformResolutionPresetBox class]]) {
FCPPlatformResolutionPresetBox *box = (FCPPlatformResolutionPresetBox *)value;
[self writeByte:136];
[self writeByte:137];
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
} else if ([value isKindOfClass:[FCPPlatformCameraDescription class]]) {
[self writeByte:137];
[self writeByte:138];
[self writeValue:[value toList]];
} else if ([value isKindOfClass:[FCPPlatformCameraState class]]) {
[self writeByte:138];
[self writeByte:139];
[self writeValue:[value toList]];
} else if ([value isKindOfClass:[FCPPlatformMediaSettings class]]) {
[self writeByte:139];
[self writeByte:140];
[self writeValue:[value toList]];
} else if ([value isKindOfClass:[FCPPlatformPoint class]]) {
[self writeByte:140];
[self writeByte:141];
[self writeValue:[value toList]];
} else if ([value isKindOfClass:[FCPPlatformSize class]]) {
[self writeByte:141];
[self writeByte:142];
[self writeValue:[value toList]];
} else {
[super writeValue:value];
Expand Down
Loading